diff options
| author | Chong Yidong | 2012-08-26 11:57:55 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-08-26 11:57:55 +0800 |
| commit | dd7ffad60f9e52590f4e6e352e8f861c6a5d13f0 (patch) | |
| tree | 1d444e8646a592c524a3f50e108da7130fedeb4f | |
| parent | e1f29348711cb668969139126b59a2a3b8881987 (diff) | |
| download | emacs-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/NEWS | 7 | ||||
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/isearch.el | 83 |
3 files changed, 73 insertions, 28 deletions
| @@ -179,6 +179,13 @@ end of the buffer. It defaults to t. | |||
| 179 | and `M-s _' in Isearch toggles symbol search mode. | 179 | and `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 | ||
| 183 | as well, so that each sequence of spaces in the search string matches | ||
| 184 | any combination of one or more whitespace characters. To change this | ||
| 185 | behavior, you can give `search-whitespace-regexp' a cons cell value, | ||
| 186 | where the car and cdr specify values for ordinary and regular | ||
| 187 | expression 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 |
| 183 | prompts for a column number. | 190 | prompts 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 @@ | |||
| 1 | 2012-08-26 Chong Yidong <cyd@gnu.org> | 1 | 2012-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 | |||
| 12 | 2012-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. |
| 114 | This applies to regular expression incremental search. | 114 | When you enter a space or spaces in the incremental search, it |
| 115 | When you put a space or spaces in the incremental regexp, it stands for | 115 | will match any sequence matched by this regexp. As an exception, |
| 116 | this, unless it is inside of a regexp construct such as [...] or *, + or ?. | 116 | spaces are treated normally in regexp incremental search if they |
| 117 | occur in a regexp construct like [...] or *, + or ?. | ||
| 118 | |||
| 119 | If the value is a string, it applies to both ordinary and regexp | ||
| 120 | incremental search. If the value is nil, each space you type | ||
| 121 | matches literally, against one space. | ||
| 122 | |||
| 123 | The value can also be a cons cell (REGEXP-1 . REGEXP-2). In that | ||
| 124 | case, REGEXP-1 is used as the value for ordinary incremental | ||
| 125 | search, and REGEXP-2 is used for regexp incremental search. | ||
| 126 | |||
| 117 | You might want to use something like \"[ \\t\\r\\n]+\" instead. | 127 | You might want to use something like \"[ \\t\\r\\n]+\" instead. |
| 118 | In the Customization buffer, that is `[' followed by a space, | 128 | In the Customization buffer, that is `[' followed by a space, |
| 119 | a tab, a carriage return (control-M), a newline, and `]+'. | 129 | a tab, a carriage return (control-M), a newline, and `]+'." |
| 120 | 130 | :type '(choice (const :tag "Treat Spaces Literally" nil) | |
| 121 | When 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. | |||
| 687 | Type \\[isearch-describe-key] to display documentation of Isearch key. | 702 | Type \\[isearch-describe-key] to display documentation of Isearch key. |
| 688 | Type \\[isearch-describe-mode] to display documentation of Isearch mode. | 703 | Type \\[isearch-describe-mode] to display documentation of Isearch mode. |
| 689 | 704 | ||
| 705 | In incremental searches, a space or spaces normally matches any | ||
| 706 | whitespace; see the variable `search-whitespace-regexp'. To | ||
| 707 | search for a literal space and nothing else, enter C-q SPC. | ||
| 708 | |||
| 690 | If an input method is turned on in the current buffer, that input | 709 | If an input method is turned on in the current buffer, that input |
| 691 | method is also active while you are typing characters to search. | 710 | method is also active while you are typing characters to search. |
| 692 | To toggle the input method, type \\[isearch-toggle-input-method]. \ | 711 | To 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. |
| 714 | Do incremental search forward for regular expression. | ||
| 715 | With a prefix argument, do a regular string search instead. | 733 | With a prefix argument, do a regular string search instead. |
| 716 | Like ordinary incremental search except that your input is treated | 734 | Like ordinary incremental search except that your input is treated |
| 717 | as a regexp. See the command `isearch-forward' for more information. | 735 | as a regexp. See the command `isearch-forward' for more information. |
| 718 | 736 | ||
| 719 | In regexp incremental searches, a space or spaces normally matches | 737 | In incremental searches, a space or spaces normally matches any |
| 720 | any whitespace (the variable `search-whitespace-regexp' controls | 738 | whitespace; see the variable `search-whitespace-regexp'. To |
| 721 | precisely what that means). If you want to search for a literal space | 739 | search for a literal space and nothing else, enter C-q SPC." |
| 722 | and 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. |
| 728 | Do incremental search forward for a sequence of words. | ||
| 729 | With a prefix argument, do a regular string search instead. | 745 | With a prefix argument, do a regular string search instead. |
| 730 | Like ordinary incremental search except that your input is treated | 746 | Like ordinary incremental search except that your input is treated |
| 731 | as a sequence of words without regard to how the words are separated. | 747 | as 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. |
| 738 | Do incremental search forward for a symbol. | ||
| 739 | The prefix argument is currently unused. | 754 | The prefix argument is currently unused. |
| 740 | Like ordinary incremental search except that your input is treated | 755 | Like ordinary incremental search except that your input is treated |
| 741 | as a symbol surrounded by symbol boundary constructs \\_< and \\_>. | 756 | as 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. |
| 748 | Do incremental search backward. | ||
| 749 | With a prefix argument, do a regular expression search instead. | 763 | With a prefix argument, do a regular expression search instead. |
| 750 | See the command `isearch-forward' for more information." | 764 | See 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. |
| 756 | Do incremental search backward for regular expression. | ||
| 757 | With a prefix argument, do a regular string search instead. | 770 | With a prefix argument, do a regular string search instead. |
| 758 | Like ordinary incremental search except that your input is treated | 771 | Like ordinary incremental search except that your input is treated |
| 759 | as a regexp. See the command `isearch-forward' for more information." | 772 | as 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. |
| 1552 | Interactively, REGEXP is constructed using the search string from the | 1573 | Interactively, 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 "") |