# HG changeset patch # User Juri Linkov # Date 1203897701 0 # Node ID 1b8f987330e10411be1546493263367c07120ea5 # Parent 16e08abf25d27c3070a546a035a11d7f61b9fde9 (isearch-fail): Use "RosyBrown1" for a light background, "red4" for a dark background, "red" for 16 and 8 colors, "grey" for grayscale, and inverse video otherwise. Add :version tag. (isearch-message): Keep the original isearch-message intact, and add text properties to it where necessary. Add `isearch-error' to the condition that checks if isearch is unsuccessful. diff -r 16e08abf25d2 -r 1b8f987330e1 lisp/isearch.el --- a/lisp/isearch.el Sun Feb 24 23:22:26 2008 +0000 +++ b/lisp/isearch.el Mon Feb 25 00:01:41 2008 +0000 @@ -231,8 +231,20 @@ :group 'basic-faces) (defvar isearch 'isearch) -(defface isearch-fail '((t (:foreground "Black" :background "Plum"))) +(defface isearch-fail + '((((class color) (min-colors 88) (background light)) + (:background "RosyBrown1")) + (((class color) (min-colors 88) (background dark)) + (:background "red4")) + (((class color) (min-colors 16)) + (:background "red")) + (((class color) (min-colors 8)) + (:background "red")) + (((class color grayscale)) + :foreground "grey") + (t (:inverse-video t))) "Face for highlighting failed part in Isearch echo-area message." + :version "23.1" :group 'isearch) (defcustom isearch-lazy-highlight t @@ -1959,22 +1971,28 @@ (defun isearch-message (&optional c-q-hack ellipsis) ;; Generate and print the message string. (let ((cursor-in-echo-area ellipsis) - (cmds isearch-cmds) - succ-msg m) - (while (not (isearch-success-state (car cmds))) (pop cmds)) - (setq succ-msg (and cmds (isearch-message-state (car cmds)))) - (setq m (concat - (isearch-message-prefix c-q-hack ellipsis isearch-nonincremental) - succ-msg - (and (not isearch-success) - (string-match (regexp-quote succ-msg) isearch-message) - (not (string= succ-msg isearch-message)) - (propertize (substring isearch-message (match-end 0)) - 'face 'isearch-fail)))) - (when (and (not isearch-success) (string-match " +$" m)) - (put-text-property (match-beginning 0) (length m) 'face 'trailing-whitespace m)) - (setq m (concat m (isearch-message-suffix c-q-hack ellipsis))) - (if c-q-hack m (let ((message-log-max nil)) (message "%s" m))))) + (m isearch-message) + (cmds isearch-cmds) + succ-msg) + (when (or (not isearch-success) isearch-error) + ;; Highlight failed part + (while (or (not (isearch-success-state (car cmds))) + (isearch-error-state (car cmds))) + (pop cmds)) + (setq succ-msg (and cmds (isearch-message-state (car cmds))) + m (copy-sequence m)) + (when (and (stringp succ-msg) (< (length succ-msg) (length m))) + (add-text-properties (length succ-msg) (length m) + '(face isearch-fail) m)) + ;; Highlight failed trailing whitespace + (when (string-match " +$" m) + (add-text-properties (match-beginning 0) (match-end 0) + '(face trailing-whitespace) m))) + (setq m (concat + (isearch-message-prefix c-q-hack ellipsis isearch-nonincremental) + m + (isearch-message-suffix c-q-hack ellipsis))) + (if c-q-hack m (let ((message-log-max nil)) (message "%s" m))))) (defun isearch-message-prefix (&optional c-q-hack ellipsis nonincremental) ;; If about to search, and previous search regexp was invalid,