* lisp/isearch.el (isearch-search-fun-default): New function.

(isearch-search-fun): Move default part to the new function
`isearch-search-fun-default'.
(isearch-search-fun-function): Set the default value to
`isearch-search-fun-default'. 

* lisp/comint.el (comint-history-isearch-end):
Use `isearch-search-fun-default'.
(comint-history-isearch-search): Use `isearch-search-fun-default'
and remove spacial case for `isearch-word'.
(comint-history-isearch-wrap): Remove spacial case for
`isearch-word'.

* lisp/hexl.el (hexl-isearch-search-function):
Use `isearch-search-fun-default'.

* lisp/info.el (Info-isearch-search): Use `isearch-search-fun-default'.
Use `word-search-regexp' for `isearch-word'.

* lisp/misearch.el (multi-isearch-search-fun):
Use `isearch-search-fun-default'.

* lisp/simple.el (minibuffer-history-isearch-search):
Use `isearch-search-fun-default' and remove spacial case for
`isearch-word'.
(minibuffer-history-isearch-wrap): Remove spacial case for
`isearch-word'.

* lisp/textmodes/reftex-global.el (reftex-isearch-wrap-function):
Remove spacial case for `isearch-word'.
(reftex-isearch-isearch-search): Use `isearch-search-fun-default'.

Fixes: debbugs:11381
This commit is contained in:
Juri Linkov 2012-05-29 12:09:38 +03:00
parent c846da4383
commit 8cbd80f713
8 changed files with 187 additions and 187 deletions

View file

@ -1,3 +1,37 @@
2012-05-29 Juri Linkov <juri@jurta.org>
* isearch.el (isearch-search-fun-default): New function.
(isearch-search-fun): Move default part to the new function
`isearch-search-fun-default'.
(isearch-search-fun-function): Set the default value to
`isearch-search-fun-default'. (Bug#11381)
* comint.el (comint-history-isearch-end):
Use `isearch-search-fun-default'.
(comint-history-isearch-search): Use `isearch-search-fun-default'
and remove spacial case for `isearch-word'.
(comint-history-isearch-wrap): Remove spacial case for
`isearch-word'.
* hexl.el (hexl-isearch-search-function):
Use `isearch-search-fun-default'.
* info.el (Info-isearch-search): Use `isearch-search-fun-default'.
Use `word-search-regexp' for `isearch-word'.
* misearch.el (multi-isearch-search-fun):
Use `isearch-search-fun-default'.
* simple.el (minibuffer-history-isearch-search):
Use `isearch-search-fun-default' and remove spacial case for
`isearch-word'.
(minibuffer-history-isearch-wrap): Remove spacial case for
`isearch-word'.
* textmodes/reftex-global.el (reftex-isearch-wrap-function):
Remove spacial case for `isearch-word'.
(reftex-isearch-isearch-search): Use `isearch-search-fun-default'.
2012-05-28 Agustín Martín Domingo <agustin.martin@hispalinux.es>
Decrease XEmacs incompatibilities.

View file

