From: Juri Linkov <juri@jurta.org>
To: Drew Adams <drew.adams@oracle.com>
Cc: emacs-devel@gnu.org
Subject: Re: highlight failed part of isearch input
Date: Sun, 24 Feb 2008 19:29:19 +0200 [thread overview]
Message-ID: <87oda6e614.fsf@jurta.org> (raw)
In-Reply-To: <8763wfpi9w.fsf@jurta.org> (Juri Linkov's message of "Sat, 23 Feb 2008 21:47:07 +0200")
>> There is one regression after installing this patch: `C-s M-p' now
>> doesn't put the previous search string from the search ring to the
>> isearch minibuffer.
>
> The patch below fixes this problem. When the first message from the
> isearch-cmds stack is not the same as isearch-message (this happens when
> isearch-edit-string sets a different value) then it uses this value
> for succ-msg.
I discovered another problem that requires a different fix.
`C-s foo M-r' (in a buffer without this text) completely discards the
failed part and doesn't display it.
The best fix for this and related problems is to always keep the
original isearch-message intact, and just to add text properties to it.
The patch below also fixed another problem. `C-M-s [a-z]' (typed
in the empty buffer) highlights as failed part only the closing bracket.
This patch uses `isearch-error' to highlight the whole `[a-z]' part:
Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.310
diff -c -r1.310 isearch.el
*** lisp/isearch.el 12 Feb 2008 00:50:44 -0000 1.310
--- lisp/isearch.el 24 Feb 2008 17:28:43 -0000
***************
*** 1959,1980 ****
(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)))))
(defun isearch-message-prefix (&optional c-q-hack ellipsis nonincremental)
;; If about to search, and previous search regexp was invalid,
--- 1979,2006 ----
(defun isearch-message (&optional c-q-hack ellipsis)
;; Generate and print the message string.
(let ((cursor-in-echo-area ellipsis)
! (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,
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2008-02-24 17:29 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-10 3:03 highlight failed part of isearch input Drew Adams
2007-07-10 13:21 ` Juri Linkov
2007-07-10 14:19 ` Drew Adams
2007-07-10 23:22 ` Juri Linkov
2007-07-11 0:16 ` Drew Adams
2007-07-11 3:57 ` Stefan Monnier
2007-07-11 5:27 ` David Kastrup
2007-07-11 6:18 ` Stefan Monnier
2007-07-11 6:26 ` Miles Bader
2007-07-11 7:14 ` Stefan Monnier
2007-07-11 7:15 ` David Kastrup
2007-07-11 16:10 ` Drew Adams
2007-07-11 19:20 ` Robert J. Chassell
2007-07-11 21:14 ` Drew Adams
2007-07-11 23:17 ` Juri Linkov
2007-07-12 13:01 ` Robert J. Chassell
[not found] ` <E1I968h-0002xA-VO@fencepost.gnu.org>
2007-07-12 23:16 ` Juri Linkov
2007-07-13 18:38 ` Richard Stallman
2007-07-14 23:05 ` Juri Linkov
2007-07-15 22:53 ` Richard Stallman
2007-07-23 4:27 ` Richard Stallman
2007-07-14 23:07 ` Juri Linkov
2007-07-15 22:53 ` Richard Stallman
2007-07-12 21:24 ` Richard Stallman
2007-07-11 21:03 ` Richard Stallman
2007-07-11 21:15 ` Drew Adams
2007-07-10 14:07 ` Masatake YAMATO
2007-07-10 14:37 ` ding susceptibility (was: highlight failed part of isearch input) Drew Adams
2007-07-10 22:01 ` highlight failed part of isearch input Richard Stallman
2007-07-10 14:32 ` Stefan Monnier
2007-07-10 22:01 ` Richard Stallman
2007-07-22 23:40 ` Drew Adams
2007-07-23 18:06 ` Richard Stallman
2007-07-23 21:29 ` Juri Linkov
2007-07-23 22:37 ` Drew Adams
2007-07-23 23:33 ` Juri Linkov
2007-07-24 2:22 ` Drew Adams
2007-07-24 22:16 ` Richard Stallman
2007-07-24 16:45 ` Richard Stallman
2007-07-24 17:25 ` Drew Adams
2008-02-11 23:31 ` Drew Adams
2008-02-12 0:18 ` Juri Linkov
2008-02-12 0:36 ` Drew Adams
2008-02-12 0:54 ` Bastien
2008-02-16 19:18 ` Juri Linkov
2008-02-23 19:47 ` Juri Linkov
2008-02-23 21:27 ` Drew Adams
2008-02-23 21:55 ` Juri Linkov
2008-02-23 23:12 ` Drew Adams
2008-02-24 17:32 ` Juri Linkov
2008-02-24 23:15 ` Drew Adams
2008-02-25 0:01 ` Juri Linkov
2008-02-25 7:59 ` Bastien
2008-02-24 23:31 ` Dan Nicolaescu
2008-02-24 23:47 ` Drew Adams
2008-02-24 23:58 ` Dan Nicolaescu
2008-02-25 0:00 ` Jason Rumney
2008-02-25 0:12 ` Drew Adams
2008-02-25 0:17 ` Juri Linkov
2008-02-24 17:29 ` Juri Linkov [this message]
2008-02-24 23:05 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oda6e614.fsf@jurta.org \
--to=juri@jurta.org \
--cc=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).