diff options
| author | Juri Linkov | 2018-04-23 01:10:49 +0300 |
|---|---|---|
| committer | Juri Linkov | 2018-04-23 01:10:49 +0300 |
| commit | 7abd3f2dcf1d31e31f40ca817666e8f66a17284f (patch) | |
| tree | 880199c2f4902fb30fab689dd7495106493a1a07 | |
| parent | b26872a3b13f69f7f67a4964722d2ef155964c45 (diff) | |
| download | emacs-7abd3f2dcf1d31e31f40ca817666e8f66a17284f.tar.gz emacs-7abd3f2dcf1d31e31f40ca817666e8f66a17284f.zip | |
Improve Isearch error handling
* lisp/isearch.el (isearch--momentary-message): Propertize message
suffix with minibuffer-prompt face.
(isearch--describe-regexp-mode): Do not omit description in case
of error in default non-literal search.
(isearch-message-prefix): Display “case-sensitive” in case of error.
(isearch-message-suffix): Propertize message suffix with
minibuffer-prompt face.
(isearch-search-fun-default): Remove unused error handling.
* lisp/vc/add-log.el (change-log-next-buffer): Better handle
errors during wrapping.
| -rw-r--r-- | etc/NEWS | 18 | ||||
| -rw-r--r-- | lisp/info.el | 2 | ||||
| -rw-r--r-- | lisp/isearch.el | 68 | ||||
| -rw-r--r-- | lisp/replace.el | 2 | ||||
| -rw-r--r-- | lisp/vc/add-log.el | 14 |
5 files changed, 60 insertions, 44 deletions
| @@ -141,11 +141,6 @@ regular expression was previously invalid, but is now accepted: | |||
| 141 | 141 | ||
| 142 | * Editing Changes in Emacs 27.1 | 142 | * Editing Changes in Emacs 27.1 |
| 143 | 143 | ||
| 144 | +++ | ||
| 145 | ** New isearch bindings. | ||
| 146 | 'C-M-w' in isearch changed from isearch-del-char to the new function | ||
| 147 | isearch-yank-symbol-or-char. isearch-del-char is now bound to 'C-M-d'. | ||
| 148 | |||
| 149 | --- | 144 | --- |
| 150 | ** New variable 'x-wait-for-event-timeout'. | 145 | ** New variable 'x-wait-for-event-timeout'. |
| 151 | This controls how long Emacs will wait for updates to the graphical | 146 | This controls how long Emacs will wait for updates to the graphical |
| @@ -169,6 +164,10 @@ for abbrevs that have them. | |||
| 169 | `text-property-search-backward' have been added. These provide an | 164 | `text-property-search-backward' have been added. These provide an |
| 170 | interface that's more like functions like @code{search-forward}. | 165 | interface that's more like functions like @code{search-forward}. |
| 171 | 166 | ||
| 167 | --- | ||
| 168 | ** More commands support noncontiguous rectangular regions, namely | ||
| 169 | ‘upcase-dwim’, ‘downcase-dwim’, ‘replace-string’, ‘replace-regexp’. | ||
| 170 | |||
| 172 | 171 | ||
| 173 | * Changes in Specialized Modes and Packages in Emacs 27.1 | 172 | * Changes in Specialized Modes and Packages in Emacs 27.1 |
| 174 | 173 | ||
| @@ -293,12 +292,21 @@ can now be searched via 'C-s'. | |||
| 293 | ** Search and Replace | 292 | ** Search and Replace |
| 294 | 293 | ||
| 295 | +++ | 294 | +++ |
| 295 | *** New isearch bindings. | ||
| 296 | 'C-M-w' in isearch changed from isearch-del-char to the new function | ||
| 297 | isearch-yank-symbol-or-char. isearch-del-char is now bound to 'C-M-d'. | ||
| 298 | |||
| 299 | +++ | ||
| 296 | *** 'search-exit-option' provides new options 'move' and 'shift-move' | 300 | *** 'search-exit-option' provides new options 'move' and 'shift-move' |
| 297 | to extend the search string by yanking text that ends at the new | 301 | to extend the search string by yanking text that ends at the new |
| 298 | position after moving point in the current buffer. 'shift-move' | 302 | position after moving point in the current buffer. 'shift-move' |
| 299 | extends the search string by motion commands while holding down | 303 | extends the search string by motion commands while holding down |
| 300 | the shift key. | 304 | the shift key. |
| 301 | 305 | ||
| 306 | --- | ||
| 307 | *** Isearch now remembers the regexp-based search mode for words/symbols | ||
| 308 | and case-sensitivity together with search strings in the search ring. | ||
| 309 | |||
| 302 | ** Edebug | 310 | ** Edebug |
| 303 | 311 | ||
| 304 | +++ | 312 | +++ |
diff --git a/lisp/info.el b/lisp/info.el index 0db84fb3dab..bbce55f6216 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -2017,7 +2017,7 @@ If DIRECTION is `backward', search in the reverse direction." | |||
| 2017 | Info-isearch-initial-node | 2017 | Info-isearch-initial-node |
| 2018 | bound | 2018 | bound |
| 2019 | (and found (> found opoint-min) (< found opoint-max))) | 2019 | (and found (> found opoint-min) (< found opoint-max))) |
| 2020 | (signal 'user-search-failed (list regexp "(end of node)"))) | 2020 | (signal 'user-search-failed (list regexp "end of node"))) |
| 2021 | 2021 | ||
| 2022 | ;; If no subfiles, give error now. | 2022 | ;; If no subfiles, give error now. |
| 2023 | (unless (or found Info-current-subfile) | 2023 | (unless (or found Info-current-subfile) |
diff --git a/lisp/isearch.el b/lisp/isearch.el index db196e00efb..5cbb4c941a5 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -1143,10 +1143,10 @@ REGEXP if non-nil says use the regexp search ring." | |||
| 1143 | 1143 | ||
| 1144 | (defun isearch-update-from-string-properties (string) | 1144 | (defun isearch-update-from-string-properties (string) |
| 1145 | "Update isearch properties from the isearch string" | 1145 | "Update isearch properties from the isearch string" |
| 1146 | (when (memq 'isearch-case-fold-search (text-properties-at 0 string)) | 1146 | (when (plist-member (text-properties-at 0 string) 'isearch-case-fold-search) |
| 1147 | (setq isearch-case-fold-search | 1147 | (setq isearch-case-fold-search |
| 1148 | (get-text-property 0 'isearch-case-fold-search string))) | 1148 | (get-text-property 0 'isearch-case-fold-search string))) |
| 1149 | (when (memq 'isearch-regexp-function (text-properties-at 0 string)) | 1149 | (when (plist-member (text-properties-at 0 string) 'isearch-regexp-function) |
| 1150 | (setq isearch-regexp-function | 1150 | (setq isearch-regexp-function |
| 1151 | (get-text-property 0 'isearch-regexp-function string)))) | 1151 | (get-text-property 0 'isearch-regexp-function string)))) |
| 1152 | 1152 | ||
| @@ -1602,10 +1602,10 @@ Turning on character-folding turns off regexp mode.") | |||
| 1602 | (defun isearch--momentary-message (string) | 1602 | (defun isearch--momentary-message (string) |
| 1603 | "Print STRING at the end of the isearch prompt for 1 second" | 1603 | "Print STRING at the end of the isearch prompt for 1 second" |
| 1604 | (let ((message-log-max nil)) | 1604 | (let ((message-log-max nil)) |
| 1605 | (message "%s%s [%s]" | 1605 | (message "%s%s%s" |
| 1606 | (isearch-message-prefix nil isearch-nonincremental) | 1606 | (isearch-message-prefix nil isearch-nonincremental) |
| 1607 | isearch-message | 1607 | isearch-message |
| 1608 | string)) | 1608 | (propertize (format " [%s]" string) 'face 'minibuffer-prompt))) |
| 1609 | (sit-for 1)) | 1609 | (sit-for 1)) |
| 1610 | 1610 | ||
| 1611 | (isearch-define-mode-toggle lax-whitespace " " nil | 1611 | (isearch-define-mode-toggle lax-whitespace " " nil |
| @@ -2693,12 +2693,16 @@ the word mode." | |||
| 2693 | (cond | 2693 | (cond |
| 2694 | ;; 1. Do not use a description on the default search mode, | 2694 | ;; 1. Do not use a description on the default search mode, |
| 2695 | ;; but only if the default search mode is non-nil. | 2695 | ;; but only if the default search mode is non-nil. |
| 2696 | ((or (and search-default-mode | 2696 | ((and (or (and search-default-mode |
| 2697 | (equal search-default-mode regexp-function)) | 2697 | (equal search-default-mode regexp-function)) |
| 2698 | ;; Special case where `search-default-mode' is t | 2698 | ;; Special case where `search-default-mode' is t |
| 2699 | ;; (defaults to regexp searches). | 2699 | ;; (defaults to regexp searches). |
| 2700 | (and (eq search-default-mode t) | 2700 | (and (eq search-default-mode t) |
| 2701 | (eq search-default-mode isearch-regexp))) "") | 2701 | (eq search-default-mode isearch-regexp))) |
| 2702 | ;; Also do not omit description in case of error | ||
| 2703 | ;; in default non-literal search. | ||
| 2704 | (or isearch-success (not (or regexp-function isearch-regexp)))) | ||
| 2705 | "") | ||
| 2702 | ;; 2. Use the `isearch-message-prefix' set for | 2706 | ;; 2. Use the `isearch-message-prefix' set for |
| 2703 | ;; `regexp-function' if available. | 2707 | ;; `regexp-function' if available. |
| 2704 | (regexp-function | 2708 | (regexp-function |
| @@ -2741,6 +2745,8 @@ the word mode." | |||
| 2741 | (< (point) isearch-opoint))) | 2745 | (< (point) isearch-opoint))) |
| 2742 | "over") | 2746 | "over") |
| 2743 | (if isearch-wrapped "wrapped ") | 2747 | (if isearch-wrapped "wrapped ") |
| 2748 | (if (and (not isearch-success) (not isearch-case-fold-search)) | ||
| 2749 | "case-sensitive ") | ||
| 2744 | (let ((prefix "")) | 2750 | (let ((prefix "")) |
| 2745 | (advice-function-mapc | 2751 | (advice-function-mapc |
| 2746 | (lambda (_ props) | 2752 | (lambda (_ props) |
| @@ -2768,11 +2774,12 @@ the word mode." | |||
| 2768 | 'face 'minibuffer-prompt))) | 2774 | 'face 'minibuffer-prompt))) |
| 2769 | 2775 | ||
| 2770 | (defun isearch-message-suffix (&optional c-q-hack) | 2776 | (defun isearch-message-suffix (&optional c-q-hack) |
| 2771 | (concat (if c-q-hack "^Q" "") | 2777 | (propertize (concat (if c-q-hack "^Q" "") |
| 2772 | (if isearch-error | 2778 | (if isearch-error |
| 2773 | (concat " [" isearch-error "]") | 2779 | (concat " [" isearch-error "]") |
| 2774 | "") | 2780 | "") |
| 2775 | (or isearch-message-suffix-add ""))) | 2781 | (or isearch-message-suffix-add "")) |
| 2782 | 'face 'minibuffer-prompt)) | ||
| 2776 | 2783 | ||
| 2777 | 2784 | ||
| 2778 | ;; Searching | 2785 | ;; Searching |
| @@ -2808,25 +2815,18 @@ Can be changed via `isearch-search-fun-function' for special needs." | |||
| 2808 | (isearch-regexp isearch-regexp-lax-whitespace) | 2815 | (isearch-regexp isearch-regexp-lax-whitespace) |
| 2809 | (t isearch-lax-whitespace)) | 2816 | (t isearch-lax-whitespace)) |
| 2810 | search-whitespace-regexp))) | 2817 | search-whitespace-regexp))) |
| 2811 | (condition-case er | 2818 | (funcall |
| 2812 | (funcall | 2819 | (if isearch-forward #'re-search-forward #'re-search-backward) |
| 2813 | (if isearch-forward #'re-search-forward #'re-search-backward) | 2820 | (cond (isearch-regexp-function |
| 2814 | (cond (isearch-regexp-function | 2821 | (let ((lax (and (not bound) (isearch--lax-regexp-function-p)))) |
| 2815 | (let ((lax (and (not bound) (isearch--lax-regexp-function-p)))) | 2822 | (when lax |
| 2816 | (when lax | 2823 | (setq isearch-adjusted t)) |
| 2817 | (setq isearch-adjusted t)) | 2824 | (if (functionp isearch-regexp-function) |
| 2818 | (if (functionp isearch-regexp-function) | 2825 | (funcall isearch-regexp-function string lax) |
| 2819 | (funcall isearch-regexp-function string lax) | 2826 | (word-search-regexp string lax)))) |
| 2820 | (word-search-regexp string lax)))) | 2827 | (isearch-regexp string) |
| 2821 | (isearch-regexp string) | 2828 | (t (regexp-quote string))) |
| 2822 | (t (regexp-quote string))) | 2829 | bound noerror count)))) |
| 2823 | bound noerror count) | ||
| 2824 | (search-failed | ||
| 2825 | (signal (car er) | ||
| 2826 | (let ((prefix (get isearch-regexp-function 'isearch-message-prefix))) | ||
| 2827 | (if (and isearch-regexp-function (stringp prefix)) | ||
| 2828 | (list (format "%s [using %ssearch]" string prefix)) | ||
| 2829 | (cdr er))))))))) | ||
| 2830 | 2830 | ||
| 2831 | (defun isearch-search-string (string bound noerror) | 2831 | (defun isearch-search-string (string bound noerror) |
| 2832 | "Search for the first occurrence of STRING or its translation. | 2832 | "Search for the first occurrence of STRING or its translation. |
diff --git a/lisp/replace.el b/lisp/replace.el index d5d34f652ab..3503b656d9c 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -314,7 +314,7 @@ the original string if not." | |||
| 314 | (query-replace-read-to from prompt regexp-flag)))) | 314 | (query-replace-read-to from prompt regexp-flag)))) |
| 315 | (list from to | 315 | (list from to |
| 316 | (or (and current-prefix-arg (not (eq current-prefix-arg '-))) | 316 | (or (and current-prefix-arg (not (eq current-prefix-arg '-))) |
| 317 | (and (memq 'isearch-regexp-function (text-properties-at 0 from)) | 317 | (and (plist-member (text-properties-at 0 from) 'isearch-regexp-function) |
| 318 | (get-text-property 0 'isearch-regexp-function from))) | 318 | (get-text-property 0 'isearch-regexp-function from))) |
| 319 | (and current-prefix-arg (eq current-prefix-arg '-))))) | 319 | (and current-prefix-arg (eq current-prefix-arg '-))))) |
| 320 | 320 | ||
diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index 41a99916994..4c64ae1f60b 100644 --- a/lisp/vc/add-log.el +++ b/lisp/vc/add-log.el | |||
| @@ -1099,9 +1099,17 @@ file were isearch was started." | |||
| 1099 | ;; If there are no files that match the default pattern ChangeLog.[0-9], | 1099 | ;; If there are no files that match the default pattern ChangeLog.[0-9], |
| 1100 | ;; return the current buffer to force isearch wrapping to its beginning. | 1100 | ;; return the current buffer to force isearch wrapping to its beginning. |
| 1101 | ;; If file is nil, multi-isearch-search-fun will signal "end of multi". | 1101 | ;; If file is nil, multi-isearch-search-fun will signal "end of multi". |
| 1102 | (if (and file (file-exists-p file)) | 1102 | (cond |
| 1103 | (find-file-noselect file) | 1103 | ;; Wrapping doesn't catch errors from the nil arg of file-exists-p, |
| 1104 | (current-buffer)))) | 1104 | ;; so handle it explicitly. |
| 1105 | ((and wrap (null file)) | ||
| 1106 | (current-buffer)) | ||
| 1107 | ;; When there is no next file, file-exists-p raises the error to be | ||
| 1108 | ;; catched by the search function that displays the error message. | ||
| 1109 | ((file-exists-p file) | ||
| 1110 | (find-file-noselect file)) | ||
| 1111 | (t | ||
| 1112 | (current-buffer))))) | ||
| 1105 | 1113 | ||
| 1106 | (defun change-log-fill-forward-paragraph (n) | 1114 | (defun change-log-fill-forward-paragraph (n) |
| 1107 | "Cut paragraphs so filling preserves open parentheses at beginning of lines." | 1115 | "Cut paragraphs so filling preserves open parentheses at beginning of lines." |