From: Juri Linkov <juri@jurta.org>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: Stefan Monnier <monnier@IRO.UMontreal.CA>, emacs-devel@gnu.org
Subject: Re: word search (Re: isearch in Dired)
Date: Thu, 31 Jul 2008 15:35:59 +0300 [thread overview]
Message-ID: <878wvicjtk.fsf@jurta.org> (raw)
In-Reply-To: <87myjz8ggy.fsf@jurta.org> (Juri Linkov's message of "Wed, 30 Jul 2008 19:50:33 +0300")
>> Looks OK to me. Please check it in ASAP, and don't forget to write a
>> NEWS entry, and to document the keybinding in the docstring of
>> `isearch'.
>
> Done.
Actually incremental word search is useless. While typing a sequence of
words, incremental word search advances forward through false positives
and failures because it tries to match on all incomplete word boundaries.
When the user finishes typing a complete sequence of words, the current
match may skip some matches from the starting point. So this behavior
makes more harm!
What is necessary instead is reading a sequence of words in the minibuffer,
starting Isearch on the entered words, and using C-s or C-r to find next or
previous word occurrences. This is essentially what currently a clumsy trick
`C-s M-e C-w' tries to do. But it is better to put this feature on `M-s w'.
This was already discussed in March 2008, and Stefan agreed to this change
but Richard worried about eliminating the C-w word-search feature.
So I propose to display a warning after typing C-w in the isearch-edit-string
minibuffer that this feature is obsolete and suggest using `M-s w' instead
for the upcoming release. After this release, we can eliminate it completely
or replace with word-yanking.
The following patch does this, and also binds `M-s w' to a new command that
starts Isearch with reading a sequence of words in the minibuffer. This
feature is useful for regexp Isearch as well because often it is distracting
to see warnings "incomplete input" while typing a complex regexp in Isearch
mode. So it binds `M-s r' to a similar command that reads a regexp in the
minibuffer and starts Isearch with it.
This is the last patch I submit before the feature freeze, and I think
it is important to install it now.
Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.325
diff -c -r1.325 isearch.el
*** lisp/isearch.el 30 Jul 2008 16:40:23 -0000 1.325
--- lisp/isearch.el 31 Jul 2008 12:35:35 -0000
***************
*** 509,514 ****
--- 509,515 ----
(define-key map "\M-\t" 'isearch-complete-edit)
(define-key map "\C-s" 'isearch-forward-exit-minibuffer)
(define-key map "\C-r" 'isearch-reverse-exit-minibuffer)
+ (define-key map "\C-w" 'isearch-edit-string-set-word)
(define-key map "\C-f" 'isearch-yank-char-in-minibuffer)
(define-key map [right] 'isearch-yank-char-in-minibuffer)
map)
***************
*** 599,605 ****
(define-key esc-map "\C-s" 'isearch-forward-regexp)
(define-key global-map "\C-r" 'isearch-backward)
(define-key esc-map "\C-r" 'isearch-backward-regexp)
! (define-key search-map "w" 'isearch-forward-word)
;; Entry points to isearch-mode.
--- 600,607 ----
(define-key esc-map "\C-s" 'isearch-forward-regexp)
(define-key global-map "\C-r" 'isearch-backward)
(define-key esc-map "\C-r" 'isearch-backward-regexp)
! (define-key search-map "r" 'isearch-edit-regexp-search)
! (define-key search-map "w" 'isearch-edit-word-search)
;; Entry points to isearch-mode.
***************
*** 693,708 ****
(interactive "P\np")
(isearch-mode t (null not-regexp) nil (not no-recursive-edit)))
- (defun isearch-forward-word (&optional not-word no-recursive-edit)
- "\
- Do incremental search forward for a sequence of words.
- With a prefix argument, do a regular string search instead.
- Like ordinary incremental search except that your input
- is treated as a sequence of words without regard to how the
- words are separated. See \\[isearch-forward] for more info."
- (interactive "P\np")
- (isearch-mode t nil nil (not no-recursive-edit) (null not-word)))
-
(defun isearch-backward (&optional regexp-p no-recursive-edit)
"\
Do incremental search backward.
***************
*** 715,725 ****
(interactive "P\np")
(isearch-mode nil (null not-regexp) nil (not no-recursive-edit)))
+ (defun isearch-edit-regexp-search ()
+ "Read regular expression and do incremental search on input.
+ It reads regular expression in the minibuffer, and after exiting minibuffer
+ with RET, C-s or C-r, Isearch starts incremental search with the entered
+ regular expression. See the command `isearch-forward' for more information."
+ (interactive)
+ (isearch-mode t t nil nil)
+ (isearch-edit-string))
+
+ (defun isearch-edit-word-search ()
+ "Read sequence of words and do incremental search on input.
+ It reads words in the minibuffer, and after exiting minibuffer
+ with RET, C-s or C-r, Isearch starts incremental search with
+ entered words without regard to how the words are separated.
+ See the command `isearch-forward' for more information."
+ (interactive)
+ (isearch-mode t nil nil nil t)
+ (isearch-edit-string))
+
\f
;; isearch-mode only sets up incremental search for the minor mode.
;; All the work is done by the isearch-mode commands.
***************
*** 1111,1141 ****
;; that can change their values.
(setq old-point (point) old-other-end isearch-other-end)
- (isearch-message) ;; for read-char
(unwind-protect
! (let* (;; Why does following read-char echo?
! ;;(echo-keystrokes 0) ;; not needed with above message
! (e (let ((cursor-in-echo-area t))
! (read-event)))
;; Binding minibuffer-history-symbol to nil is a work-around
;; for some incompatibility with gmhist.
! (minibuffer-history-symbol)
! (message-log-max nil))
! ;; If the first character the user types when we prompt them
! ;; for a string is the yank-word character, then go into
! ;; word-search mode. Otherwise unread that character and
! ;; read a key the normal way.
! ;; Word search does not apply (yet) to regexp searches,
! ;; no check is made here.
! (message "%s" (isearch-message-prefix nil nil t))
! (if (memq (lookup-key isearch-mode-map (vector e))
! '(isearch-yank-word
! isearch-yank-word-or-char))
! (setq isearch-word t;; so message-prefix is right
! isearch-new-word t)
! (cancel-kbd-macro-events)
! (isearch-unread e))
! (setq cursor-in-echo-area nil)
(setq isearch-new-string
(read-from-minibuffer
(isearch-message-prefix nil nil isearch-nonincremental)
--- 1122,1132 ----
;; that can change their values.
(setq old-point (point) old-other-end isearch-other-end)
(unwind-protect
! (let* ((message-log-max nil)
;; Binding minibuffer-history-symbol to nil is a work-around
;; for some incompatibility with gmhist.
! (minibuffer-history-symbol))
(setq isearch-new-string
(read-from-minibuffer
(isearch-message-prefix nil nil isearch-nonincremental)
***************
*** 1209,1214 ****
--- 1200,1214 ----
(isearch-abort) ;; outside of let to restore outside global values
)))
+ ;; Obsolete usage of `C-s M-e C-w'. Remove after 23.1.
+ (defvar isearch-new-word)
+ (defun isearch-edit-string-set-word ()
+ "Do word search after exiting `isearch-edit-string'."
+ (interactive)
+ (message "This feature is obsolete since 23.1; use `M-s w' instead.")
+ (setq isearch-word t isearch-new-word t))
+
+
(defun isearch-nonincremental-exit-minibuffer ()
(interactive)
(setq isearch-nonincremental t)
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2008-07-31 12:35 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-08 3:05 propose: dired-isearch.el --- isearch in Dired William Xu
2007-08-08 3:47 ` Levin
2007-08-08 5:29 ` William Xu
2007-08-08 8:12 ` Herbert Euler
2007-08-08 8:16 ` Miles Bader
2007-08-08 9:35 ` William Xu
2007-08-08 13:01 ` Stefan Monnier
2007-08-09 2:45 ` Miles Bader
2007-08-08 18:46 ` Stefan Monnier
2007-08-08 22:54 ` Juri Linkov
2008-07-23 20:34 ` Juri Linkov
2008-07-24 6:41 ` Mathias Dahl
2008-07-25 0:32 ` Juri Linkov
2008-07-24 13:53 ` Stefan Monnier
2008-07-24 15:52 ` Drew Adams
2008-07-24 17:20 ` Stefan Monnier
2008-07-24 17:31 ` dired-details status [was: isearch in Dired] Drew Adams
2008-07-25 0:33 ` isearch in Dired Juri Linkov
2008-07-25 0:40 ` Lennart Borgman (gmail)
2008-07-29 15:44 ` word search (Re: isearch in Dired) Juri Linkov
2008-07-29 17:22 ` Chong Yidong
2008-07-30 16:50 ` Juri Linkov
2008-07-31 12:35 ` Juri Linkov [this message]
2008-07-31 14:10 ` Stefan Monnier
2008-07-31 15:16 ` Juri Linkov
2008-07-31 16:30 ` Stefan Monnier
2008-07-31 15:24 ` Stefan Monnier
2008-07-29 15:45 ` isearch in Dired Juri Linkov
2008-07-29 17:56 ` Stefan Monnier
2008-07-30 14:29 ` Juri Linkov
2007-08-09 2:46 ` propose: dired-isearch.el --- " William Xu
2007-08-09 0:06 ` Richard Stallman
2007-08-09 1:53 ` William Xu
2007-08-09 23:11 ` Richard Stallman
2007-08-10 1:42 ` William Xu
2007-08-10 8:37 ` Mathias Dahl
2007-08-10 9:22 ` David Kastrup
2007-08-10 15:56 ` Drew Adams
2007-08-11 10:52 ` William Xu
2007-08-11 15:15 ` Drew Adams
2007-08-11 16:58 ` Robert J. Chassell
2007-08-12 1:02 ` Drew Adams
2007-08-12 20:46 ` Juri Linkov
2007-08-12 21:43 ` Drew Adams
2007-08-12 23:23 ` Juri Linkov
2007-08-13 9:14 ` Mathias Megyei
2007-08-13 9:24 ` Andreas Schwab
2007-08-13 13:09 ` Mathias Dahl
2007-08-09 16:07 ` Drew Adams
2007-08-09 2:37 ` Herbert Euler
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878wvicjtk.fsf@jurta.org \
--to=juri@jurta.org \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/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 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).