* isearch magic space
@ 2005-03-15 11:14 Chong Yidong
2005-03-15 13:09 ` Juri Linkov
2005-03-18 3:18 ` Miles Bader
0 siblings, 2 replies; 5+ messages in thread
From: Chong Yidong @ 2005-03-15 11:14 UTC (permalink / raw)
Some time ago, I proposed providing a magic space for ordinary isearch.
The response was generally favorable, but my papers were not in order, so
the patch could not be applied. My copyright assignment is settled now;
can the patch be applied, or is it too late?
*** emacs/lisp/isearch.el~ Tue Mar 15 19:06:42 2005
--- emacs/lisp/isearch.el Tue Mar 15 19:15:49 2005
***************
*** 109,114 ****
--- 109,123 ----
:type 'boolean
:group 'isearch)
+ (defcustom search-string-whitespace-regexp "[ \t\r\n]+"
+ "*If non-nil, regular expression to match a sequence of whitespace chars.
+ This applies to ordinary (string) 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 ?."
+ :type 'regexp
+ :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.
***************
*** 2027,2033 ****
(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.
--- 2036,2051 ----
(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-string-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-string-whitespace-regexp))
! (re-search-backward (regexp-quote string) bound noerror count)))
(defun isearch-search ()
;; Do the search with the current search string.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: isearch magic space
2005-03-15 11:14 isearch magic space Chong Yidong
@ 2005-03-15 13:09 ` Juri Linkov
2005-03-15 15:00 ` Chong Yidong
2005-03-18 3:18 ` Miles Bader
1 sibling, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2005-03-15 13:09 UTC (permalink / raw)
Cc: emacs-devel
"Chong Yidong" <cyd@stupidchicken.com> writes:
> Some time ago, I proposed providing a magic space for ordinary isearch.
> The response was generally favorable, but my papers were not in order, so
> the patch could not be applied. My copyright assignment is settled now;
> can the patch be applied, or is it too late?
I like the idea of using a space to match any whitespace in plain
non-regexp isearch. However, it should be nil by default to preserve
the default behavior for users who don't expect such a change.
Also there should be an easy way to put a literal space into the
search string. In regexp isearch this can be done with C-q SPC.
One solution is to allow `search-whitespace-regexp' to be a list of
regexps and a new key could rotate this list and search will use
the first element. I noticed that in most cases as the whitespace
regexp "\\W+" is more useful than "\\s-+". So a new key could use
the default values '(nil "\\s-+" "\\W+") and switch between them.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: isearch magic space
2005-03-15 13:09 ` Juri Linkov
@ 2005-03-15 15:00 ` Chong Yidong
2005-03-15 15:05 ` Chong Yidong
0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2005-03-15 15:00 UTC (permalink / raw)
Cc: emacs-devel
> I like the idea of using a space to match any whitespace in plain
> non-regexp isearch. However, it should be nil by default to preserve
> the default behavior for users who don't expect such a change.
That is fine.
> Also there should be an easy way to put a literal space into the
> search string. In regexp isearch this can be done with C-q SPC.
It is actually easy to extend this to string search, by making an
additional small tweak to isearch-quote-char:
*** 1768,1774 ****
;; Assume character codes 0200 - 0377 stand for characters in some
;; single-byte character set, and convert them to Emacs
;; characters.
! (if (and isearch-regexp (= char ?\ ))
(if (subregexp-context-p isearch-string (length isearch-string))
(isearch-process-search-string "[ ]" " ")
(isearch-process-search-char char))
--- 1777,1783 ----
;; Assume character codes 0200 - 0377 stand for characters in some
;; single-byte character set, and convert them to Emacs
;; characters.
! (if (and (not isearch-word) (= char ?\ ))
(if (subregexp-context-p isearch-string (length isearch-string))
(isearch-process-search-string "[ ]" " ")
(isearch-process-search-char char))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: isearch magic space
2005-03-15 11:14 isearch magic space Chong Yidong
2005-03-15 13:09 ` Juri Linkov
@ 2005-03-18 3:18 ` Miles Bader
1 sibling, 0 replies; 5+ messages in thread
From: Miles Bader @ 2005-03-18 3:18 UTC (permalink / raw)
Cc: emacs-devel
On Tue, 15 Mar 2005 06:14:13 -0500 (EST), Chong Yidong
<cyd@stupidchicken.com> wrote:
> Some time ago, I proposed providing a magic space for ordinary isearch.
> The response was generally favorable, but my papers were not in order, so
> the patch could not be applied. My copyright assignment is settled now;
> can the patch be applied, or is it too late?
Whatever the case, I think it should default to off.
-miles
--
Do not taunt Happy Fun Ball.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-03-18 3:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-15 11:14 isearch magic space Chong Yidong
2005-03-15 13:09 ` Juri Linkov
2005-03-15 15:00 ` Chong Yidong
2005-03-15 15:05 ` Chong Yidong
2005-03-18 3:18 ` Miles Bader
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.