[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: can't tell if one is searching with appended whitespace
From: |
Juri Linkov |
Subject: |
Re: can't tell if one is searching with appended whitespace |
Date: |
Mon, 07 Jun 2004 09:35:02 +0300 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
Kevin Rodgers <address@hidden> writes in bug-gnu-emacs:
> Dan Jacobson wrote:
> > Gentlemen, looking in the minibuffer, how can you tell the difference
> between
> > I-search: bla
> > and
> > I-search: bla
> > Therefore, something must be done about it.
> > Why, one could miss important stuff if one doesn't realize he is
> > carrying around an appended blank in his search string!
> > Perhaps do something with color, or a " $" appearing, or turn on
> > show-trailing-whitespace in the minibuffer by default.
> > (setq-default show-trailing-whitespace t in .emacs isn't good enough.)
>
> That may be because trailing whitespace is not highlighted when point is
> at the end of a line in any buffer, even if the line is terminated by a
> newline (and thus there is at least 1 [possibly empty] subsequent line).
>
> Or perhaps that point is moot, because isearch.el displays the search
> string in the echo area, not in the minibuffer (if so, perhaps the
> message function should be changed to respect show-trailing-whitespace).
I suspect it would be very annoying when trailing whitespace will be
highlighted in all messages. But highlighting it only in failed
isearch (i.e. in the message "Failing I-search: ...") may be good.
Or another solution is to add explicit text about whitespace as the
suffix of the failed string. I included both solutions below:
Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.228
diff -u -r1.228 isearch.el
--- lisp/isearch.el 6 Jun 2004 13:57:39 -0000 1.228
+++ lisp/isearch.el 7 Jun 2004 00:29:14 -0000
@@ -1764,7 +1786,13 @@
(let ((cursor-in-echo-area ellipsis)
(m (concat
(isearch-message-prefix c-q-hack ellipsis isearch-nonincremental)
- isearch-message
+ (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
@@ -1806,7 +1834,10 @@
(concat (if c-q-hack "^Q" "")
(if isearch-invalid-regexp
(concat " [" isearch-invalid-regexp "]")
- "")))
+ "")
+ (if (and (not isearch-success)
+ (string-match " $" isearch-message))
+ "[whitespace]")))
;; Searching
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: can't tell if one is searching with appended whitespace,
Juri Linkov <=