From d8891294b81672883c21b6b957e5a17b6990b8e4 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 25 Feb 2008 00:01:54 +0000 Subject: [PATCH] (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. --- lisp/ChangeLog | 10 ++++++++++ lisp/isearch.el | 52 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 266d07a9ee5..eb3a907d6c3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2008-02-25 Juri Linkov + + * isearch.el (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. + 2008-02-24 Juri Linkov * progmodes/compile.el (compilation-handle-exit): diff --git a/lisp/isearch.el b/lisp/isearch.el index 44f4ad1eed4..bbe2363d57b 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -231,8 +231,20 @@ Default value, nil, means edit the string instead." :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 @@ If there is no completion possible, say so and continue searching." (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, -- 2.39.5