diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-10-28 12:01:39 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-10-28 15:10:08 +0000 |
commit | faace42f8a4c8f53f629419ba89a5196d62ee006 (patch) | |
tree | 4b71336244c09c209f7fbb5474f9ca7124bab236 /lisp | |
parent | 12c0edb7555613aecfd27610601f137be252b804 (diff) | |
download | emacs-faace42f8a4c8f53f629419ba89a5196d62ee006.tar.gz emacs-faace42f8a4c8f53f629419ba89a5196d62ee006.tar.bz2 emacs-faace42f8a4c8f53f629419ba89a5196d62ee006.zip |
* lisp/isearch.el: Refactor momentary messages
(isearch--momentary-message): New function.
(isearch-toggle-lax-whitespace, isearch-toggle-case-fold)
(isearch-toggle-invisible): Use it.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/isearch.el | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 1c545de3e20..915255b2227 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1532,48 +1532,46 @@ The command then executes BODY and updates the isearch prompt." (setq isearch-regexp (not isearch-regexp)) (if isearch-regexp (setq isearch-regexp-function nil))) +(defun isearch--momentary-message (string) + "Print STRING at the end of the isearch prompt for 1 second" + (let ((message-log-max nil)) + (message "%s%s [%s]" + (isearch-message-prefix nil isearch-nonincremental) + isearch-message + string)) + (sit-for 1)) + (isearch-define-mode-toggle lax-whitespace " " nil "In ordinary search, toggles the value of the variable `isearch-lax-whitespace'. In regexp search, toggles the value of the variable `isearch-regexp-lax-whitespace'." - (if isearch-regexp - (setq isearch-regexp-lax-whitespace (not isearch-regexp-lax-whitespace)) - (setq isearch-lax-whitespace (not isearch-lax-whitespace))) - (let ((message-log-max nil)) - (message "%s%s [%s]" - (isearch-message-prefix nil isearch-nonincremental) - isearch-message - (if (if isearch-regexp - isearch-regexp-lax-whitespace - isearch-lax-whitespace) - "match spaces loosely" - "match spaces literally"))) - (sit-for 1)) + (isearch--momentary-message + (if (if isearch-regexp + (setq isearch-regexp-lax-whitespace (not isearch-regexp-lax-whitespace)) + (setq isearch-lax-whitespace (not isearch-lax-whitespace))) + "match spaces loosely" + "match spaces literally"))) (isearch-define-mode-toggle case-fold "c" nil "Toggles the value of the variable `isearch-case-fold-search'." - (setq isearch-case-fold-search - (if isearch-case-fold-search nil 'yes)) - (let ((message-log-max nil)) - (message "%s%s [case %ssensitive]" - (isearch-message-prefix nil isearch-nonincremental) - isearch-message - (if isearch-case-fold-search "in" ""))) - (sit-for 1)) + (isearch--momentary-message + (if (setq isearch-case-fold-search + (if isearch-case-fold-search nil 'yes)) + "case insensitive" + "case sensitive"))) (isearch-define-mode-toggle invisible "i" nil "This determines whether to search inside invisible text or not. Toggles the variable `isearch-invisible' between values nil and a non-nil value of the option `search-invisible' \(or `open' if `search-invisible' is nil)." - (setq isearch-invisible - (if isearch-invisible nil (or search-invisible 'open))) - (let ((message-log-max nil)) - (message "%s%s [match %svisible text]" - (isearch-message-prefix nil isearch-nonincremental) - isearch-message - (if isearch-invisible "in" ""))) - (sit-for 1)) + "match %svisible text" + (isearch--momentary-message + (if (setq isearch-invisible + (if isearch-invisible + nil (or search-invisible 'open))) + "match invisible text" + "match visible text"))) ;; Word search |