[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interpretation of a space in regexp isearch?

From: Juri Linkov
Subject: Re: Interpretation of a space in regexp isearch?
Date: Wed, 29 Aug 2012 01:54:18 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu)

> I have other things to do, so I haven't participated in this thread,
> but FWIW, I think that search-whitespace-regexp is not something that
> should be used by default.

Ignoring whitespace in isearch is a very useful feature.
But I agree that its current implementation is far from optimal.

It would be better to reimplement it in isearch exactly the same way
as `isearch-word' is implemented because these two are similar features.

A new `isearch-whitespace' toggled by `M-s SPC' could construct a regexp
like in `word-search-regexp' and search it with `re-search-forward' in
`isearch-search-fun-default'.  This will provide flexibility to solve
related problems.

To make this feature less "magic" and surprising to users,
it could reveal a constructed regexp after switching from ordinary
isearch mode to regexp mode.  As well as after switching from word mode
to regexp mode could also reveal the regexp used to search words
ignoring punctuation.

Another variant to implement `isearch-toggle-whitespace' is like
`isearch-toggle-case-fold' that changes the value of the internal
variable `case-fold-search' effective to both regexp and non-regexp
searches.  But I don't know how difficult is to modify the
search engine to ignore whitespace the same way as it ignores case
using translation tables.

Regarding the need to quote literal spaces in non-regexp search,
one example of possible solution is HTML that uses "nobr"
for essential whitespace that should not be ignored.
Doing the same in isearch for `C-q SPC' would insert "no-break space"
to the search string.  Then repeating a non-regexp search
from the search ring will correctly interpret it as a literal space
(as opposed to the normal space character interpreted as whitespace pattern).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]