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 r108416: * lisp/isearch.el (isearc


From: Juri Linkov
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r108416: * lisp/isearch.el (isearch-word): Add docstring.
Date: Fri, 02 Nov 2012 02:25:00 -0000
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108416
fixes bug: http://debbugs.gnu.org/11381
committer: Juri Linkov <address@hidden>
branch nick: trunk
timestamp: Tue 2012-05-29 12:27:39 +0300
message:
  * lisp/isearch.el (isearch-word): Add docstring. 
  (isearch-occur, isearch-search-and-update): If `isearch-word' is
  a function, call it to get the regexp.
  (isearch-message-prefix): If `isearch-word' holds a symbol, use its
  property `isearch-message-prefix' instead of the string "word ".
  (isearch-search-fun-default): For the case of `isearch-word',
  return a lambda that calls re-search-forward/re-search-backward
  with a regexp returned by `word-search-regexp' or by the function
  in `isearch-word'.
modified:
  lisp/ChangeLog
  lisp/isearch.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-05-29 09:09:38 +0000
+++ b/lisp/ChangeLog    2012-05-29 09:27:39 +0000
@@ -1,5 +1,17 @@
 2012-05-29  Juri Linkov  <address@hidden>
 
+       * isearch.el (isearch-word): Add docstring.  (Bug#11381)
+       (isearch-occur, isearch-search-and-update): If `isearch-word' is
+       a function, call it to get the regexp.
+       (isearch-message-prefix): If `isearch-word' holds a symbol, use its
+       property `isearch-message-prefix' instead of the string "word ".
+       (isearch-search-fun-default): For the case of `isearch-word',
+       return a lambda that calls re-search-forward/re-search-backward
+       with a regexp returned by `word-search-regexp' or by the function
+       in `isearch-word'.
+
+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'.

=== modified file 'lisp/isearch.el'
--- a/lisp/isearch.el   2012-05-29 09:09:38 +0000
+++ b/lisp/isearch.el   2012-05-29 09:27:39 +0000
@@ -530,8 +530,13 @@
 
 (defvar isearch-forward nil)   ; Searching in the forward direction.
 (defvar isearch-regexp nil)    ; Searching for a regexp.
-(defvar isearch-word nil)      ; Searching for words.
-(defvar isearch-hidden nil) ; Non-nil if the string exists but is invisible.
+(defvar isearch-word nil
+  "Regexp-based search mode for words.
+If t, do incremental search for a sequence of words, ignoring punctuation.
+If the value is a function, it is called to convert the search string
+to a regexp used by regexp search functions.  The property
+`isearch-message-prefix' put on this function specifies the
+prefix string displyed in the search message.")
 
 (defvar isearch-cmds nil
   "Stack of search status sets.
@@ -592,6 +597,9 @@
 ;; Accumulate here the overlays opened during searching.
 (defvar isearch-opened-overlays nil)
 
+;; Non-nil if the string exists but is invisible.
+(defvar isearch-hidden nil)
+
 ;; The value of input-method-function when isearch is invoked.
 (defvar isearch-input-method-function nil)
 
@@ -747,14 +755,14 @@
 ;;  "List of commands for which isearch-mode does not recursive-edit.")
 
 
-(defun isearch-mode (forward &optional regexp op-fun recursive-edit word-p)
+(defun isearch-mode (forward &optional regexp op-fun recursive-edit word)
   "Start Isearch minor mode.
 It is called by the function `isearch-forward' and other related functions."
 
   ;; Initialize global vars.
   (setq isearch-forward forward
        isearch-regexp regexp
-       isearch-word word-p
+       isearch-word word
        isearch-op-fun op-fun
        isearch-last-case-fold-search isearch-case-fold-search
        isearch-case-fold-search case-fold-search
@@ -1534,6 +1542,8 @@
   (interactive
    (let* ((perform-collect (consp current-prefix-arg))
          (regexp (cond
+                  ((functionp isearch-word)
+                   (funcall isearch-word isearch-string))
                   (isearch-word (word-search-regexp isearch-string))
                   (isearch-regexp isearch-string)
                   (t (regexp-quote isearch-string)))))
@@ -1749,6 +1759,8 @@
                       (setq case-fold-search
                             (isearch-no-upper-case-p isearch-string 
isearch-regexp)))
                   (looking-at (cond
+                               ((functionp isearch-word)
+                                (funcall isearch-word isearch-string t))
                                (isearch-word (word-search-regexp 
isearch-string t))
                                (isearch-regexp isearch-string)
                                (t (regexp-quote isearch-string)))))
@@ -2329,7 +2341,11 @@
                              (< (point) isearch-opoint)))
                       "over")
                   (if isearch-wrapped "wrapped ")
-                  (if isearch-word "word " "")
+                  (if isearch-word
+                      (or (and (symbolp isearch-word)
+                               (get isearch-word 'isearch-message-prefix))
+                          "word ")
+                    "")
                   (if isearch-regexp "regexp " "")
                   (if multi-isearch-next-buffer-current-function "multi " "")
                   (or isearch-message-prefix-add "")
@@ -2374,14 +2390,19 @@
   "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)))
+    (lambda (string &optional bound noerror count)
+      ;; 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)
+      (let ((lax (not (or isearch-nonincremental
+                         (eq (length isearch-string)
+                             (length (isearch-string-state (car 
isearch-cmds))))))))
+       (funcall
+        (if isearch-forward #'re-search-forward #'re-search-backward)
+        (if (functionp isearch-word)
+            (funcall isearch-word string lax)
+          (word-search-regexp string lax))
+        bound noerror count))))
    (isearch-regexp
     (if isearch-forward 're-search-forward 're-search-backward))
    (t


reply via email to

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