all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Chong Yidong" <cyd@stupidchicken.com>
Subject: Re: search-whitespace-regexp
Date: Fri, 4 Feb 2005 10:55:05 -0500 (EST)	[thread overview]
Message-ID: <2252.219.74.2.152.1107532505.squirrel@219.74.2.152> (raw)
In-Reply-To: <jwvis589x4t.fsf-monnier+emacs@gnu.org>

> 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.

How about this revised patch?

*** isearch.el~	Fri Feb  4 19:33:15 2005
--- isearch.el	Fri Feb  4 23:47:15 2005
***************
*** 109,122 ****
    :type 'boolean
    :group 'isearch)

! (defcustom search-whitespace-regexp "\\s-+"
    "*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 `]+'."
    :type 'regexp
    :group 'isearch)

--- 109,124 ----
    :type 'boolean
    :group 'isearch)

! (defcustom search-whitespace-regexp nil
    "*If non-nil, regular expression to match a sequence of whitespace chars.
! When you put a space or spaces in the incremental search string,
! it will be replaced with this regular expression when searching.
! This applies to `isearch-forward' and `isearch-backward', but not
! the regular expression searches `isearch-forward-regexp' and
! `isearch-backward-regexp'. You might want to use something like
! \"[ \\t\\r\\n]+\". In the Customization buffer, that is `['
! followed by a space, a tab, a carriage return (control-M), a
! newline, and `]+'."
    :type 'regexp
    :group 'isearch)

***************
*** 514,519 ****
--- 516,525 ----
  With a prefix argument, do an incremental regular expression search
instead.
  \\<isearch-mode-map>
  As you type characters, they add to the search string and are found.
+
+ If `search-whitespace-regexp' is non-nil, any space or spaces
+ entered are replaced with that regular expression when searching.
+
  The following non-printing keys are bound in `isearch-mode-map'.

  Type \\[isearch-delete-char] to cancel last input item from end of
search string.
***************
*** 573,584 ****
  Do incremental search forward for regular expression.
  With a prefix argument, do a regular string search instead.
  Like ordinary incremental search except that your input
! is treated as a regexp.  See \\[isearch-forward] for more info.
!
! In regexp incremental searches, a space or spaces normally matches
! any whitespace (the variable `search-whitespace-regexp' controls
! precisely what that means).  If you want to search for a literal space
! and nothing else, enter `[ ]'."
    (interactive "P\np")
    (isearch-mode t (null not-regexp) nil (not no-recursive-edit)))

--- 579,585 ----
  Do incremental search forward for regular expression.
  With a prefix argument, do a regular string search instead.
  Like ordinary incremental search except that your input
! is treated as a regexp.  See \\[isearch-forward] for more info."
    (interactive "P\np")
    (isearch-mode t (null not-regexp) nil (not no-recursive-edit)))

***************
*** 2029,2035 ****
       (isearch-regexp
        (if isearch-forward 're-search-forward 're-search-backward))
       (t
!       (if isearch-forward 'search-forward 'search-backward)))))

  (defun isearch-search ()
    ;; Do the search with the current search string.
--- 2030,2045 ----
       (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)
!   (let ((search-spaces-regexp search-whitespace-regexp))
!     (re-search-forward (regexp-quote string) bound noerror count)))
!
! (defun isearch-search-backward (string &optional bound noerror count)
!   (let ((search-spaces-regexp search-whitespace-regexp))
!     (re-search-backward (regexp-quote string) bound noerror count)))

  (defun isearch-search ()
    ;; Do the search with the current search string.
***************
*** 2041,2047 ****
        (let ((inhibit-point-motion-hooks search-invisible)
  	    (inhibit-quit nil)
  	    (case-fold-search isearch-case-fold-search)
- 	    (search-spaces-regexp search-whitespace-regexp)
  	    (retry t))
  	(if isearch-regexp (setq isearch-invalid-regexp nil))
  	(setq isearch-within-brackets nil)
--- 2051,2056 ----
***************
*** 2377,2384 ****
  (defun isearch-lazy-highlight-search ()
    "Search ahead for the next or previous match, for lazy highlighting.
  Attempt to do the search exactly the way the pending isearch would."
!   (let ((case-fold-search isearch-case-fold-search)
! 	(search-spaces-regexp search-whitespace-regexp))
      (funcall (isearch-search-fun)
               isearch-string
               (if isearch-forward
--- 2386,2392 ----
  (defun isearch-lazy-highlight-search ()
    "Search ahead for the next or previous match, for lazy highlighting.
  Attempt to do the search exactly the way the pending isearch would."
!   (let ((case-fold-search isearch-case-fold-search))
      (funcall (isearch-search-fun)
               isearch-string
               (if isearch-forward

  reply	other threads:[~2005-02-04 15:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-04 14:12 search-whitespace-regexp Chong Yidong
2005-02-04 14:36 ` search-whitespace-regexp Andreas Schwab
2005-02-04 15:22   ` search-whitespace-regexp Chong Yidong
2005-02-04 15:27   ` search-whitespace-regexp Chong Yidong
2005-02-04 15:17 ` search-whitespace-regexp Stefan Monnier
2005-02-04 15:55   ` Chong Yidong [this message]
2005-02-05 17:39 ` search-whitespace-regexp Richard Stallman
2005-02-06  1:59   ` search-whitespace-regexp Chong Yidong
2005-02-06 12:42     ` search-whitespace-regexp Richard Stallman
2005-02-06 16:21     ` search-whitespace-regexp Stefan Monnier
2005-02-06 22:39       ` search-whitespace-regexp Miles Bader
2005-02-06 22:49         ` search-whitespace-regexp Stefan Monnier
2005-02-06 23:17           ` search-whitespace-regexp Miles Bader
2005-02-07  0:28             ` search-whitespace-regexp Drew Adams
2005-02-07  0:41               ` search-whitespace-regexp Miles Bader
2005-02-07  1:36                 ` search-whitespace-regexp Chong Yidong
2005-02-07  4:12                   ` search-whitespace-regexp Drew Adams
2005-02-07  9:48                 ` search-whitespace-regexp Andreas Schwab
2005-02-07 20:51                 ` search-whitespace-regexp Richard Stallman
2005-02-07 20:51       ` search-whitespace-regexp Richard Stallman
2005-02-07 21:07         ` search-whitespace-regexp Stefan Monnier
2005-02-08  0:01           ` search-whitespace-regexp Miles Bader

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=2252.219.74.2.152.1107532505.squirrel@219.74.2.152 \
    --to=cyd@stupidchicken.com \
    /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.