[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: First two elements of search-ring shown twice in minibuffer when usi
From: |
Stefan Monnier |
Subject: |
Re: First two elements of search-ring shown twice in minibuffer when using M-p multiple times? |
Date: |
Mon, 10 Mar 2008 10:31:38 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
> Below is a patch that fixes all these problems. It uses
> search-ring-yank-pointer and regexp-search-ring-yank-pointer
> for the HISTPOS argument of read-from-minibuffer that gives
> the correct initial minibuffer search history position for
> isearch-edit-string.
Thanks.
> It also gets rid of all trickery used to read the first character
> typed in the minibuffer (that removes another set of problems;
> see related old bug reports). It adds a new backward-compatible
> command `isearch-edit-string-set-word' bound to C-w in the minibuffer
> that calls `kill-region' when the mark is active, and otherwise does
> word search after exiting `isearch-edit-string' (the mark is not active
> when `isearch-edit-string' just created the minibuffer, and without
> the mark `kill-region' would fail anyway).
> This preserves the behavior described in the Emacs manual:
> `C-s <RET> C-w WORDS <RET>'
> Search for WORDS, ignoring details of punctuation.
This seems unrelated, right?
It looks like a good change. But I wonder why we don't use an approach
similar to the M-r binding to isearch-toggle-regexp. Of course, we'd
rather not eat yet-another key (e.g. bind M-w to isearch-toggle-word),
but maybe we could change isearch-toggle-regexp into
isearch-cycle-regexp-word, such that the command cycles between
plain/regexp/word searches.
Stefan
> Index: lisp/isearch.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/isearch.el,v
> retrieving revision 1.313
> diff -c -r1.313 isearch.el
> *** lisp/isearch.el 28 Feb 2008 01:57:42 -0000 1.313
> --- lisp/isearch.el 9 Mar 2008 21:57:02 -0000
> ***************
> *** 436,441 ****
> --- 436,442 ----
> (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)
> ***************
> *** 1025,1061 ****
> ;; 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)
> isearch-string
> minibuffer-local-isearch-map nil
> ! (if isearch-regexp 'regexp-search-ring 'search-ring)
> nil t)
> isearch-new-message
> (mapconcat 'isearch-text-char-description
> --- 1026,1046 ----
> ;; 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)
> isearch-string
> minibuffer-local-isearch-map nil
> ! (if isearch-regexp
> ! (cons 'regexp-search-ring
> ! (1+ (or regexp-search-ring-yank-pointer -1)))
> ! (cons 'search-ring
> ! (1+ (or search-ring-yank-pointer -1))))
> nil t)
> isearch-new-message
> (mapconcat 'isearch-text-char-description
> ***************
> *** 1116,1121 ****
> --- 1101,1116 ----
> (isearch-abort) ;; outside of let to restore outside global values
> )))
> + (defun isearch-edit-string-set-word ()
> + "Do word search after exiting `isearch-edit-string'.
> + If the mark is not active in the search string editing minibuffer,
> + then after exiting `isearch-edit-string', do word search.
> + Otherwise, kill text between point and mark in the minibuffer."
> + (interactive)
> + (if mark-active
> + (kill-region (point) (mark))
> + (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/
- Re: First two elements of search-ring shown twice in minibuffer when using M-p multiple times?, Juri Linkov, 2008/03/09
- Re: First two elements of search-ring shown twice in minibuffer when using M-p multiple times?,
Stefan Monnier <=
- Word search (was: First two elements of search-ring shown twice in minibuffer when using M-p multiple times?), Juri Linkov, 2008/03/10
- Re: Word search, Stefan Monnier, 2008/03/10
- Re: Word search, Juri Linkov, 2008/03/10
- Re: Word search, Stefan Monnier, 2008/03/11
- Re: Word search, Juri Linkov, 2008/03/11
- Re: Word search, Stefan Monnier, 2008/03/11
- Re: Word search, Juri Linkov, 2008/03/12
- Re: Word search, Stefan Monnier, 2008/03/12
- Re: Word search, Richard Stallman, 2008/03/12
- Re: Word search, Richard Stallman, 2008/03/11