aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2012-05-29 12:27:39 +0300
committerJuri Linkov2012-05-29 12:27:39 +0300
commitd5e61c1c754a725dea0d7b949e705ce4a98789af (patch)
tree3b718ed43f7198a3f023746826bd9323fa3997fb
parent8cbd80f7138bcf61518ecaab76d1b762b2510c21 (diff)
downloademacs-d5e61c1c754a725dea0d7b949e705ce4a98789af.tar.gz
emacs-d5e61c1c754a725dea0d7b949e705ce4a98789af.zip
* 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'. Fixes: debbugs:11381
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/isearch.el47
2 files changed, 46 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c155b0a27c0..ae410d54075 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,17 @@
12012-05-29 Juri Linkov <juri@jurta.org> 12012-05-29 Juri Linkov <juri@jurta.org>
2 2
3 * isearch.el (isearch-word): Add docstring. (Bug#11381)
4 (isearch-occur, isearch-search-and-update): If `isearch-word' is
5 a function, call it to get the regexp.
6 (isearch-message-prefix): If `isearch-word' holds a symbol, use its
7 property `isearch-message-prefix' instead of the string "word ".
8 (isearch-search-fun-default): For the case of `isearch-word',
9 return a lambda that calls re-search-forward/re-search-backward
10 with a regexp returned by `word-search-regexp' or by the function
11 in `isearch-word'.
12
132012-05-29 Juri Linkov <juri@jurta.org>
14
3 * isearch.el (isearch-search-fun-default): New function. 15 * isearch.el (isearch-search-fun-default): New function.
4 (isearch-search-fun): Move default part to the new function 16 (isearch-search-fun): Move default part to the new function
5 `isearch-search-fun-default'. 17 `isearch-search-fun-default'.
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 2fcd2d53251..8564a390314 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -530,8 +530,13 @@ This is like `describe-bindings', but displays only Isearch keys."
530 530
531(defvar isearch-forward nil) ; Searching in the forward direction. 531(defvar isearch-forward nil) ; Searching in the forward direction.
532(defvar isearch-regexp nil) ; Searching for a regexp. 532(defvar isearch-regexp nil) ; Searching for a regexp.
533(defvar isearch-word nil) ; Searching for words. 533(defvar isearch-word nil
534(defvar isearch-hidden nil) ; Non-nil if the string exists but is invisible. 534 "Regexp-based search mode for words.
535If t, do incremental search for a sequence of words, ignoring punctuation.
536If the value is a function, it is called to convert the search string
537to a regexp used by regexp search functions. The property
538`isearch-message-prefix' put on this function specifies the
539prefix string displyed in the search message.")
535 540
536(defvar isearch-cmds nil 541(defvar isearch-cmds nil
537 "Stack of search status sets. 542 "Stack of search status sets.
@@ -592,6 +597,9 @@ Each set is a vector of the form:
592;; Accumulate here the overlays opened during searching. 597;; Accumulate here the overlays opened during searching.
593(defvar isearch-opened-overlays nil) 598(defvar isearch-opened-overlays nil)
594 599
600;; Non-nil if the string exists but is invisible.
601(defvar isearch-hidden nil)
602
595;; The value of input-method-function when isearch is invoked. 603;; The value of input-method-function when isearch is invoked.
596(defvar isearch-input-method-function nil) 604(defvar isearch-input-method-function nil)
597 605
@@ -747,14 +755,14 @@ as a regexp. See the command `isearch-forward' for more information."
747;; "List of commands for which isearch-mode does not recursive-edit.") 755;; "List of commands for which isearch-mode does not recursive-edit.")
748 756
749 757
750(defun isearch-mode (forward &optional regexp op-fun recursive-edit word-p) 758(defun isearch-mode (forward &optional regexp op-fun recursive-edit word)
751 "Start Isearch minor mode. 759 "Start Isearch minor mode.
752It is called by the function `isearch-forward' and other related functions." 760It is called by the function `isearch-forward' and other related functions."
753 761
754 ;; Initialize global vars. 762 ;; Initialize global vars.
755 (setq isearch-forward forward 763 (setq isearch-forward forward
756 isearch-regexp regexp 764 isearch-regexp regexp
757 isearch-word word-p 765 isearch-word word
758 isearch-op-fun op-fun 766 isearch-op-fun op-fun
759 isearch-last-case-fold-search isearch-case-fold-search 767 isearch-last-case-fold-search isearch-case-fold-search
760 isearch-case-fold-search case-fold-search 768 isearch-case-fold-search case-fold-search
@@ -1534,6 +1542,8 @@ characters in that string."
1534 (interactive 1542 (interactive
1535 (let* ((perform-collect (consp current-prefix-arg)) 1543 (let* ((perform-collect (consp current-prefix-arg))
1536 (regexp (cond 1544 (regexp (cond
1545 ((functionp isearch-word)
1546 (funcall isearch-word isearch-string))
1537 (isearch-word (word-search-regexp isearch-string)) 1547 (isearch-word (word-search-regexp isearch-string))
1538 (isearch-regexp isearch-string) 1548 (isearch-regexp isearch-string)
1539 (t (regexp-quote isearch-string))))) 1549 (t (regexp-quote isearch-string)))))
@@ -1749,6 +1759,8 @@ Subword is used when `subword-mode' is activated. "
1749 (setq case-fold-search 1759 (setq case-fold-search
1750 (isearch-no-upper-case-p isearch-string isearch-regexp))) 1760 (isearch-no-upper-case-p isearch-string isearch-regexp)))
1751 (looking-at (cond 1761 (looking-at (cond
1762 ((functionp isearch-word)
1763 (funcall isearch-word isearch-string t))
1752 (isearch-word (word-search-regexp isearch-string t)) 1764 (isearch-word (word-search-regexp isearch-string t))
1753 (isearch-regexp isearch-string) 1765 (isearch-regexp isearch-string)
1754 (t (regexp-quote isearch-string))))) 1766 (t (regexp-quote isearch-string)))))
@@ -2329,7 +2341,11 @@ If there is no completion possible, say so and continue searching."
2329 (< (point) isearch-opoint))) 2341 (< (point) isearch-opoint)))
2330 "over") 2342 "over")
2331 (if isearch-wrapped "wrapped ") 2343 (if isearch-wrapped "wrapped ")
2332 (if isearch-word "word " "") 2344 (if isearch-word
2345 (or (and (symbolp isearch-word)
2346 (get isearch-word 'isearch-message-prefix))
2347 "word ")
2348 "")
2333 (if isearch-regexp "regexp " "") 2349 (if isearch-regexp "regexp " "")
2334 (if multi-isearch-next-buffer-current-function "multi " "") 2350 (if multi-isearch-next-buffer-current-function "multi " "")
2335 (or isearch-message-prefix-add "") 2351 (or isearch-message-prefix-add "")
@@ -2374,14 +2390,19 @@ Can be changed via `isearch-search-fun-function' for special needs."
2374 "Return default functions to use for the search." 2390 "Return default functions to use for the search."
2375 (cond 2391 (cond
2376 (isearch-word 2392 (isearch-word
2377 ;; Use lax versions to not fail at the end of the word while 2393 (lambda (string &optional bound noerror count)
2378 ;; the user adds and removes characters in the search string 2394 ;; Use lax versions to not fail at the end of the word while
2379 ;; (or when using nonincremental word isearch) 2395 ;; the user adds and removes characters in the search string
2380 (if (or isearch-nonincremental 2396 ;; (or when using nonincremental word isearch)
2381 (eq (length isearch-string) 2397 (let ((lax (not (or isearch-nonincremental
2382 (length (isearch-string-state (car isearch-cmds))))) 2398 (eq (length isearch-string)
2383 (if isearch-forward 'word-search-forward 'word-search-backward) 2399 (length (isearch-string-state (car isearch-cmds))))))))
2384 (if isearch-forward 'word-search-forward-lax 'word-search-backward-lax))) 2400 (funcall
2401 (if isearch-forward #'re-search-forward #'re-search-backward)
2402 (if (functionp isearch-word)
2403 (funcall isearch-word string lax)
2404 (word-search-regexp string lax))
2405 bound noerror count))))
2385 (isearch-regexp 2406 (isearch-regexp
2386 (if isearch-forward 're-search-forward 're-search-backward)) 2407 (if isearch-forward 're-search-forward 're-search-backward))
2387 (t 2408 (t