diff options
| author | Artur Malabarba | 2015-10-28 12:01:39 +0000 |
|---|---|---|
| committer | Artur Malabarba | 2015-10-28 15:10:08 +0000 |
| commit | faace42f8a4c8f53f629419ba89a5196d62ee006 (patch) | |
| tree | 4b71336244c09c209f7fbb5474f9ca7124bab236 | |
| parent | 12c0edb7555613aecfd27610601f137be252b804 (diff) | |
| download | emacs-faace42f8a4c8f53f629419ba89a5196d62ee006.tar.gz 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.
| -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." | |||
| 1532 | (setq isearch-regexp (not isearch-regexp)) | 1532 | (setq isearch-regexp (not isearch-regexp)) |
| 1533 | (if isearch-regexp (setq isearch-regexp-function nil))) | 1533 | (if isearch-regexp (setq isearch-regexp-function nil))) |
| 1534 | 1534 | ||
| 1535 | (defun isearch--momentary-message (string) | ||
| 1536 | "Print STRING at the end of the isearch prompt for 1 second" | ||
| 1537 | (let ((message-log-max nil)) | ||
| 1538 | (message "%s%s [%s]" | ||
| 1539 | (isearch-message-prefix nil isearch-nonincremental) | ||
| 1540 | isearch-message | ||
| 1541 | string)) | ||
| 1542 | (sit-for 1)) | ||
| 1543 | |||
| 1535 | (isearch-define-mode-toggle lax-whitespace " " nil | 1544 | (isearch-define-mode-toggle lax-whitespace " " nil |
| 1536 | "In ordinary search, toggles the value of the variable | 1545 | "In ordinary search, toggles the value of the variable |
| 1537 | `isearch-lax-whitespace'. In regexp search, toggles the | 1546 | `isearch-lax-whitespace'. In regexp search, toggles the |
| 1538 | value of the variable `isearch-regexp-lax-whitespace'." | 1547 | value of the variable `isearch-regexp-lax-whitespace'." |
| 1539 | (if isearch-regexp | 1548 | (isearch--momentary-message |
| 1540 | (setq isearch-regexp-lax-whitespace (not isearch-regexp-lax-whitespace)) | 1549 | (if (if isearch-regexp |
| 1541 | (setq isearch-lax-whitespace (not isearch-lax-whitespace))) | 1550 | (setq isearch-regexp-lax-whitespace (not isearch-regexp-lax-whitespace)) |
| 1542 | (let ((message-log-max nil)) | 1551 | (setq isearch-lax-whitespace (not isearch-lax-whitespace))) |
| 1543 | (message "%s%s [%s]" | 1552 | "match spaces loosely" |
| 1544 | (isearch-message-prefix nil isearch-nonincremental) | 1553 | "match spaces literally"))) |
| 1545 | isearch-message | ||
| 1546 | (if (if isearch-regexp | ||
| 1547 | isearch-regexp-lax-whitespace | ||
| 1548 | isearch-lax-whitespace) | ||
| 1549 | "match spaces loosely" | ||
| 1550 | "match spaces literally"))) | ||
| 1551 | (sit-for 1)) | ||
| 1552 | 1554 | ||
| 1553 | (isearch-define-mode-toggle case-fold "c" nil | 1555 | (isearch-define-mode-toggle case-fold "c" nil |
| 1554 | "Toggles the value of the variable `isearch-case-fold-search'." | 1556 | "Toggles the value of the variable `isearch-case-fold-search'." |
| 1555 | (setq isearch-case-fold-search | 1557 | (isearch--momentary-message |
| 1556 | (if isearch-case-fold-search nil 'yes)) | 1558 | (if (setq isearch-case-fold-search |
| 1557 | (let ((message-log-max nil)) | 1559 | (if isearch-case-fold-search nil 'yes)) |
| 1558 | (message "%s%s [case %ssensitive]" | 1560 | "case insensitive" |
| 1559 | (isearch-message-prefix nil isearch-nonincremental) | 1561 | "case sensitive"))) |
| 1560 | isearch-message | ||
| 1561 | (if isearch-case-fold-search "in" ""))) | ||
| 1562 | (sit-for 1)) | ||
| 1563 | 1562 | ||
| 1564 | (isearch-define-mode-toggle invisible "i" nil | 1563 | (isearch-define-mode-toggle invisible "i" nil |
| 1565 | "This determines whether to search inside invisible text or not. | 1564 | "This determines whether to search inside invisible text or not. |
| 1566 | Toggles the variable `isearch-invisible' between values | 1565 | Toggles the variable `isearch-invisible' between values |
| 1567 | nil and a non-nil value of the option `search-invisible' | 1566 | nil and a non-nil value of the option `search-invisible' |
| 1568 | \(or `open' if `search-invisible' is nil)." | 1567 | \(or `open' if `search-invisible' is nil)." |
| 1569 | (setq isearch-invisible | 1568 | "match %svisible text" |
| 1570 | (if isearch-invisible nil (or search-invisible 'open))) | 1569 | (isearch--momentary-message |
| 1571 | (let ((message-log-max nil)) | 1570 | (if (setq isearch-invisible |
| 1572 | (message "%s%s [match %svisible text]" | 1571 | (if isearch-invisible |
| 1573 | (isearch-message-prefix nil isearch-nonincremental) | 1572 | nil (or search-invisible 'open))) |
| 1574 | isearch-message | 1573 | "match invisible text" |
| 1575 | (if isearch-invisible "in" ""))) | 1574 | "match visible text"))) |
| 1576 | (sit-for 1)) | ||
| 1577 | 1575 | ||
| 1578 | 1576 | ||
| 1579 | ;; Word search | 1577 | ;; Word search |