emacs-devel
[Top][All Lists]
Advanced

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

Re: search-whitespace-regexp


From: Stefan Monnier
Subject: Re: search-whitespace-regexp
Date: Fri, 04 Feb 2005 10:17:14 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

> --- 2023,2043 ----
>        (isearch-regexp
>         (if isearch-forward 're-search-forward 're-search-backward))
>        (t
> !       (if isearch-forward 'isearch-search-forward
> 'isearch-search-backward)))))
> !
> ! (defun isearch-search-forward (string &optional bound noerror count)
> !   (re-search-forward
> !    (if search-whitespace-regexp
> !        (replace-regexp-in-string " +" search-whitespace-regexp string)
> !      string)
> !    bound noerror count))
> !
> ! (defun isearch-search-backward (string &optional bound noerror count)
> !   (re-search-backward
> !    (if search-whitespace-regexp
> !        (replace-regexp-in-string " +" search-whitespace-regexp string)
> !      string)
> !    bound noerror count))

I generally agree with your proposal to change the behavior of isearch such
that only plain search uses a "magical space", whereas regexp search is made
more "raw".  But the above code is wrong in that it fails to quote
chars like "[" in the search string.

You probably want to use something like

  (re-search-forward (mapconcat 'regexp-quote
                                (split-string string)
                                search-whitespace-regexp)
                     bound noerror count)

instead,


        Stefan




reply via email to

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