all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Subject: Re: can't tell if one is searching with appended whitespace
Date: Mon, 07 Jun 2004 09:35:02 +0300	[thread overview]
Message-ID: <87wu2kw5tt.fsf@mail.jurta.org> (raw)
In-Reply-To: <40C0EC47.10707@yahoo.com> (Kevin Rodgers's message of "Fri, 04 Jun 2004 15:40:23 -0600")

Kevin Rodgers <ihs_4664@yahoo.com> 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]")))
 
 \f
 ;; Searching

-- 
Juri Linkov
http://www.jurta.org/emacs/

  reply	other threads:[~2004-06-07  6:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-03 20:42 can't tell if one is searching with appended whitespace Dan Jacobson
2004-06-04 21:40 ` Kevin Rodgers
2004-06-07  6:35   ` Juri Linkov [this message]
2004-06-07 19:17     ` Richard Stallman

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wu2kw5tt.fsf@mail.jurta.org \
    --to=juri@jurta.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.