aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-08-26 11:57:55 +0800
committerChong Yidong2012-08-26 11:57:55 +0800
commitdd7ffad60f9e52590f4e6e352e8f861c6a5d13f0 (patch)
tree1d444e8646a592c524a3f50e108da7130fedeb4f
parente1f29348711cb668969139126b59a2a3b8881987 (diff)
downloademacs-dd7ffad60f9e52590f4e6e352e8f861c6a5d13f0.tar.gz
emacs-dd7ffad60f9e52590f4e6e352e8f861c6a5d13f0.zip
Make ordinary isearch obey search-whitespace-regexp too.
* lisp/isearch.el (search-whitespace-regexp): Make string and nil values apply to both ordinary and regexp search. Allow a cons cell value to distinguish between the two. (isearch-whitespace-regexp, isearch-search-forward) (isearch-search-backward): New functions. (isearch-occur, isearch-search-fun-default, isearch-search) (isearch-lazy-highlight-new-loop): Use them. (isearch-forward, isearch-forward-regexp): Doc fix.
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/isearch.el83
3 files changed, 73 insertions, 28 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 0c9ffe50093..02bd6410255 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -179,6 +179,13 @@ end of the buffer. It defaults to t.
179and `M-s _' in Isearch toggles symbol search mode. 179and `M-s _' in Isearch toggles symbol search mode.
180`M-s c' in Isearch toggles search case-sensitivity. 180`M-s c' in Isearch toggles search case-sensitivity.
181 181
182*** `search-whitespace-regexp' now acts on ordinary incremental search
183as well, so that each sequence of spaces in the search string matches
184any combination of one or more whitespace characters. To change this
185behavior, you can give `search-whitespace-regexp' a cons cell value,
186where the car and cdr specify values for ordinary and regular
187expression incremental search respectively.
188
182** M-x move-to-column, if called interactively with no prefix arg, now 189** M-x move-to-column, if called interactively with no prefix arg, now
183prompts for a column number. 190prompts for a column number.
184 191
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7b789ad64ed..2cc41c92210 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,16 @@
12012-08-26 Chong Yidong <cyd@gnu.org> 12012-08-26 Chong Yidong <cyd@gnu.org>
2 2
3 * isearch.el (search-whitespace-regexp): Make string and nil
4 values apply to both ordinary and regexp search. Allow a cons
5 cell value to distinguish between the two.
6 (isearch-whitespace-regexp, isearch-search-forward)
7 (isearch-search-backward): New functions.
8 (isearch-occur, isearch-search-fun-default, isearch-search)
9 (isearch-lazy-highlight-new-loop): Use them.
10 (isearch-forward, isearch-forward-regexp): Doc fix.
11
122012-08-26 Chong Yidong <cyd@gnu.org>
13
3 * faces.el (help-argument-name): Always inherit from italic 14 * faces.el (help-argument-name): Always inherit from italic
4 (Bug#12213). 15 (Bug#12213).
5 16
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 9271ce32484..27d35045ade 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -111,17 +111,32 @@ string, and RET terminates editing and does a nonincremental search."
111 111
112(defcustom search-whitespace-regexp (purecopy "\\s-+") 112(defcustom search-whitespace-regexp (purecopy "\\s-+")
113 "If non-nil, regular expression to match a sequence of whitespace chars. 113 "If non-nil, regular expression to match a sequence of whitespace chars.
114This applies to regular expression incremental search. 114When you enter a space or spaces in the incremental search, it
115When you put a space or spaces in the incremental regexp, it stands for 115will match any sequence matched by this regexp. As an exception,
116this, unless it is inside of a regexp construct such as [...] or *, + or ?. 116spaces are treated normally in regexp incremental search if they
117occur in a regexp construct like [...] or *, + or ?.
118
119If the value is a string, it applies to both ordinary and regexp
120incremental search. If the value is nil, each space you type
121matches literally, against one space.
122
123The value can also be a cons cell (REGEXP-1 . REGEXP-2). In that
124case, REGEXP-1 is used as the value for ordinary incremental
125search, and REGEXP-2 is used for regexp incremental search.
126
117You might want to use something like \"[ \\t\\r\\n]+\" instead. 127You might want to use something like \"[ \\t\\r\\n]+\" instead.
118In the Customization buffer, that is `[' followed by a space, 128In the Customization buffer, that is `[' followed by a space,
119a tab, a carriage return (control-M), a newline, and `]+'. 129a tab, a carriage return (control-M), a newline, and `]+'."
120 130 :type '(choice (const :tag "Treat Spaces Literally" nil)
121When this is nil, each space you type matches literally, against one space." 131 (cons (choice :tag "For Ordinary Isearch"
122 :type '(choice (const :tag "Find Spaces Literally" nil) 132 regexp
133 (const :tag "Treat Spaces Literally" nil))
134 (choice :tag "For Regexp Isearch"
135 regexp
136 (const :tag "Treat Spaces Literally" nil)))
123 regexp) 137 regexp)
124 :group 'isearch) 138 :group 'isearch
139 :version "24.3")
125 140
126(defcustom search-invisible 'open 141(defcustom search-invisible 'open
127 "If t incremental search can match hidden text. 142 "If t incremental search can match hidden text.
@@ -687,6 +702,10 @@ Type \\[isearch-describe-bindings] to display all Isearch key bindings.
687Type \\[isearch-describe-key] to display documentation of Isearch key. 702Type \\[isearch-describe-key] to display documentation of Isearch key.
688Type \\[isearch-describe-mode] to display documentation of Isearch mode. 703Type \\[isearch-describe-mode] to display documentation of Isearch mode.
689 704
705In incremental searches, a space or spaces normally matches any
706whitespace; see the variable `search-whitespace-regexp'. To
707search for a literal space and nothing else, enter C-q SPC.
708
690If an input method is turned on in the current buffer, that input 709If an input method is turned on in the current buffer, that input
691method is also active while you are typing characters to search. 710method is also active while you are typing characters to search.
692To toggle the input method, type \\[isearch-toggle-input-method]. \ 711To toggle the input method, type \\[isearch-toggle-input-method]. \
@@ -710,22 +729,19 @@ the calling function until the search is done."
710 (isearch-mode t (not (null regexp-p)) nil (not no-recursive-edit))) 729 (isearch-mode t (not (null regexp-p)) nil (not no-recursive-edit)))
711 730
712(defun isearch-forward-regexp (&optional not-regexp no-recursive-edit) 731(defun isearch-forward-regexp (&optional not-regexp no-recursive-edit)
713 "\ 732 "Do incremental search forward for regular expression.
714Do incremental search forward for regular expression.
715With a prefix argument, do a regular string search instead. 733With a prefix argument, do a regular string search instead.
716Like ordinary incremental search except that your input is treated 734Like ordinary incremental search except that your input is treated
717as a regexp. See the command `isearch-forward' for more information. 735as a regexp. See the command `isearch-forward' for more information.
718 736
719In regexp incremental searches, a space or spaces normally matches 737In incremental searches, a space or spaces normally matches any
720any whitespace (the variable `search-whitespace-regexp' controls 738whitespace; see the variable `search-whitespace-regexp'. To
721precisely what that means). If you want to search for a literal space 739search for a literal space and nothing else, enter C-q SPC."
722and nothing else, enter C-q SPC."
723 (interactive "P\np") 740 (interactive "P\np")
724 (isearch-mode t (null not-regexp) nil (not no-recursive-edit))) 741 (isearch-mode t (null not-regexp) nil (not no-recursive-edit)))
725 742
726(defun isearch-forward-word (&optional not-word no-recursive-edit) 743(defun isearch-forward-word (&optional not-word no-recursive-edit)
727 "\ 744 "Do incremental search forward for a sequence of words.
728Do incremental search forward for a sequence of words.
729With a prefix argument, do a regular string search instead. 745With a prefix argument, do a regular string search instead.
730Like ordinary incremental search except that your input is treated 746Like ordinary incremental search except that your input is treated
731as a sequence of words without regard to how the words are separated. 747as a sequence of words without regard to how the words are separated.
@@ -734,8 +750,7 @@ See the command `isearch-forward' for more information."
734 (isearch-mode t nil nil (not no-recursive-edit) (null not-word))) 750 (isearch-mode t nil nil (not no-recursive-edit) (null not-word)))
735 751
736(defun isearch-forward-symbol (&optional not-symbol no-recursive-edit) 752(defun isearch-forward-symbol (&optional not-symbol no-recursive-edit)
737 "\ 753 "Do incremental search forward for a symbol.
738Do incremental search forward for a symbol.
739The prefix argument is currently unused. 754The prefix argument is currently unused.
740Like ordinary incremental search except that your input is treated 755Like ordinary incremental search except that your input is treated
741as a symbol surrounded by symbol boundary constructs \\_< and \\_>. 756as a symbol surrounded by symbol boundary constructs \\_< and \\_>.
@@ -744,16 +759,14 @@ See the command `isearch-forward' for more information."
744 (isearch-mode t nil nil (not no-recursive-edit) 'isearch-symbol-regexp)) 759 (isearch-mode t nil nil (not no-recursive-edit) 'isearch-symbol-regexp))
745 760
746(defun isearch-backward (&optional regexp-p no-recursive-edit) 761(defun isearch-backward (&optional regexp-p no-recursive-edit)
747 "\ 762 "Do incremental search backward.
748Do incremental search backward.
749With a prefix argument, do a regular expression search instead. 763With a prefix argument, do a regular expression search instead.
750See the command `isearch-forward' for more information." 764See the command `isearch-forward' for more information."
751 (interactive "P\np") 765 (interactive "P\np")
752 (isearch-mode nil (not (null regexp-p)) nil (not no-recursive-edit))) 766 (isearch-mode nil (not (null regexp-p)) nil (not no-recursive-edit)))
753 767
754(defun isearch-backward-regexp (&optional not-regexp no-recursive-edit) 768(defun isearch-backward-regexp (&optional not-regexp no-recursive-edit)
755 "\ 769 "Do incremental search backward for regular expression.
756Do incremental search backward for regular expression.
757With a prefix argument, do a regular string search instead. 770With a prefix argument, do a regular string search instead.
758Like ordinary incremental search except that your input is treated 771Like ordinary incremental search except that your input is treated
759as a regexp. See the command `isearch-forward' for more information." 772as a regexp. See the command `isearch-forward' for more information."
@@ -895,8 +908,7 @@ The last thing it does is to run `isearch-update-post-hook'."
895 (if (< isearch-other-end (point)) ; isearch-forward? 908 (if (< isearch-other-end (point)) ; isearch-forward?
896 (isearch-highlight isearch-other-end (point)) 909 (isearch-highlight isearch-other-end (point))
897 (isearch-highlight (point) isearch-other-end)) 910 (isearch-highlight (point) isearch-other-end))
898 (isearch-dehighlight)) 911 (isearch-dehighlight))))
899 ))
900 (setq ;; quit-flag nil not for isearch-mode 912 (setq ;; quit-flag nil not for isearch-mode
901 isearch-adjusted nil 913 isearch-adjusted nil
902 isearch-yank-flag nil) 914 isearch-yank-flag nil)
@@ -1547,6 +1559,15 @@ See `isearch-query-replace' for more information."
1547 (list current-prefix-arg)) 1559 (list current-prefix-arg))
1548 (isearch-query-replace delimited t)) 1560 (isearch-query-replace delimited t))
1549 1561
1562(defun isearch-whitespace-regexp ()
1563 "Return the value of `search-whitespace-regexp' for the current search."
1564 (cond ((not (consp search-whitespace-regexp))
1565 search-whitespace-regexp)
1566 (isearch-regexp
1567 (cdr search-whitespace-regexp))
1568 (t
1569 (car search-whitespace-regexp))))
1570
1550(defun isearch-occur (regexp &optional nlines) 1571(defun isearch-occur (regexp &optional nlines)
1551 "Run `occur' using the last search string as the regexp. 1572 "Run `occur' using the last search string as the regexp.
1552Interactively, REGEXP is constructed using the search string from the 1573Interactively, REGEXP is constructed using the search string from the
@@ -1586,7 +1607,7 @@ characters in that string."
1586 ;; Set `search-upper-case' to nil to not call 1607 ;; Set `search-upper-case' to nil to not call
1587 ;; `isearch-no-upper-case-p' in `occur-1'. 1608 ;; `isearch-no-upper-case-p' in `occur-1'.
1588 (search-upper-case nil) 1609 (search-upper-case nil)
1589 (search-spaces-regexp (if isearch-regexp search-whitespace-regexp))) 1610 (search-spaces-regexp (isearch-whitespace-regexp)))
1590 (occur regexp nlines))) 1611 (occur regexp nlines)))
1591 1612
1592(declare-function hi-lock-read-face-name "hi-lock" ()) 1613(declare-function hi-lock-read-face-name "hi-lock" ())
@@ -2426,7 +2447,13 @@ Can be changed via `isearch-search-fun-function' for special needs."
2426 (isearch-regexp 2447 (isearch-regexp
2427 (if isearch-forward 're-search-forward 're-search-backward)) 2448 (if isearch-forward 're-search-forward 're-search-backward))
2428 (t 2449 (t
2429 (if isearch-forward 'search-forward 'search-backward)))) 2450 (if isearch-forward 'isearch-search-forward 'isearch-search-backward))))
2451
2452(defun isearch-search-forward (string &optional bound noerror count)
2453 (re-search-forward (regexp-quote string) bound noerror count))
2454
2455(defun isearch-search-backward (string &optional bound noerror count)
2456 (re-search-backward (regexp-quote string) bound noerror count))
2430 2457
2431(defun isearch-search-string (string bound noerror) 2458(defun isearch-search-string (string bound noerror)
2432 "Search for the first occurrence of STRING or its translation. 2459 "Search for the first occurrence of STRING or its translation.
@@ -2487,7 +2514,7 @@ update the match data, and return point."
2487 search-invisible)) 2514 search-invisible))
2488 (inhibit-quit nil) 2515 (inhibit-quit nil)
2489 (case-fold-search isearch-case-fold-search) 2516 (case-fold-search isearch-case-fold-search)
2490 (search-spaces-regexp search-whitespace-regexp) 2517 (search-spaces-regexp (isearch-whitespace-regexp))
2491 (retry t)) 2518 (retry t))
2492 (setq isearch-error nil) 2519 (setq isearch-error nil)
2493 (while retry 2520 (while retry
@@ -2847,7 +2874,7 @@ by other Emacs features."
2847 isearch-lazy-highlight-last-string isearch-string 2874 isearch-lazy-highlight-last-string isearch-string
2848 isearch-lazy-highlight-case-fold-search isearch-case-fold-search 2875 isearch-lazy-highlight-case-fold-search isearch-case-fold-search
2849 isearch-lazy-highlight-regexp isearch-regexp 2876 isearch-lazy-highlight-regexp isearch-regexp
2850 isearch-lazy-highlight-space-regexp search-whitespace-regexp 2877 isearch-lazy-highlight-space-regexp (isearch-whitespace-regexp)
2851 isearch-lazy-highlight-word isearch-word 2878 isearch-lazy-highlight-word isearch-word
2852 isearch-lazy-highlight-forward isearch-forward) 2879 isearch-lazy-highlight-forward isearch-forward)
2853 (unless (equal isearch-string "") 2880 (unless (equal isearch-string "")