diff options
author | Juri Linkov <juri@linkov.net> | 2018-04-23 01:10:49 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2018-04-23 01:10:49 +0300 |
commit | 7abd3f2dcf1d31e31f40ca817666e8f66a17284f (patch) | |
tree | 880199c2f4902fb30fab689dd7495106493a1a07 /lisp | |
parent | b26872a3b13f69f7f67a4964722d2ef155964c45 (diff) | |
download | emacs-7abd3f2dcf1d31e31f40ca817666e8f66a17284f.tar.gz |
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.
Diffstat (limited to 'lisp')
-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 |
4 files changed, 47 insertions, 39 deletions
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." Info-isearch-initial-node bound (and found (> found opoint-min) (< found opoint-max))) - (signal 'user-search-failed (list regexp "(end of node)"))) + (signal 'user-search-failed (list regexp "end of node"))) ;; If no subfiles, give error now. (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." (defun isearch-update-from-string-properties (string) "Update isearch properties from the isearch string" - (when (memq 'isearch-case-fold-search (text-properties-at 0 string)) + (when (plist-member (text-properties-at 0 string) 'isearch-case-fold-search) (setq isearch-case-fold-search (get-text-property 0 'isearch-case-fold-search string))) - (when (memq 'isearch-regexp-function (text-properties-at 0 string)) + (when (plist-member (text-properties-at 0 string) 'isearch-regexp-function) (setq isearch-regexp-function (get-text-property 0 'isearch-regexp-function string)))) @@ -1602,10 +1602,10 @@ Turning on character-folding turns off regexp mode.") (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]" + (message "%s%s%s" (isearch-message-prefix nil isearch-nonincremental) isearch-message - string)) + (propertize (format " [%s]" string) 'face 'minibuffer-prompt))) (sit-for 1)) (isearch-define-mode-toggle lax-whitespace " " nil @@ -2693,12 +2693,16 @@ the word mode." (cond ;; 1. Do not use a description on the default search mode, ;; but only if the default search mode is non-nil. - ((or (and search-default-mode - (equal search-default-mode regexp-function)) - ;; Special case where `search-default-mode' is t - ;; (defaults to regexp searches). - (and (eq search-default-mode t) - (eq search-default-mode isearch-regexp))) "") + ((and (or (and search-default-mode + (equal search-default-mode regexp-function)) + ;; Special case where `search-default-mode' is t + ;; (defaults to regexp searches). + (and (eq search-default-mode t) + (eq search-default-mode isearch-regexp))) + ;; Also do not omit description in case of error + ;; in default non-literal search. + (or isearch-success (not (or regexp-function isearch-regexp)))) + "") ;; 2. Use the `isearch-message-prefix' set for ;; `regexp-function' if available. (regexp-function @@ -2741,6 +2745,8 @@ the word mode." (< (point) isearch-opoint))) "over") (if isearch-wrapped "wrapped ") + (if (and (not isearch-success) (not isearch-case-fold-search)) + "case-sensitive ") (let ((prefix "")) (advice-function-mapc (lambda (_ props) @@ -2768,11 +2774,12 @@ the word mode." 'face 'minibuffer-prompt))) (defun isearch-message-suffix (&optional c-q-hack) - (concat (if c-q-hack "^Q" "") - (if isearch-error - (concat " [" isearch-error "]") - "") - (or isearch-message-suffix-add ""))) + (propertize (concat (if c-q-hack "^Q" "") + (if isearch-error + (concat " [" isearch-error "]") + "") + (or isearch-message-suffix-add "")) + 'face 'minibuffer-prompt)) ;; Searching @@ -2808,25 +2815,18 @@ Can be changed via `isearch-search-fun-function' for special needs." (isearch-regexp isearch-regexp-lax-whitespace) (t isearch-lax-whitespace)) search-whitespace-regexp))) - (condition-case er - (funcall - (if isearch-forward #'re-search-forward #'re-search-backward) - (cond (isearch-regexp-function - (let ((lax (and (not bound) (isearch--lax-regexp-function-p)))) - (when lax - (setq isearch-adjusted t)) - (if (functionp isearch-regexp-function) - (funcall isearch-regexp-function string lax) - (word-search-regexp string lax)))) - (isearch-regexp string) - (t (regexp-quote string))) - bound noerror count) - (search-failed - (signal (car er) - (let ((prefix (get isearch-regexp-function 'isearch-message-prefix))) - (if (and isearch-regexp-function (stringp prefix)) - (list (format "%s [using %ssearch]" string prefix)) - (cdr er))))))))) + (funcall + (if isearch-forward #'re-search-forward #'re-search-backward) + (cond (isearch-regexp-function + (let ((lax (and (not bound) (isearch--lax-regexp-function-p)))) + (when lax + (setq isearch-adjusted t)) + (if (functionp isearch-regexp-function) + (funcall isearch-regexp-function string lax) + (word-search-regexp string lax)))) + (isearch-regexp string) + (t (regexp-quote string))) + bound noerror count)))) (defun isearch-search-string (string bound noerror) "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." (query-replace-read-to from prompt regexp-flag)))) (list from to (or (and current-prefix-arg (not (eq current-prefix-arg '-))) - (and (memq 'isearch-regexp-function (text-properties-at 0 from)) + (and (plist-member (text-properties-at 0 from) 'isearch-regexp-function) (get-text-property 0 'isearch-regexp-function from))) (and current-prefix-arg (eq current-prefix-arg '-))))) 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." ;; If there are no files that match the default pattern ChangeLog.[0-9], ;; return the current buffer to force isearch wrapping to its beginning. ;; If file is nil, multi-isearch-search-fun will signal "end of multi". - (if (and file (file-exists-p file)) - (find-file-noselect file) - (current-buffer)))) + (cond + ;; Wrapping doesn't catch errors from the nil arg of file-exists-p, + ;; so handle it explicitly. + ((and wrap (null file)) + (current-buffer)) + ;; When there is no next file, file-exists-p raises the error to be + ;; catched by the search function that displays the error message. + ((file-exists-p file) + (find-file-noselect file)) + (t + (current-buffer))))) (defun change-log-fill-forward-paragraph (n) "Cut paragraphs so filling preserves open parentheses at beginning of lines." |