unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* RE: emacs 22 - regular-expression isearch on spaces extremely lenient
       [not found] <2cd46e7f0604281356i582388e2kef07922b6b6a9a3a@mail.gmail.com>
@ 2006-04-29 14:41 ` Drew Adams
  2006-04-29 17:23   ` Eric Hanchrow
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2006-04-29 14:41 UTC (permalink / raw)
  Cc: Emacs-Devel

    i recently started noticing that emacs 22 regular expression isearches
    do not treat spaces exactly - any number of spaces in your search will
    map to any number, same or different, of spaces in the target.

    can anyone tell me whether or not it's deliberate, and what the
    rationale is?

(setq search-whitespace-regexp nil) will turn this off. When this is nil,
each space you type matches literally, against one space.

`search-whitespace-regexp' is, by default, "\\s-+", which searches for any
amount of whitespace when you type a space. This was introduced for regexp
search in Emacs 21, I believe. There is no such "magic-space" searching in
Emacs 20. Doc:

 If non-nil, regular expression to match a sequence of whitespace chars.
 This applies to regular expression incremental search.
 When you put a space or spaces in the incremental regexp, it stands for
 this, unless it is inside of a regexp construct such as [...] or *, + or ?.
 You might want to use something like "[ \t\r\n]+" instead.
 In the Customization buffer, that is `[' followed by a space,
 a tab, a carriage return (control-M), a newline, and `]+'.

The rationale was, I believe, that some users might want that: type space to
find any amount of whitespace, in particular, to find two words that are
separated by a newline.

There was talk of using this "magic-space" searching also for plain
incremental search in Emacs 22, but I don't think that was done.

FWIW, I agree with Miles on this - this is a misfeature, if turned on by
default. It should be off by default, and you should be able to turn it on
via a simple toggle during incremental search (regexp or plain).

Here is what I wrote 2005/02/06 to emacs-devel on this:

            > > sometimes the actual whitespace matters.
            > Right: in *regexp* search.
          while people generally expect regexp searches to be a bit
          fuzzy, they might expect a non-regexp search to be exact.
          Since the fuzzy whitespace matching often "looks" like normal
          matching (because the majority of whitespace is in fact a
          single space), it might take some time to see what's going on,
          resulting in some subtle errors. This is particularly true if
          one embeds a search inside a keyboard macro [which I often do].

    Plain (incremental) search should be a literal search. Regexp
    search should rigorously respect the regexp. People don't expect
    either to be fuzzy.

    The question is "Under what circumstances should typing a space be
    interpreted as wanting to search for any amount of whitespace?"

    This is unrelated to both plain search and regexp search. You
    might or might not want this _input effect_ with either plain
    or regexp search.

    This is akin to word search (as I think someone mentioned).
    Ultimately, a word search or a space-means-whitespace search is
    implemented with a regexp search - but the point in both cases
    is to provide a user-friendly way to do it, instead of requiring
    users to know about regexps.

    By default, neither `C-M-s' nor `C-s' should respect the
    user-friendly space-input feature. Or, rather, the default
    behavior of each should be determined by a user option - a la
    case-fold-search. And, regardless of the value of this option,
    you should be able to toggle space-means-whitespace
    searching from both `C-M-s' and `C-s', via a key sequence.

    The question then becomes how to toggle this space-means-whitespace
    searching?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: emacs 22 - regular-expression isearch on spaces extremely lenient
       [not found] <u7j58xvhh.fsf@comcast.net>
@ 2006-04-29 16:14 ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2006-04-29 16:14 UTC (permalink / raw)
  Cc: don provan

Fwding to emacs-devel. They are the ones who can change this behavior or
perhaps make the user option move visible somehow.

    To: help-gnu-emacs@gnu.org
    > (setq search-whitespace-regexp nil) will turn this off. When
    > this is nil, each space you type matches literally, against
    > one space.

    Thanks! This always annoyed me, but I've never seen a mention of the
    control variable to turn it off.

    >  If non-nil, regular expression to match a sequence of
    >  whitespace chars. This applies to regular expression
    >  incremental search.

    I think the biggest problem with it is the inconsistency between
    incremental search and elisp regexp searches. Literally just yesterday
    I had to debug a problem caused because my practice regexp at the
    command line did what I wanted with a space, but when I used the same
    string in a functional search, it didn't. I've seen the documentation
    for this feature, but wherever it was, it wasn't clear to me until now
    that it was specific to incremental regexp searches rather than a
    general feature of all regexp searches.

    -don

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: emacs 22 - regular-expression isearch on spaces extremely lenient
  2006-04-29 14:41 ` emacs 22 - regular-expression isearch on spaces extremely lenient Drew Adams
@ 2006-04-29 17:23   ` Eric Hanchrow
  2006-05-01 14:51     ` Kevin Rodgers
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Hanchrow @ 2006-04-29 17:23 UTC (permalink / raw)
  Cc: help-gnu-emacs

>>>>> "Drew" == Drew Adams <drew.adams@oracle.com> writes:

    Drew>     The question then becomes how to toggle this
    Drew>     space-means-whitespace searching?

I haven't the slightest idea how to toggle it, which of course is the
important question.  But I do have an idea: for regexp searches, if
while I'm typing my regexp, and I type a space, and this feature is
on, it'd be lovely if Emacs would simply insert the appropriate regexp
for whitespace -- such as \s-+ -- into the mini-buffer.  That way I
will learn a bit more about regexps.

-- 

            |\      _,,,---,,_
      ZZZzz /,`.-'`'    -.  ;-;;,_
           |,4-  ) )-,_. ,\ (  `'-'
          '---''(_/--'  `-'\_) fL

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: emacs 22 - regular-expression isearch on spaces extremely lenient
  2006-04-29 17:23   ` Eric Hanchrow
@ 2006-05-01 14:51     ` Kevin Rodgers
  2006-05-02  2:04       ` Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2006-05-01 14:51 UTC (permalink / raw)
  Cc: help-gnu-emacs

Eric Hanchrow wrote:
>>>>>> "Drew" == Drew Adams <drew.adams@oracle.com> writes:
> 
>     Drew>     The question then becomes how to toggle this
>     Drew>     space-means-whitespace searching?
> 
> I haven't the slightest idea how to toggle it, which of course is the
> important question.  But I do have an idea: for regexp searches, if
> while I'm typing my regexp, and I type a space, and this feature is
> on, it'd be lovely if Emacs would simply insert the appropriate regexp
> for whitespace -- such as \s-+ -- into the mini-buffer.  That way I
> will learn a bit more about regexps.

Excellent suggestion!

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: emacs 22 - regular-expression isearch on spaces extremely lenient
  2006-05-01 14:51     ` Kevin Rodgers
@ 2006-05-02  2:04       ` Richard Stallman
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2006-05-02  2:04 UTC (permalink / raw)
  Cc: help-gnu-emacs, emacs-devel

    > I haven't the slightest idea how to toggle it, which of course is the
    > important question.  But I do have an idea: for regexp searches, if
    > while I'm typing my regexp, and I type a space, and this feature is
    > on, it'd be lovely if Emacs would simply insert the appropriate regexp
    > for whitespace -- such as \s-+ -- into the mini-buffer.  That way I
    > will learn a bit more about regexps.

That could help clarify matters for some users, but it could be
confusing for other users.

That space in regexp i-search matches all whitespace is not a new
feature.  We have only changed the way it is implemented, to make
quoting spaces more reliable.  So I see no urgent need to change this.

But I would not mind adding an option to make SPC echo as some other
string in regexp i-search.  Then, after the release, we could
ask users to try turning it on and say whether they like it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-02  2:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <2cd46e7f0604281356i582388e2kef07922b6b6a9a3a@mail.gmail.com>
2006-04-29 14:41 ` emacs 22 - regular-expression isearch on spaces extremely lenient Drew Adams
2006-04-29 17:23   ` Eric Hanchrow
2006-05-01 14:51     ` Kevin Rodgers
2006-05-02  2:04       ` Richard Stallman
     [not found] <u7j58xvhh.fsf@comcast.net>
2006-04-29 16:14 ` Drew Adams

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).