emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-24 r108415: * lisp/isearch.el (isearc


From: Juri Linkov
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r108415: * lisp/isearch.el (isearch-search-fun-default): New function.
Date: Fri, 02 Nov 2012 02:24:55 -0000
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108415
fixes bug: http://debbugs.gnu.org/11381
committer: Juri Linkov <address@hidden>
branch nick: trunk
timestamp: Tue 2012-05-29 12:09:38 +0300
message:
  * 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'.
modified:
  lisp/ChangeLog
  lisp/comint.el
  lisp/hexl.el
  lisp/info.el
  lisp/isearch.el
  lisp/misearch.el
  lisp/simple.el
  lisp/textmodes/reftex-global.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-05-29 06:16:49 +0000
+++ b/lisp/ChangeLog    2012-05-29 09:09:38 +0000
@@ -1,3 +1,37 @@
+2012-05-29  Juri Linkov  <address@hidden>
+
+       * 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  <address@hidden>
 
        Decrease XEmacs incompatibilities.

=== modified file 'lisp/comint.el'
--- a/lisp/comint.el    2012-05-29 06:16:49 +0000
+++ b/lisp/comint.el    2012-05-29 09:09:38 +0000
@@ -1441,7 +1441,7 @@
   (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 @@
 
 (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 @@
   "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 ()

=== modified file 'lisp/hexl.el'
--- a/lisp/hexl.el      2012-04-14 05:10:55 +0000
+++ b/lisp/hexl.el      2012-05-29 09:09:38 +0000
@@ -420,8 +420,7 @@
                                   " \\(?: .+\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)
 

=== modified file 'lisp/info.el'
--- a/lisp/info.el      2012-05-26 21:23:28 +0000
+++ b/lisp/info.el      2012-05-29 09:09:38 +0000
@@ -1925,26 +1925,23 @@
 (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

=== modified file 'lisp/isearch.el'
--- a/lisp/isearch.el   2012-05-17 00:03:49 +0000
+++ b/lisp/isearch.el   2012-05-29 09:09:38 +0000
@@ -2356,8 +2356,8 @@
 
 ;; 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 @@
 (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.

=== modified file 'lisp/misearch.el'
--- a/lisp/misearch.el  2012-01-19 07:21:25 +0000
+++ b/lisp/misearch.el  2012-05-29 09:09:38 +0000
@@ -130,13 +130,7 @@
   (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

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2012-05-04 23:16:47 +0000
+++ b/lisp/simple.el    2012-05-29 09:09:38 +0000
@@ -1699,58 +1699,50 @@
 
 (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 @@
   "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 ()

=== modified file 'lisp/textmodes/reftex-global.el'
--- a/lisp/textmodes/reftex-global.el   2012-01-19 07:21:25 +0000
+++ b/lisp/textmodes/reftex-global.el   2012-05-29 09:09:38 +0000
@@ -350,9 +350,8 @@
 ;; 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 @@
 
 (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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]