@ -1441,7 +1441,7 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'."
(if comint-history-isearch-message-overlay
(delete-overlay comint-history-isearch-message-overlay))
(setq isearch-message-prefix-add nil)
(setq isearch-search-fun-function nil)
(setq isearch-search-fun-function 'isearch-search-fun-default)
(setq isearch-message-function nil)
(setq isearch-wrap-function nil)
(setq isearch-push-state-function nil)
@ -1463,67 +1463,59 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'."
(defun comint-history-isearch-search ()
"Return the proper search function, for Isearch in input history."
(cond
(isearch-word
(if isearch-forward 'word-search-forward 'word-search-backward))
(t
(lambda (string bound noerror)
(let ((search-fun
;; Use standard functions to search within comint text
(cond
(isearch-regexp
(if isearch-forward 're-search-forward 're-search-backward))
(t
(if isearch-forward 'search-forward 'search-backward))))
found)
;; Avoid lazy-highlighting matches in the comint prompt and in the
;; output when searching forward. Lazy-highlight calls this lambda
;; with the bound arg, so skip the prompt and the output.
(if (and bound isearch-forward (not (comint-after-pmark-p)))
(goto-char (process-mark (get-buffer-process (current-buffer)))))
(or
;; 1. First try searching in the initial comint text
(funcall search-fun string
(if isearch-forward bound (comint-line-beginning-position))
noerror)
;; 2. If the above search fails, start putting next/prev history
;; elements in the comint successively, and search the string
;; in them. Do this only when bound is nil (i.e. not while
;; lazy-highlighting search strings in the current comint text).
(unless bound
(condition-case nil
(progn
(while (not found)
(cond (isearch-forward
;; Signal an error here explicitly, because
;; `comint-next-input' doesn't signal an error.
(when (null comint-input-ring-index)
(error "End of history; no next item"))
(comint-next-input 1)
(goto-char (comint-line-beginning-position)))
(t
;; Signal an error here explicitly, because
;; `comint-previous-input' doesn't signal an error.
(when (eq comint-input-ring-index
(1- (ring-length comint-input-ring)))
(error "Beginning of history; no preceding item"))
(comint-previous-input 1)
(goto-char (point-max))))
(setq isearch-barrier (point) isearch-opoint (point))
;; After putting the next/prev history element, search
;; the string in them again, until comint-next-input
;; or comint-previous-input raises an error at the
;; beginning/end of history.
(setq found (funcall search-fun string
(unless isearch-forward
;; For backward search, don't search
;; in the comint prompt
(comint-line-beginning-position))
noerror)))
;; Return point of the new search result
(point))
;; Return nil on the error "no next/preceding item"
(error nil)))))))))
(lambda (string bound noerror)
(let ((search-fun
;; Use standard functions to search within comint text
(isearch-search-fun-default))
found)
;; Avoid lazy-highlighting matches in the comint prompt and in the
;; output when searching forward. Lazy-highlight calls this lambda
;; with the bound arg, so skip the prompt and the output.
(if (and bound isearch-forward (not (comint-after-pmark-p)))
(goto-char (process-mark (get-buffer-process (current-buffer)))))
(or
;; 1. First try searching in the initial comint text
(funcall search-fun string
(if isearch-forward bound (comint-line-beginning-position))
noerror)
;; 2. If the above search fails, start putting next/prev history
;; elements in the comint successively, and search the string
;; in them. Do this only when bound is nil (i.e. not while
;; lazy-highlighting search strings in the current comint text).
(unless bound
(condition-case nil
(progn
(while (not found)
(cond (isearch-forward
;; Signal an error here explicitly, because
;; `comint-next-input' doesn't signal an error.
(when (null comint-input-ring-index)
(error "End of history; no next item"))
(comint-next-input 1)
(goto-char (comint-line-beginning-position)))
(t
;; Signal an error here explicitly, because
;; `comint-previous-input' doesn't signal an error.
(when (eq comint-input-ring-index
(1- (ring-length comint-input-ring)))
(error "Beginning of history; no preceding item"))
(comint-previous-input 1)
(goto-char (point-max))))
(setq isearch-barrier (point) isearch-opoint (point))
;; After putting the next/prev history element, search
;; the string in them again, until comint-next-input
;; or comint-previous-input raises an error at the
;; beginning/end of history.
(setq found (funcall search-fun string
(unless isearch-forward
;; For backward search, don't search
;; in the comint prompt
(comint-line-beginning-position))
noerror)))
;; Return point of the new search result
(point))
;; Return nil on the error "no next/preceding item"
(error nil)))))))
(defun comint-history-isearch-message (&optional c-q-hack ellipsis)
"Display the input history search prompt.
@ -1556,14 +1548,13 @@ Otherwise, it displays the standard Isearch message returned from
"Wrap the input history search when search fails.
Move point to the first history element for a forward search,
or to the last history element for a backward search."
(unless isearch-word
;; When `comint-history-isearch-search' fails on reaching the
;; beginning/end of the history, wrap the search to the first/last
;; input history element.
(if isearch-forward
(comint-goto-input (1- (ring-length comint-input-ring)))
(comint-goto-input nil))
(setq isearch-success t))
;; When `comint-history-isearch-search' fails on reaching the
;; beginning/end of the history, wrap the search to the first/last
;; input history element.
(if isearch-forward
(comint-goto-input (1- (ring-length comint-input-ring)))
(comint-goto-input nil))
(setq isearch-success t)
(goto-char (if isearch-forward (comint-line-beginning-position) (point-max))))
(defun comint-history-isearch-push-state ()

View file

@ -420,8 +420,7 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
" \\(?: .+\n[a-f0-9]+: \\)?"))
textre))
bound noerror count))
(let ((isearch-search-fun-function nil))
(isearch-search-fun))))
(isearch-search-fun-default)))
(defvar hexl-in-save-buffer nil)

View file

