[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16546: C-s vs. whitespace highlighting
From: |
Juri Linkov |
Subject: |
bug#16546: C-s vs. whitespace highlighting |
Date: |
Mon, 27 Jan 2014 11:21:27 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) |
> 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.
- bug#16546: C-s vs. whitespace highlighting, jidanni, 2014/01/25
- bug#16546: C-s vs. whitespace highlighting, Bastien, 2014/01/25
- bug#16546: C-s vs. whitespace highlighting, Dani Moncayo, 2014/01/25
- bug#16546: C-s vs. whitespace highlighting, Nicolas Richard, 2014/01/26
- bug#16546: C-s vs. whitespace highlighting, Dani Moncayo, 2014/01/27
- bug#16546: C-s vs. whitespace highlighting, martin rudalics, 2014/01/27
- bug#16546: C-s vs. whitespace highlighting, Dani Moncayo, 2014/01/27
- bug#16546: C-s vs. whitespace highlighting,
Juri Linkov <=
- bug#16546: C-s vs. whitespace highlighting, Dani Moncayo, 2014/01/27
- bug#16546: C-s vs. whitespace highlighting, Juri Linkov, 2014/01/28
bug#16546: C-s vs. whitespace highlighting, jidanni, 2014/01/25