emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

highlight failed part of isearch input


From: Drew Adams
Subject: highlight failed part of isearch input
Date: Mon, 9 Jul 2007 20:03:04 -0700

I find that this minor tweak to `isearch-message' helps a good deal when
using Isearch. It highlights, within your Isearch input, the part that fails
to match.

(defface isearch-fail '((t (:foreground "Black" :background "Plum")))
  "Face for highlighting failed part in Isearch echo-area message."
  :group 'isearch)

(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 succ-msg isearch-message)
                  (not (string= succ-msg isearch-message))
                  (propertize (substring isearch-message (match-end 0))
                              'face 'isearch-fail))))
    (when (string-match " +$" m)
      (propertize (substring m (match-beginning 0)) 'face
'trailing-whitespace))
    (setq m (concat m (isearch-message-suffix c-q-hack ellipsis)))
    (if c-q-hack m (let ((message-log-max nil)) (message "%s" m)))))

--

Here is the original `isearch-message', for reference:

(defun isearch-message (&optional c-q-hack ellipsis)
  ;; Generate and print the message string.
  (let ((cursor-in-echo-area ellipsis)
        (m (concat
            (isearch-message-prefix c-q-hack ellipsis isearch-nonincremental)
            (if (and (not isearch-success)
                     (string-match " +$" isearch-message))
                (concat
                 (substring isearch-message 0 (match-beginning 0))
                 (propertize (substring isearch-message (match-beginning 0))
                             'face 'trailing-whitespace))
              isearch-message)
            (isearch-message-suffix c-q-hack ellipsis)
            )))
    (if c-q-hack
        m
      (let ((message-log-max nil))
        (message "%s" m)))))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]