@ -1925,26 +1925,23 @@ If DIRECTION is `backward', search in the reverse direction."
(defun Info-isearch-search ()
(if Info-isearch-search
(lambda (string &optional bound noerror count)
(if isearch-word
(Info-search (concat "\\b" (replace-regexp-in-string
"\\W+" "\\W+"
(replace-regexp-in-string
"^\\W+\\|\\W+$" "" string)
nil t)
;; Lax version of word search
(if (or isearch-nonincremental
(eq (length string)
(length (isearch-string-state
(car isearch-cmds)))))
"\\b"))
bound noerror count
(unless isearch-forward 'backward))
(Info-search (if isearch-regexp string (regexp-quote string))
bound noerror count
(unless isearch-forward 'backward)))
(Info-search
(cond
(isearch-word
;; Lax version of word search
(let ((lax (not (or isearch-nonincremental
(eq (length string)
(length (isearch-string-state
(car isearch-cmds))))))))
(if (functionp isearch-word)
(funcall isearch-word string lax)
(word-search-regexp string lax))))
(isearch-regexp string)
(t (regexp-quote string)))
bound noerror count
(unless isearch-forward 'backward))
(point))
(let ((isearch-search-fun-function nil))
(isearch-search-fun))))
(isearch-search-fun-default)))
(defun Info-isearch-wrap ()
(if Info-isearch-search

View file

@ -2356,8 +2356,8 @@ If there is no completion possible, say so and continue searching."
;; Searching
(defvar isearch-search-fun-function nil
"Overrides the default `isearch-search-fun' behavior.
(defvar isearch-search-fun-function 'isearch-search-fun-default
"Non-default value overrides the behavior of `isearch-search-fun-default'.
This variable's value should be a function, which will be called
with no arguments, and should return a function that takes three
arguments: STRING, BOUND, and NOERROR.
@ -2368,22 +2368,24 @@ search for the first occurrence of STRING or its translation.")
(defun isearch-search-fun ()
"Return the function to use for the search.
Can be changed via `isearch-search-fun-function' for special needs."
(if isearch-search-fun-function
(funcall isearch-search-fun-function)
(cond
(isearch-word
;; Use lax versions to not fail at the end of the word while
;; the user adds and removes characters in the search string
;; (or when using nonincremental word isearch)
(if (or isearch-nonincremental
(eq (length isearch-string)
(length (isearch-string-state (car isearch-cmds)))))
(if isearch-forward 'word-search-forward 'word-search-backward)
(if isearch-forward 'word-search-forward-lax 'word-search-backward-lax)))
(isearch-regexp
(if isearch-forward 're-search-forward 're-search-backward))
(t
(if isearch-forward 'search-forward 'search-backward)))))
(funcall (or isearch-search-fun-function 'isearch-search-fun-default)))
(defun isearch-search-fun-default ()
"Return default functions to use for the search."
(cond
(isearch-word
;; Use lax versions to not fail at the end of the word while
;; the user adds and removes characters in the search string
;; (or when using nonincremental word isearch)
(if (or isearch-nonincremental
(eq (length isearch-string)
(length (isearch-string-state (car isearch-cmds)))))
(if isearch-forward 'word-search-forward 'word-search-backward)
(if isearch-forward 'word-search-forward-lax 'word-search-backward-lax)))
(isearch-regexp
(if isearch-forward 're-search-forward 're-search-backward))
(t
(if isearch-forward 'search-forward 'search-backward))))
(defun isearch-search-string (string bound noerror)
"Search for the first occurrence of STRING or its translation.

View file

@ -130,13 +130,7 @@ Intended to be added to `isearch-mode-hook'."
(lambda (string bound noerror)
(let ((search-fun
;; Use standard functions to search within one buffer
(cond
(isearch-word
(if isearch-forward 'word-search-forward 'word-search-backward))
(isearch-regexp
(if isearch-forward 're-search-forward 're-search-backward))
(t
(if isearch-forward 'search-forward 'search-backward))))
(isearch-search-fun-default))
found buffer)
(or
;; 1. First try searching in the initial buffer

View file

@ -1699,58 +1699,50 @@ Intended to be added to `minibuffer-setup-hook'."
(defun minibuffer-history-isearch-search ()
"Return the proper search function, for isearch in minibuffer history."
(cond
(isearch-word
(if isearch-forward 'word-search-forward 'word-search-backward))
(t
(lambda (string bound noerror)
(let ((search-fun
;; Use standard functions to search within minibuffer text
(cond
(isearch-regexp
(if isearch-forward 're-search-forward 're-search-backward))
(t
(if isearch-forward 'search-forward 'search-backward))))
found)
;; Avoid lazy-highlighting matches in the minibuffer prompt when
;; searching forward. Lazy-highlight calls this lambda with the
;; bound arg, so skip the minibuffer prompt.
(if (and bound isearch-forward (< (point) (minibuffer-prompt-end)))
(goto-char (minibuffer-prompt-end)))
(or
;; 1. First try searching in the initial minibuffer text
(funcall search-fun string
(if isearch-forward bound (minibuffer-prompt-end))
noerror)
;; 2. If the above search fails, start putting next/prev history
;; elements in the minibuffer successively, and search the string
;; in them. Do this only when bound is nil (i.e. not while
;; lazy-highlighting search strings in the current minibuffer text).
(unless bound
(condition-case nil
(progn
(while (not found)
(cond (isearch-forward
(next-history-element 1)
(goto-char (minibuffer-prompt-end)))
(t
(previous-history-element 1)
(goto-char (point-max))))
(setq isearch-barrier (point) isearch-opoint (point))
;; After putting the next/prev history element, search
;; the string in them again, until next-history-element
;; or previous-history-element raises an error at the
;; beginning/end of history.
(setq found (funcall search-fun string
(unless isearch-forward
;; For backward search, don't search
;; in the minibuffer prompt
(minibuffer-prompt-end))
noerror)))
;; Return point of the new search result
(point))
;; Return nil when next(prev)-history-element fails
(error nil)))))))))
(lambda (string bound noerror)
(let ((search-fun
;; Use standard functions to search within minibuffer text
(isearch-search-fun-default))
found)
;; Avoid lazy-highlighting matches in the minibuffer prompt when
;; searching forward. Lazy-highlight calls this lambda with the
;; bound arg, so skip the minibuffer prompt.
(if (and bound isearch-forward (< (point) (minibuffer-prompt-end)))
(goto-char (minibuffer-prompt-end)))
(or
;; 1. First try searching in the initial minibuffer text
(funcall search-fun string
(if isearch-forward bound (minibuffer-prompt-end))
noerror)
;; 2. If the above search fails, start putting next/prev history
;; elements in the minibuffer successively, and search the string
;; in them. Do this only when bound is nil (i.e. not while
;; lazy-highlighting search strings in the current minibuffer text).
(unless bound
(condition-case nil
(progn
(while (not found)
(cond (isearch-forward
(next-history-element 1)
(goto-char (minibuffer-prompt-end)))
(t
(previous-history-element 1)
(goto-char (point-max))))
(setq isearch-barrier (point) isearch-opoint (point))
;; After putting the next/prev history element, search
;; the string in them again, until next-history-element
;; or previous-history-element raises an error at the
;; beginning/end of history.
(setq found (funcall search-fun string
(unless isearch-forward
;; For backward search, don't search
;; in the minibuffer prompt
(minibuffer-prompt-end))
noerror)))
;; Return point of the new search result
(point))
;; Return nil when next(prev)-history-element fails
(error nil)))))))
(defun minibuffer-history-isearch-message (&optional c-q-hack ellipsis)
"Display the minibuffer history search prompt.
@ -1781,14 +1773,13 @@ Otherwise, it displays the standard isearch message returned from
"Wrap the minibuffer history search when search fails.
Move point to the first history element for a forward search,
or to the last history element for a backward search."
(unless isearch-word
;; When `minibuffer-history-isearch-search' fails on reaching the
;; beginning/end of the history, wrap the search to the first/last
;; minibuffer history element.
(if isearch-forward
(goto-history-element (length (symbol-value minibuffer-history-variable)))
(goto-history-element 0))
(setq isearch-success t))
;; When `minibuffer-history-isearch-search' fails on reaching the
;; beginning/end of the history, wrap the search to the first/last
;; minibuffer history element.
(if isearch-forward
(goto-history-element (length (symbol-value minibuffer-history-variable)))
(goto-history-element 0))
(setq isearch-success t)
(goto-char (if isearch-forward (minibuffer-prompt-end) (point-max))))
(defun minibuffer-history-isearch-push-state ()

View file

@ -350,9 +350,8 @@ Also checks if buffers visiting the files are in read-only mode."
;; variable `multi-isearch-next-buffer-function'.
(defun reftex-isearch-wrap-function ()
(if (not isearch-word)
(switch-to-buffer
(funcall isearch-next-buffer-function (current-buffer) t)))
(switch-to-buffer
(funcall isearch-next-buffer-function (current-buffer) t))
(goto-char (if isearch-forward (point-min) (point-max))))
(defun reftex-isearch-push-state-function ()
@ -364,14 +363,7 @@ Also checks if buffers visiting the files are in read-only mode."
(defun reftex-isearch-isearch-search (string bound noerror)
(let ((nxt-buff nil)
(search-fun
(cond
(isearch-word
(if isearch-forward 'word-search-forward 'word-search-backward))
(isearch-regexp
(if isearch-forward 're-search-forward 're-search-backward))
(t
(if isearch-forward 'search-forward 'search-backward)))))
(search-fun (isearch-search-fun-default)))
(or
(funcall search-fun string bound noerror)
(unless bound