From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 9185@debbugs.gnu.org
Subject: bug#9185: 24.0.50; "C-s M-p" does not bring the tip of the search ring
Date: Tue, 23 Aug 2011 12:52:57 +0300 [thread overview]
Message-ID: <87liukxxtj.fsf@mail.jurta.org> (raw)
In-Reply-To: <jwvty99qgj3.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 22 Aug 2011 17:34:08 -0400")
> A patch that makes it work like you describe (i.e. C-s M-p gets first,
> and C-s C-s M-p gets the second) sounds OK, assuming the patch
> is not too ugly.
There are two places in isearch.el that reuse the last element of the
ring when the search string is empty. One is `isearch-repeat' (used by
`C-s C-s') and another is `isearch-edit-string'. The latter is questionable.
An old comment used to say:
;; This used to set the last search string,
;; but I think it is not right to do that here.
;; Only the string actually used should be saved.
It doesn't correspond to the actual code, so I deleted it.
I have no opinion how useless is to reuse the last element of the
ring after exiting from `isearch-edit-string' with empty input.
But with the existing functionality this place needs to adjust the ring.
So three diff hunks below fix the following cases:
1. in isearch-edit-string: C-s M-e RET M-p
2. in isearch-repeat: C-s C-s M-p
3. in isearch-ring-adjust1: C-s M-p
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el 2011-07-15 13:33:07 +0000
+++ lisp/isearch.el 2011-08-23 09:51:16 +0000
@@ -1191,19 +1200,17 @@ (defun isearch-edit-string ()
isearch-word isearch-new-word))
;; Empty isearch-string means use default.
- (if (= 0 (length isearch-string))
- (setq isearch-string (or (car (if isearch-regexp
- regexp-search-ring
- search-ring))
- "")
-
- isearch-message
- (mapconcat 'isearch-text-char-description
- isearch-string ""))
- ;; This used to set the last search string,
- ;; but I think it is not right to do that here.
- ;; Only the string actually used should be saved.
- ))
+ (when (= 0 (length isearch-string))
+ (setq isearch-string (or (car (if isearch-regexp
+ regexp-search-ring
+ search-ring))
+ "")
+
+ isearch-message
+ (mapconcat 'isearch-text-char-description
+ isearch-string ""))
+ ;; After taking the last element, adjust ring to previous one.
+ (isearch-ring-adjust1 nil)))
;; This used to push the state as of before this C-s, but it adds
;; an inconsistent state where part of variables are from the
@@ -1290,7 +1297,9 @@ (defun isearch-repeat (direction)
isearch-message
(mapconcat 'isearch-text-char-description
isearch-string "")
- isearch-case-fold-search isearch-last-case-fold-search))
+ isearch-case-fold-search isearch-last-case-fold-search)
+ ;; After taking the last element, adjust ring to previous one.
+ (isearch-ring-adjust1 nil))
;; If already have what to search for, repeat it.
(or isearch-success
(progn
@@ -2071,7 +2080,7 @@ (defun isearch-ring-adjust1 (advance)
()
(set yank-pointer-name
(setq yank-pointer
- (mod (+ (or yank-pointer 0)
+ (mod (+ (or yank-pointer (if advance 0 -1))
(if advance -1 1))
length)))
(setq isearch-string (nth yank-pointer ring)
next prev parent reply other threads:[~2011-08-23 9:52 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 8:12 bug#9185: 24.0.50; "C-s M-p" does not bring the tip of the search ring Dani Moncayo
2011-07-28 8:18 ` Dani Moncayo
2011-07-28 8:20 ` Deniz Dogan
2011-07-28 8:43 ` Dani Moncayo
2011-07-28 8:50 ` Deniz Dogan
2011-07-28 9:08 ` Dani Moncayo
2011-07-28 9:11 ` Deniz Dogan
2011-07-28 9:17 ` Dani Moncayo
2011-07-28 9:11 ` Andreas Schwab
2011-07-28 9:29 ` Juri Linkov
2011-07-28 9:50 ` Juri Linkov
2011-07-28 10:05 ` Dani Moncayo
2011-07-28 11:13 ` Andreas Schwab
2011-07-28 11:32 ` Dani Moncayo
2011-07-28 11:44 ` Juri Linkov
2011-07-30 8:52 ` Juri Linkov
2011-08-10 19:03 ` Dani Moncayo
2011-08-13 15:24 ` Stefan Monnier
2011-08-14 11:14 ` Dani Moncayo
2011-08-14 12:36 ` Stefan Monnier
2011-08-14 14:47 ` Dani Moncayo
2011-08-21 17:56 ` Dani Moncayo
2011-08-21 18:35 ` Juri Linkov
2011-08-21 19:24 ` Dani Moncayo
2011-08-22 11:06 ` Juri Linkov
2011-08-22 12:09 ` Dani Moncayo
2011-08-22 21:34 ` Stefan Monnier
2011-08-23 9:52 ` Juri Linkov [this message]
2011-08-23 18:40 ` Stefan Monnier
2011-08-24 9:41 ` Juri Linkov
2011-08-24 14:23 ` Dani Moncayo
2011-08-24 15:44 ` Juri Linkov
2011-08-24 16:18 ` Dani Moncayo
2011-08-24 18:28 ` Juri Linkov
2011-08-24 23:21 ` Dani Moncayo
2011-08-24 23:54 ` Dani Moncayo
2011-08-25 9:01 ` Juri Linkov
2011-08-25 10:10 ` Dani Moncayo
2011-11-19 19:59 ` Juri Linkov
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=87liukxxtj.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=9185@debbugs.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).