diff options
| author | Daniel Colascione | 2015-07-04 17:10:55 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2015-07-04 17:10:55 -0700 |
| commit | 4fff58dd1ec11543e2b0195f10cefc1746748499 (patch) | |
| tree | 049a91215c71b0612e5f904c2e76b4c7afd16bc6 | |
| parent | 65571b37ed5300546ea75da7888f73941011d0d0 (diff) | |
| download | emacs-4fff58dd1ec11543e2b0195f10cefc1746748499.tar.gz emacs-4fff58dd1ec11543e2b0195f10cefc1746748499.zip | |
Factor isearch word description into new function
* lisp/isearch.el (isearch--describe-word-mode): New function.
(isearch-message-prefix, isearch-query-replace): Use it.
| -rw-r--r-- | lisp/isearch.el | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index a103c5ab59b..8d4bf24c6fb 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -1766,16 +1766,8 @@ replacements from Isearch is `M-s w ... M-%'." | |||
| 1766 | (query-replace-read-to | 1766 | (query-replace-read-to |
| 1767 | isearch-string | 1767 | isearch-string |
| 1768 | (concat "Query replace" | 1768 | (concat "Query replace" |
| 1769 | (if (or delimited isearch-word) | 1769 | (isearch--describe-word-mode (or delimited isearch-word) t) |
| 1770 | (let* ((symbol (or delimited isearch-word)) | 1770 | (if isearch-regexp " regexp" "") |
| 1771 | (string (and symbol (symbolp symbol) | ||
| 1772 | (get symbol 'isearch-message-prefix)))) | ||
| 1773 | (if (stringp string) | ||
| 1774 | ;; Move space from the end to the beginning. | ||
| 1775 | (replace-regexp-in-string "\\(.*\\) \\'" " \\1" string) | ||
| 1776 | " word")) | ||
| 1777 | "") | ||
| 1778 | (if isearch-regexp " regexp" "") | ||
| 1779 | (if backward " backward" "") | 1771 | (if backward " backward" "") |
| 1780 | (if (and transient-mark-mode mark-active) " in region" "")) | 1772 | (if (and transient-mark-mode mark-active) " in region" "")) |
| 1781 | isearch-regexp) | 1773 | isearch-regexp) |
| @@ -2521,6 +2513,21 @@ If there is no completion possible, say so and continue searching." | |||
| 2521 | (isearch-message-suffix c-q-hack))) | 2513 | (isearch-message-suffix c-q-hack))) |
| 2522 | (if c-q-hack m (let ((message-log-max nil)) (message "%s" m))))) | 2514 | (if c-q-hack m (let ((message-log-max nil)) (message "%s" m))))) |
| 2523 | 2515 | ||
| 2516 | (defun isearch--describe-word-mode (word-mode &optional space-before) | ||
| 2517 | "Make a string for describing WORD-MODE. | ||
| 2518 | If SPACE-BEFORE is non-nil, put a space before, instead of after, | ||
| 2519 | the word mode." | ||
| 2520 | (let ((description | ||
| 2521 | (cond ((and (symbolp word-mode) | ||
| 2522 | (get word-mode 'isearch-message-prefix)) | ||
| 2523 | (get word-mode 'isearch-message-prefix)) | ||
| 2524 | (word-mode "word ") | ||
| 2525 | (t "")))) | ||
| 2526 | (if space-before | ||
| 2527 | ;; Move space from the end to the beginning. | ||
| 2528 | (replace-regexp-in-string "\\(.*\\) \\'" " \\1" description) | ||
| 2529 | description))) | ||
| 2530 | |||
| 2524 | (defun isearch-message-prefix (&optional ellipsis nonincremental) | 2531 | (defun isearch-message-prefix (&optional ellipsis nonincremental) |
| 2525 | ;; If about to search, and previous search regexp was invalid, | 2532 | ;; If about to search, and previous search regexp was invalid, |
| 2526 | ;; check that it still is. If it is valid now, | 2533 | ;; check that it still is. If it is valid now, |
| @@ -2547,13 +2554,9 @@ If there is no completion possible, say so and continue searching." | |||
| 2547 | (let ((np (cdr (assq 'isearch-message-prefix props)))) | 2554 | (let ((np (cdr (assq 'isearch-message-prefix props)))) |
| 2548 | (if np (setq prefix (concat np prefix))))) | 2555 | (if np (setq prefix (concat np prefix))))) |
| 2549 | isearch-filter-predicate) | 2556 | isearch-filter-predicate) |
| 2550 | prefix) | 2557 | prefix) |
| 2551 | (if isearch-word | 2558 | (isearch--describe-word-mode isearch-word) |
| 2552 | (or (and (symbolp isearch-word) | 2559 | (if isearch-regexp "regexp " "") |
| 2553 | (get isearch-word 'isearch-message-prefix)) | ||
| 2554 | "word ") | ||
| 2555 | "") | ||
| 2556 | (if isearch-regexp "regexp " "") | ||
| 2557 | (cond | 2560 | (cond |
| 2558 | (multi-isearch-file-list "multi-file ") | 2561 | (multi-isearch-file-list "multi-file ") |
| 2559 | (multi-isearch-buffer-list "multi-buffer ") | 2562 | (multi-isearch-buffer-list "multi-buffer ") |