From: Juri Linkov <juri@jurta.org>
To: Dani Moncayo <dmoncayo@gmail.com>
Cc: Bastien <bzg@altern.org>,
16546@debbugs.gnu.org,
Nicolas Richard <theonewiththeevillook@yahoo.fr>,
Dan Jacobson <jidanni@jidanni.org>
Subject: bug#16546: C-s vs. whitespace highlighting
Date: Mon, 27 Jan 2014 11:21:27 +0200 [thread overview]
Message-ID: <87vbx53hke.fsf@mail.jurta.org> (raw)
In-Reply-To: <CAH8Pv0gqkUnsnjzY-HqGM-RfeuNaxdT-Ub5hO8W9L0KCV2TdJA@mail.gmail.com> (Dani Moncayo's message of "Mon, 27 Jan 2014 08:50:52 +0100")
> IMO, that behavior would make sense only when the whitespace chars are
> entered interactively (i.e. typed on the keyboard), because if the
> search string comes from another place (copy&paste, grabbed from the
> buffer, ...), I don't think it would be a good idea to temporarily set
> `search-whitespace-regexp' to nil. And BTW, that reasoning applies
> equally to case-fold-search.
I agree that when the user types several spaces in a row explicitly
then spaces should be treated as intended by the user.
Actually, whitespace search already does this in regexp mode.
Relevant lines from regex.c:
/* If the spaces are followed by a repetition op,
treat them normally. */
if (p1 != pend
&& (*p1 == '*' || *p1 == '+' || *p1 == '?'
|| (*p1 == '\\' && p1 + 1 != pend && p1[1] == '{')))
goto normal_char;
This means that when the user types ` +' then `search-whitespace-regexp'
is ignored. I think the same should be implemented for a non-regexp search
as well, so typing ` ' will transform the input to ` +' and ignored.
> IOW, if I copy some text "foo<any-whitespace>bar" from one place and
> then go to Emacs and do "C-s C-y", I definitely want a "lax" search
> wrt whitespace.
Indeed.
> At least, that behavior should be configurable, IMO.
For better configurability I'm using such implementation:
(defun search-forward-lax-whitespace (string &optional bound noerror count)
(re-search-forward (search-whitespace-regexp (regexp-quote string)) bound noerror count))
(defun search-backward-lax-whitespace (string &optional bound noerror count)
(re-search-backward (search-whitespace-regexp (regexp-quote string)) bound noerror count))
(defun re-search-forward-lax-whitespace (regexp &optional bound noerror count)
(re-search-forward (search-whitespace-regexp regexp) bound noerror count))
(defun re-search-backward-lax-whitespace (regexp &optional bound noerror count)
(re-search-backward (search-whitespace-regexp regexp) bound noerror count))
where in `search-whitespace-regexp' you can do any whitespace handling.
next prev parent reply other threads:[~2014-01-27 9:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-25 9:49 bug#16546: C-s vs. whitespace highlighting jidanni
2014-01-25 13:46 ` Bastien
2014-01-25 14:17 ` Dani Moncayo
2014-01-26 21:46 ` Nicolas Richard
2014-01-26 22:32 ` Bastien
2014-01-27 2:16 ` Stefan Monnier
2014-01-27 7:09 ` Bastien
2014-01-27 7:50 ` Dani Moncayo
2014-01-27 8:21 ` martin rudalics
2014-01-27 8:35 ` Dani Moncayo
2014-01-27 9:21 ` Juri Linkov [this message]
2014-01-27 9:55 ` Dani Moncayo
2014-01-28 7:30 ` Juri Linkov
2014-01-25 14:23 ` jidanni
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=87vbx53hke.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=16546@debbugs.gnu.org \
--cc=bzg@altern.org \
--cc=dmoncayo@gmail.com \
--cc=jidanni@jidanni.org \
--cc=theonewiththeevillook@yahoo.fr \
/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.