Mercurial > emacs
comparison lisp/isearch.el @ 92882:05fd686fa0f7
(isearch-edit-string): Remove one call to
`isearch-push-state' not to push an inconsistent state,
but keep another correct call to `isearch-push-state'.
(isearch-ring-adjust): Call `isearch-push-state' only when
`search-ring-update' is non-nil since `isearch-edit-string'
already pushes its state.
(isearch-message): Improve matching the failed part by checking
if the original message starts with the last successful message.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Fri, 14 Mar 2008 01:01:59 +0000 |
parents | d38d15e5ee31 |
children | 5af8822703da |
comparison
equal
deleted
inserted
replaced
92881:d6c8f902278a | 92882:05fd686fa0f7 |
---|---|
1094 ;; This used to set the last search string, | 1094 ;; This used to set the last search string, |
1095 ;; but I think it is not right to do that here. | 1095 ;; but I think it is not right to do that here. |
1096 ;; Only the string actually used should be saved. | 1096 ;; Only the string actually used should be saved. |
1097 )) | 1097 )) |
1098 | 1098 |
1099 ;; Push the state as of before this C-s. | 1099 ;; This used to push the state as of before this C-s, but it adds |
1100 (isearch-push-state) | 1100 ;; an inconsistent state where part of variables are from the |
1101 ;; previous search (e.g. `isearch-success'), and part of variables | |
1102 ;; are just entered from the minibuffer (e.g. `isearch-string'). | |
1103 ;; (isearch-push-state) | |
1101 | 1104 |
1102 ;; Reinvoke the pending search. | 1105 ;; Reinvoke the pending search. |
1103 (isearch-search) | 1106 (isearch-search) |
1104 (isearch-push-state) | 1107 (isearch-push-state) ; this pushes the correct state |
1105 (isearch-update) | 1108 (isearch-update) |
1106 (if isearch-nonincremental | 1109 (if isearch-nonincremental |
1107 (progn | 1110 (progn |
1108 ;; (sit-for 1) ;; needed if isearch-done does: (message "") | 1111 ;; (sit-for 1) ;; needed if isearch-done does: (message "") |
1109 (isearch-done) | 1112 (isearch-done) |
1893 ;; Helper for isearch-ring-advance and isearch-ring-retreat | 1896 ;; Helper for isearch-ring-advance and isearch-ring-retreat |
1894 (isearch-ring-adjust1 advance) | 1897 (isearch-ring-adjust1 advance) |
1895 (if search-ring-update | 1898 (if search-ring-update |
1896 (progn | 1899 (progn |
1897 (isearch-search) | 1900 (isearch-search) |
1901 (isearch-push-state) | |
1898 (isearch-update)) | 1902 (isearch-update)) |
1899 (isearch-edit-string) | 1903 ;; Otherwise, edit the search string instead. Note that there is |
1900 ) | 1904 ;; no need to push the search state after isearch-edit-string here |
1901 (isearch-push-state)) | 1905 ;; since isearch-edit-string already pushes its state |
1906 (isearch-edit-string))) | |
1902 | 1907 |
1903 (defun isearch-ring-advance () | 1908 (defun isearch-ring-advance () |
1904 "Advance to the next search string in the ring." | 1909 "Advance to the next search string in the ring." |
1905 ;; This could be more general to handle a prefix arg, but who would use it. | 1910 ;; This could be more general to handle a prefix arg, but who would use it. |
1906 (interactive) | 1911 (interactive) |
1973 (while (or (not (isearch-success-state (car cmds))) | 1978 (while (or (not (isearch-success-state (car cmds))) |
1974 (isearch-error-state (car cmds))) | 1979 (isearch-error-state (car cmds))) |
1975 (pop cmds)) | 1980 (pop cmds)) |
1976 (setq succ-msg (and cmds (isearch-message-state (car cmds))) | 1981 (setq succ-msg (and cmds (isearch-message-state (car cmds))) |
1977 m (copy-sequence m)) | 1982 m (copy-sequence m)) |
1978 (when (and (stringp succ-msg) (< (length succ-msg) (length m))) | 1983 (add-text-properties |
1979 (add-text-properties (length succ-msg) (length m) | 1984 (if (and (stringp succ-msg) |
1980 '(face isearch-fail) m)) | 1985 (< (length succ-msg) (length m)) |
1986 (equal succ-msg (substring m 0 (length succ-msg)))) | |
1987 (length succ-msg) | |
1988 0) | |
1989 (length m) '(face isearch-fail) m) | |
1981 ;; Highlight failed trailing whitespace | 1990 ;; Highlight failed trailing whitespace |
1982 (when (string-match " +$" m) | 1991 (when (string-match " +$" m) |
1983 (add-text-properties (match-beginning 0) (match-end 0) | 1992 (add-text-properties (match-beginning 0) (match-end 0) |
1984 '(face trailing-whitespace) m))) | 1993 '(face trailing-whitespace) m))) |
1985 (setq m (concat | 1994 (setq m (concat |