GNU bug report logs - #9185
24.0.50; "C-s M-p" does not bring the tip of the search ring

Previous Next

Package: emacs;

Reported by: Dani Moncayo <dmoncayo <at> gmail.com>

Date: Thu, 28 Jul 2011 08:13:01 UTC

Severity: normal

Found in version 24.0.50

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9185 in the body.
You can then email your comments to 9185 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 08:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dani Moncayo <dmoncayo <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 28 Jul 2011 08:13:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; "C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 10:12:28 +0200
Hi,

I sometimes want to search for some text that I know is already in the
search ring, but I'm unsure if it is at the tip.

In these cases, I intuitively do "C-s M-p", expecting to get precisely
the last search string used, i.e., the tip of the search ring.  But I
fact M-p brings me the second entry.

IMO, "C-s M-p" should bring the _first_ (more recent) entry.


In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2011-07-25 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.5) --no-opt'

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 08:19:01 GMT) Full text and rfc822 format available.

Message #8 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 10:18:42 +0200
> IMO, "C-s M-p" should bring the _first_ (more recent) entry.

IOW, "C-s M-p <RET>" should be equivalent to "C-s C-s".


-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 08:23:01 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Deniz Dogan <deniz <at> dogan.se>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#9185: 24.0.50; "C-s M-p" does not bring the tip of the search
	ring
Date: Thu, 28 Jul 2011 10:20:34 +0200
On 2011-07-28 10:18, Dani Moncayo wrote:
>> IMO, "C-s M-p" should bring the _first_ (more recent) entry.
>
> IOW, "C-s M-p<RET>" should be equivalent to "C-s C-s".
>

How do you suggest users go back in the ring?





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 08:44:02 GMT) Full text and rfc822 format available.

Message #14 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Deniz Dogan <deniz <at> dogan.se>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 10:43:02 +0200
On Thu, Jul 28, 2011 at 10:20, Deniz Dogan <deniz <at> dogan.se> wrote:
>
> How do you suggest users go back in the ring?
>

??

To get older entries from the search ring, repeat "M-p" (as always).
Every additional "M-p" will bring an additional entry from the search
ring (as always).

What I say is that _the first_ time you do M-p, you should get the tip
of the ring, not the second entry (as happens now).


-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 08:51:01 GMT) Full text and rfc822 format available.

Message #17 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Deniz Dogan <deniz <at> dogan.se>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50; "C-s M-p" does not bring the tip of the search
	ring
Date: Thu, 28 Jul 2011 10:50:10 +0200
On 2011-07-28 10:43, Dani Moncayo wrote:
> On Thu, Jul 28, 2011 at 10:20, Deniz Dogan<deniz <at> dogan.se>  wrote:
>>
>> How do you suggest users go back in the ring?
>>
>
> ??
>
> To get older entries from the search ring, repeat "M-p" (as always).
> Every additional "M-p" will bring an additional entry from the search
> ring (as always).
>
> What I say is that _the first_ time you do M-p, you should get the tip
> of the ring, not the second entry (as happens now).
>

C-s C-s immediately searches for the latest entry in the ring.  If C-s 
M-p did that too, things would be...weird.  At least to me.  I wouldn't 
really mind that much if M-p brings back the latest entry but _doesn't_ 
perform the actual search, but it just feels kind of unnecessary since 
if you wanted to search for that you could just C-s C-s to begin with.

Deniz




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 09:09:02 GMT) Full text and rfc822 format available.

Message #20 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Deniz Dogan <deniz <at> dogan.se>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 11:08:43 +0200
On Thu, Jul 28, 2011 at 10:50, Deniz Dogan <deniz <at> dogan.se> wrote:
>
> C-s C-s immediately searches for the latest entry in the ring.  If C-s M-p
> did that too, things would be...weird.  At least to me.  I wouldn't really
> mind that much if M-p brings back the latest entry but _doesn't_ perform the
> actual search,

You are forgetting to add <RET> after "C-s M-p".  I see no weirdness
here at all.  It feel totally natural to me:
* C-s start Isearch.
* M-p brings the *last* ring entry (not the second one, as does now).
* <RET> accepts the selected entry.


> but it just feels kind of unnecessary since if you wanted to
> search for that you could just C-s C-s to begin with.

"C-s C-s" is the quick way of repeating the last search, but, as I
explained in the OP, it doesn't allow you to check the search string
before starting the search.


Again: The fact that M-p brings the second entry from the ring
(instead of the first one) seems annoying and counter-intuitive to me.
 It doesn't allow me to check the tip of the search ring before using
it.

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 09:12:01 GMT) Full text and rfc822 format available.

Message #23 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Deniz Dogan <deniz <at> dogan.se>
Cc: 9185 <at> debbugs.gnu.org, Dani Moncayo <dmoncayo <at> gmail.com>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 11:11:15 +0200
Deniz Dogan <deniz <at> dogan.se> writes:

> C-s C-s immediately searches for the latest entry in the ring.  If C-s 
> M-p did that too, things would be...weird.  At least to me.  I
> wouldn't really mind that much if M-p brings back the latest entry but
> _doesn't_ perform the actual search, but it just feels kind of
> unnecessary since if you wanted to search for that you could just C-s
> C-s to begin with.

You may want to edit it first.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 09:12:02 GMT) Full text and rfc822 format available.

Message #26 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Deniz Dogan <deniz <at> dogan.se>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50; "C-s M-p" does not bring the tip of the search
	ring
Date: Thu, 28 Jul 2011 11:11:22 +0200
On 2011-07-28 11:08, Dani Moncayo wrote:
> On Thu, Jul 28, 2011 at 10:50, Deniz Dogan<deniz <at> dogan.se>  wrote:
>>
>> C-s C-s immediately searches for the latest entry in the ring.  If C-s M-p
>> did that too, things would be...weird.  At least to me.  I wouldn't really
>> mind that much if M-p brings back the latest entry but _doesn't_ perform the
>> actual search,
>
> You are forgetting to add<RET>  after "C-s M-p".  I see no weirdness
> here at all.  It feel totally natural to me:
> * C-s start Isearch.
> * M-p brings the *last* ring entry (not the second one, as does now).
> *<RET>  accepts the selected entry.
>

You never said to hit RET, that's why I was confused.

>> but it just feels kind of unnecessary since if you wanted to
>> search for that you could just C-s C-s to begin with.
>
> "C-s C-s" is the quick way of repeating the last search, but, as I
> explained in the OP, it doesn't allow you to check the search string
> before starting the search.
>
>
> Again: The fact that M-p brings the second entry from the ring
> (instead of the first one) seems annoying and counter-intuitive to me.
>   It doesn't allow me to check the tip of the search ring before using
> it.
>

That's true.  I'm with you on this one, but since this behavior is so 
old, I wouldn't count on it changing any time soon.

Deniz




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 09:18:02 GMT) Full text and rfc822 format available.

Message #29 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Deniz Dogan <deniz <at> dogan.se>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 11:17:16 +0200
>>
>> You are forgetting to add<RET>  after "C-s M-p".  I see no weirdness
>> here at all.  It feel totally natural to me:
>> * C-s start Isearch.
>> * M-p brings the *last* ring entry (not the second one, as does now).
>> *<RET>  accepts the selected entry.
>>
>
> You never said to hit RET, that's why I was confused.

Sorry I said it.  Please check the thread:
   >> IOW, "C-s M-p <RET>" should be equivalent to "C-s C-s".


> That's true.  I'm with you on this one

Thanks!

>, but since this behavior is so old, I
> wouldn't count on it changing any time soon.

I hope that it wasn't an argument to prevent improving Emacs.

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 09:32:01 GMT) Full text and rfc822 format available.

Message #32 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 12:29:40 +0300
> IMO, "C-s M-p" should bring the _first_ (more recent) entry.

In http://lists.gnu.org/archive/html/emacs-devel/2004-07/msg00059.html
I submitted a patch to fix this.  But later I found a reason
why it's not a good change.  And now I forgot why ;(




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 09:54:02 GMT) Full text and rfc822 format available.

Message #35 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 12:50:03 +0300
>> IMO, "C-s M-p" should bring the _first_ (more recent) entry.
>
> In http://lists.gnu.org/archive/html/emacs-devel/2004-07/msg00059.html
> I submitted a patch to fix this.  But later I found a reason
> why it's not a good change.  And now I forgot why ;(

I found the explanation why this is a bad change ;)  Because to repeat the
last search, users type `C-s C-s', and to repeat the second last search,
users type `C-s M-p C-s' but with this change there are two redundant
keysequences to repeat the last search, `C-s C-s' and `C-s M-p C-s', and to
repeat the second last search, the keysequence is too long `C-s M-p M-p C-s'.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 10:06:01 GMT) Full text and rfc822 format available.

Message #38 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 12:05:45 +0200
On Thu, Jul 28, 2011 at 11:50, Juri Linkov <juri <at> jurta.org> wrote:
> I found the explanation why this is a bad change ;)  Because to repeat the
> last search, users type `C-s C-s', and to repeat the second last search,
> users type `C-s M-p C-s' but with this change there are two redundant
> keysequences to repeat the last search, `C-s C-s' and `C-s M-p C-s', and to
> repeat the second last search, the keysequence is too long `C-s M-p M-p C-s'.

Please, reconsider this.

I understand what you say, but IMO, clearly the advantages of the
current behavior (save one extra M-p) in no way makes up for the
drawbacks (counter intuitive behavior; no way to check the tip of the
search ring before using it).

TIA.


-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 11:14:02 GMT) Full text and rfc822 format available.

Message #41 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: Juri Linkov <juri <at> jurta.org>, 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 13:13:11 +0200
Dani Moncayo <dmoncayo <at> gmail.com> writes:

> I understand what you say, but IMO, clearly the advantages of the
> current behavior (save one extra M-p) in no way makes up for the
> drawbacks (counter intuitive behavior; no way to check the tip of the
> search ring before using it).

You can still type C-s M-p M-n to get the first entry for inspection.
It's a trade-off which is more important.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 11:33:02 GMT) Full text and rfc822 format available.

Message #44 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Juri Linkov <juri <at> jurta.org>, 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 13:32:01 +0200
On Thu, Jul 28, 2011 at 13:13, Andreas Schwab <schwab <at> linux-m68k.org> wrote:
> Dani Moncayo <dmoncayo <at> gmail.com> writes:
>
>> I understand what you say, but IMO, clearly the advantages of the
>> current behavior (save one extra M-p) in no way makes up for the
>> drawbacks (counter intuitive behavior; no way to check the tip of the
>> search ring before using it).
>
> You can still type C-s M-p M-n to get the first entry for inspection.
> It's a trade-off which is more important.
>

Indeed.  (I realized it just after posting).

So what do people think it would be more convenient?

Isn't the requested behavior of M-p more intuitive?
Isn't it more consistent with the behavior of M-p in other contexts?
Isn't "M-p M-p" almost as quick to type than a single "M-p"?
...


-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 28 Jul 2011 11:47:01 GMT) Full text and rfc822 format available.

Message #47 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 28 Jul 2011 14:44:49 +0300
>>> I understand what you say, but IMO, clearly the advantages of the
>>> current behavior (save one extra M-p) in no way makes up for the
>>> drawbacks (counter intuitive behavior; no way to check the tip of the
>>> search ring before using it).

I agree that it's counter intuitive behavior.

>> You can still type C-s M-p M-n to get the first entry for inspection.
>> It's a trade-off which is more important.

To do the same, I use `C-s M-e M-p'.

> So what do people think it would be more convenient?

I don't mind the change.  If people agree with it,
I'll send a new patch that implements this change.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sat, 30 Jul 2011 08:56:02 GMT) Full text and rfc822 format available.

Message #50 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sat, 30 Jul 2011 11:52:57 +0300
Severity: wishlist
Tags: patch

> So what do people think it would be more convenient?
>
> Isn't it more consistent with the behavior of M-p in other contexts?

Most importantly it will be more consistent with `C-s M-e M-p [M-p ...]'
The amount of typed M-p will be the same for the same previous search string.

So when people will agree, here is the patch:

Using parent branch file:///home/work/emacs/bzr/emacs/http-trunk/
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2011-07-15 13:33:07 +0000
+++ lisp/isearch.el	2011-07-30 08:49:36 +0000
@@ -2071,7 +2086,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)





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Wed, 10 Aug 2011 19:06:01 GMT) Full text and rfc822 format available.

Message #53 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: 9185 <at> debbugs.gnu.org
Cc: Juri Linkov <juri <at> jurta.org>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Wed, 10 Aug 2011 21:03:51 +0200
> So when people will agree, here is the patch:

Stefan, Chong, Please, could you take a look at Juri's patch?  (It is
a fairly simple issue, despite the number of post in this thread).

TIA

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sat, 13 Aug 2011 15:27:01 GMT) Full text and rfc822 format available.

Message #56 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Dani Moncayo <dmoncayo <at> gmail.com>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sat, 13 Aug 2011 11:24:37 -0400
>> So what do people think it would be more convenient?
>> Isn't it more consistent with the behavior of M-p in other contexts?

> Most importantly it will be more consistent with `C-s M-e M-p [M-p ...]'
> The amount of typed M-p will be the same for the same previous search string.
> So when people will agree, here is the patch:

I don't think that the inconsistency of the current behavior is
a serious problem.  There are already plenty of other inconsistencies
between the isearch behavior is typical minibuffer prompts, so it's not
like resolving this would make it all consistent.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sun, 14 Aug 2011 11:17:02 GMT) Full text and rfc822 format available.

Message #59 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Juri Linkov <juri <at> jurta.org>, 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sun, 14 Aug 2011 13:14:37 +0200
On Sat, Aug 13, 2011 at 17:24, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>>> So what do people think it would be more convenient?
>>> Isn't it more consistent with the behavior of M-p in other contexts?
>
>> Most importantly it will be more consistent with `C-s M-e M-p [M-p ...]'
>> The amount of typed M-p will be the same for the same previous search string.
>> So when people will agree, here is the patch:
>
> I don't think that the inconsistency of the current behavior is
> a serious problem.  There are already plenty of other inconsistencies
> between the isearch behavior is typical minibuffer prompts, so it's not
> like resolving this would make it all consistent.


Maybe there are other inconsistencies, so what?  Now we are talking
about this one.  Should not fixing it be a step forward?

Honestly, I'm pretty surprised about the resistance to do such a
trivial and logical improvement.

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sun, 14 Aug 2011 12:39:01 GMT) Full text and rfc822 format available.

Message #62 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: Juri Linkov <juri <at> jurta.org>, 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sun, 14 Aug 2011 08:36:25 -0400
>>>> So what do people think it would be more convenient?
>>>> Isn't it more consistent with the behavior of M-p in other contexts?
>>> Most importantly it will be more consistent with `C-s M-e M-p [M-p
>>> ...]'  The amount of typed M-p will be the same for the same
>>> previous search string.  So when people will agree, here is the
>>> patch:
>> I don't think that the inconsistency of the current behavior is
>> a serious problem.  There are already plenty of other inconsistencies
>> between the isearch behavior is typical minibuffer prompts, so it's not
>> like resolving this would make it all consistent.
> Maybe there are other inconsistencies, so what?  Now we are talking
> about this one.  Should not fixing it be a step forward?
> Honestly, I'm pretty surprised about the resistance to do such a
> trivial and logical improvement.

As mentioned in the thread it's not an improvement for everyone.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sun, 14 Aug 2011 14:50:02 GMT) Full text and rfc822 format available.

Message #65 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Juri Linkov <juri <at> jurta.org>, 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sun, 14 Aug 2011 16:47:40 +0200
> As mentioned in the thread it's not an improvement for everyone.

???

Could you quote a sentence in the thread that supports such claim?

At the end, both Deniz and Jury agreed with me that it would be better
to make M-p bring the top of the search ring, and Andread Just pointed
out an alternative way to achieve that with the current Emacs.  So I
don't see any opposition for the change (except yours).

For God's sake... what do people expect M-p to do but get the _previous_ thing?

-- 
Dani Moncayo.  Feeling tired...




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sun, 21 Aug 2011 17:59:01 GMT) Full text and rfc822 format available.

Message #68 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sun, 21 Aug 2011 19:56:07 +0200
Ping!

The current counter-intuitive behavior (which IMO should not have been
qualified as a feature, but as a bug) has been bugging me for some
time, as I'm sure will bug anyone that tries to navigate through the
search ring.

Juri, I guess you also want to get this fixed in the trunk.  Maybe if
you chime in, Stefan will see the light ;).  I still can't understand
his reluctance to fix this, and I seem to lack the credit/ability to
convince him.

TIA.

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sun, 21 Aug 2011 18:49:02 GMT) Full text and rfc822 format available.

Message #71 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sun, 21 Aug 2011 21:35:04 +0300
> The current counter-intuitive behavior (which IMO should not have been
> qualified as a feature, but as a bug) has been bugging me for some
> time, as I'm sure will bug anyone that tries to navigate through the
> search ring.
>
> Juri, I guess you also want to get this fixed in the trunk.  Maybe if
> you chime in, Stefan will see the light ;).  I still can't understand
> his reluctance to fix this, and I seem to lack the credit/ability to
> convince him.

You exaggerate the importance of the problem.  When I noticed this small
inconsistency I still continued to use isearch without any inconvenience.
So the only reason to change it is for the consistency with `C-s M-e M-p'
that has its own problems.  The main problem is that when you retrieve
the previous search string with `C-s C-s', then typing `M-p' will not have
a visible effect, because `M-p' will retrieve the previous search string
and the same string is already used as the current search string.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sun, 21 Aug 2011 19:28:02 GMT) Full text and rfc822 format available.

Message #74 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sun, 21 Aug 2011 21:24:41 +0200
> You exaggerate the importance of the problem.  When I noticed this small
> inconsistency

The inconsistency may be small, but you agree that there exists.

> I still continued to use isearch without any inconvenience.

I think that a (small) inconsistency should provoke a (small) inconvenience.

> So the only reason to change it is for the consistency with `C-s M-e M-p'
> that has its own problems.  The main problem is that when you retrieve
> the previous search string with `C-s C-s', then typing `M-p' will not have
> a visible effect, because `M-p' will retrieve the previous search string
> and the same string is already used as the current search string.

If that is the resulting behavior, it is indeed a problem, but a small
one IMO.  Since `C-s C-s' retrieves the first entry from the search
ring, `M-p' should retrieve the _previous_ one, i.e., the second.

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Mon, 22 Aug 2011 11:13:02 GMT) Full text and rfc822 format available.

Message #77 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Mon, 22 Aug 2011 14:06:18 +0300
> If that is the resulting behavior, it is indeed a problem, but a small
> one IMO.  Since `C-s C-s' retrieves the first entry from the search
> ring, `M-p' should retrieve the _previous_ one, i.e., the second.

This complicates the behavior of `M-p'.
Do you propose the following logic?

1. When the user starts Isearch with `C-s', then
   `M-p' should retrieve the _first_ entry from the search ring.

2. But when the user starts Isearch with `C-s C-s', then
   `M-p' should retrieve the _second_ entry from the search ring.

But what to do when the user starts Isearch with `C-s C-s', but
changes his mind and deletes it from the current search string,
i.e. types `C-s C-s DEL'.  What should `M-p' bring in this case?
The first or the second entry?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Mon, 22 Aug 2011 12:12:01 GMT) Full text and rfc822 format available.

Message #80 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Mon, 22 Aug 2011 14:09:19 +0200
> This complicates the behavior of `M-p'.

I don't know if the underlying implementation becomes a bit more
complex, but the resulting behavior is clearly better for the user
(IMO).

> Do you propose the following logic?
>
> 1. When the user starts Isearch with `C-s', then
>   `M-p' should retrieve the _first_ entry from the search ring.

Yes. This is obviously what the average user should expect.

> 2. But when the user starts Isearch with `C-s C-s', then
>   `M-p' should retrieve the _second_ entry from the search ring.

Yes too.  In this case, when the user types `M-p', s?he should want to
get the second entry, because the first one is already in effect.
IOW, `M-p' should always retrieve the _previous_ entry from the ring,
which in this case is the second one.

> But what to do when the user starts Isearch with `C-s C-s', but
> changes his mind and deletes it from the current search string,
> i.e. types `C-s C-s DEL'.  What should `M-p' bring in this case?
> The first or the second entry?

In this case, the user has discarded the first entry and then has
typed `M-p'.  Thus, TRT for `M-p' in this case is IMO to retrieve the
second entry.

The same question is applicable to the sequence `C-s M-p
<delete_the_entry_in_the_minibuffer> M-p'.  I've just tested this and
see that the current behavior is that, i.e., the last `M-p' retrieves
the second entry (which IMO is TRT).

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Mon, 22 Aug 2011 21:37:01 GMT) Full text and rfc822 format available.

Message #83 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: Juri Linkov <juri <at> jurta.org>, 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: 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.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Tue, 23 Aug 2011 09:58:02 GMT) Full text and rfc822 format available.

Message #86 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 9185 <at> debbugs.gnu.org, Dani Moncayo <dmoncayo <at> gmail.com>
Subject: Re: 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
> 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)





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Tue, 23 Aug 2011 18:43:02 GMT) Full text and rfc822 format available.

Message #89 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Dani Moncayo <dmoncayo <at> gmail.com>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Tue, 23 Aug 2011 14:40:11 -0400
> 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

That looks OK.


        Stefan




Reply sent to Juri Linkov <juri <at> jurta.org>:
You have taken responsibility. (Wed, 24 Aug 2011 09:45:02 GMT) Full text and rfc822 format available.

Notification sent to Dani Moncayo <dmoncayo <at> gmail.com>:
bug acknowledged by developer. (Wed, 24 Aug 2011 09:45:03 GMT) Full text and rfc822 format available.

Message #94 received at 9185-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 9185-done <at> debbugs.gnu.org, Dani Moncayo <dmoncayo <at> gmail.com>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Wed, 24 Aug 2011 12:41:36 +0300
>> 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
>
> That looks OK.

Installed.




Message #95 received at 9185-done <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185-done <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Wed, 24 Aug 2011 11:55:46 +0200
>> That looks OK.
>
> Installed.

Thanks for taking the time to fix this.

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Wed, 24 Aug 2011 14:26:02 GMT) Full text and rfc822 format available.

Message #98 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Wed, 24 Aug 2011 16:23:24 +0200
Hi Juri,

I've tested your patch and it works fine for the three cases you said:

> 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

But I've found another use-case that seems to need a fix too:
0. C-s a <RET> C-s b <RET> C-s c <RET>
1. C-s C-s     --> "c" is selected, OK.
2. M-p <RET>   --> "b" is selected, OK.
3. M-p         --> Now "c" (the previous used entry) should have been
selected, but I see that "b" (the current entry) remains selected
instead.

Do you see the same behavior?

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Wed, 24 Aug 2011 15:54:02 GMT) Full text and rfc822 format available.

Message #101 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Wed, 24 Aug 2011 18:44:19 +0300
> But I've found another use-case that seems to need a fix too:
> 0. C-s a <RET> C-s b <RET> C-s c <RET>
> 1. C-s C-s     --> "c" is selected, OK.
> 2. M-p <RET>   --> "b" is selected, OK.
> 3. M-p         --> Now "c" (the previous used entry) should have been
> selected, but I see that "b" (the current entry) remains selected
> instead.

This is a separate problem caused when exiting from the minibuffer in
`isearch-edit-string' by `read-from-minibuffer' (i.e. step 2
`M-p <RET>' above) adds a new element "b" to the history (search ring).

I agree that `isearch-edit-string' should not update the search ring.
It should be updated only by `isearch-update-ring' in `isearch-done'.
So e.g. `C-s C-s M-e RET C-g' or `C-s M-p RET C-g' should keep the
search ring unchanged.  Note also that `isearch-done' with the arg
NOPUSH=t already tries to take care of not updating the search ring,
but unsuccessfully.  It requires the following patch for the complete fix:

Using parent branch file:///home/work/emacs/bzr/emacs/http-trunk/
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2011-07-15 13:33:07 +0000
+++ lisp/isearch.el	2011-08-24 15:43:01 +0000
@@ -1152,9 +1161,14 @@ (defun isearch-edit-string ()
 
 	  (unwind-protect
 	      (let* ((message-log-max nil)
+		     ;; Protect the global search ring from updating
+		     ;; by read-from-minibuffer.  It should be updated only
+		     ;; by isearch-update-ring in isearch-done.
+		     (search-ring search-ring)
+		     (regexp-search-ring regexp-search-ring)
 		     ;; 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)
		        (cons isearch-string (1+ (isearch-fail-pos)))
                        minibuffer-local-isearch-map nil
                        (if isearch-regexp
 			   (cons 'regexp-search-ring




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Wed, 24 Aug 2011 16:21:01 GMT) Full text and rfc822 format available.

Message #104 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Wed, 24 Aug 2011 18:18:04 +0200
> It requires the following patch for the complete fix:

Great Juri, your patch fixes the last problem ;).

However, on further testing, I've found still another misbehavior:
0. C-s a <RET> C-s b <RET> C-s c <RET>
1. C-s C-s     --> "c" is selected, OK.
2. M-e <RET>   --> "c" remains selected (the search ring is unchanged:
"a;b;c"), OK.
3. M-p         --> Now "b" (the previous used entry) should have been
selected, but I see that "c" (the current entry) remains selected
instead.


-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Wed, 24 Aug 2011 18:32:01 GMT) Full text and rfc822 format available.

Message #107 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Wed, 24 Aug 2011 21:28:09 +0300
> However, on further testing, I've found still another misbehavior:
> 0. C-s a <RET> C-s b <RET> C-s c <RET>
> 1. C-s C-s     --> "c" is selected, OK.
> 2. M-e <RET>   --> "c" remains selected (the search ring is unchanged:
> "a;b;c"), OK.
> 3. M-p         --> Now "b" (the previous used entry) should have been
> selected, but I see that "c" (the current entry) remains selected
> instead.

So you are asking that after `isearch-edit-string' indexes of the
search ring should remain unchanged.  This is accomplished by this patch:

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2011-07-15 13:33:07 +0000
+++ lisp/isearch.el	2011-08-24 18:27:33 +0000
@@ -1131,6 +1140,9 @@ (defun isearch-edit-string ()
 	      (isearch-recursive-edit isearch-recursive-edit)
 	      ;; Save current configuration so we can restore it here.
 	      (isearch-window-configuration (current-window-configuration))
+	      ;; Save index of the search ring.
+	      (search-ring-yank-pointer search-ring-yank-pointer)
+	      (regexp-search-ring-yank-pointer regexp-search-ring-yank-pointer)
 
 	      ;; Temporarily restore `minibuffer-message-timeout'.
 	      (minibuffer-message-timeout
@@ -1152,9 +1164,14 @@ (defun isearch-edit-string ()
 
 	  (unwind-protect
 	      (let* ((message-log-max nil)
+		     ;; Protect the global search ring from updating
+		     ;; by read-from-minibuffer.  It should be updated only
+		     ;; by isearch-update-ring in isearch-done.
+		     (search-ring search-ring)
+		     (regexp-search-ring regexp-search-ring)
 		     ;; 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)
		       (cons isearch-string (1+ (isearch-fail-pos)))
                        minibuffer-local-isearch-map nil
                        (if isearch-regexp
 			   (cons 'regexp-search-ring





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Wed, 24 Aug 2011 23:25:02 GMT) Full text and rfc822 format available.

Message #110 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 25 Aug 2011 01:21:24 +0200
Hi Juri,

I think we are very close to the final/complete solution ;).

I've just applied all your patches, an tested again all use-cases.
All work very well now, except this one:

0. C-s a <RET> C-s b <RET> C-s c <RET>
1. C-s M-e <RET>    --> "c" is selected, OK [*].
2. M-p              --> Now "b" (the previous entry) should have been
selected, but I see that "c" (the current entry) remains selected
instead.



[*] FWIW: This is indeed the current behavior (use the last entry if
the minibuffer is empty), but I don't find it very suitable.  If the
user wanted to use the last entry, s?he would have typed M-p.
Therefore, IMO TRT here would be to return to Isearch with an empty
string.

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Wed, 24 Aug 2011 23:58:02 GMT) Full text and rfc822 format available.

Message #113 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 25 Aug 2011 01:54:39 +0200
Another failing use-case:

0. C-s a <RET> C-s b <RET> C-s c <RET> C-s d <RET>
1. C-s C-s        --> "d" is selected (ok).
2. M-p M-p <RET>  --> "b" is selected (ok).
3. M-p            --> "a" should have been selected, but I see that
"b" remains selected instead.

-- 
Dani Moncayo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 25 Aug 2011 09:06:02 GMT) Full text and rfc822 format available.

Message #116 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 25 Aug 2011 12:01:51 +0300
> 0. C-s a <RET> C-s b <RET> C-s c <RET>
> 1. C-s M-e <RET>    --> "c" is selected, OK [*].
> 2. M-p              --> Now "b" (the previous entry) should have been
> selected, but I see that "c" (the current entry) remains selected
> instead.

This can be easily fixed by moving `isearch-ring-adjust1' out of
let-binding of `search-ring-yank-pointer'.  But I think we should start
from the top of the search ring after `M-e RET' because we can't reliably
update the index.  See more below.

> [*] FWIW: This is indeed the current behavior (use the last entry if
> the minibuffer is empty), but I don't find it very suitable.  If the
> user wanted to use the last entry, s?he would have typed M-p.
> Therefore, IMO TRT here would be to return to Isearch with an empty
> string.

I suppose the last entry is used because otherwise an empty search
string makes no sense.  I have nothing against this functionality
because I never exit from the M-e minibuffer with empty input.

> Another failing use-case:
> 0. C-s a <RET> C-s b <RET> C-s c <RET> C-s d <RET>
> 1. C-s C-s        --> "d" is selected (ok).
> 2. M-p M-p <RET>  --> "b" is selected (ok).
> 3. M-p            --> "a" should have been selected, but I see that
> "b" remains selected instead.

We can't reliably count the number of typed M-p in `read-from-minibuffer'
in `isearch-edit-string' to adjust the index accordingly and to add the
same number of typed M-p to the index.  There is no reliable way to do this:
we could try to find the input string in the history (search ring) and
add its index to `search-ring-yank-pointer', but what to do when the user
types the same string that exists in the history - then the index
in the search ring will be incorrect.

Since `read-from-minibuffer' can't return the exact number of typed `M-p'
then I think that M-p after `M-e M-p M-p <RET>' should start from the
top of of the search ring, so `C-s C-s M-p M-p RET M-p' should select "d".
This will provide a predictable result.

OTOH, when `search-ring-update' is non-nil, `isearch-edit-string' is not used,
so everything works correctly.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Thu, 25 Aug 2011 10:13:01 GMT) Full text and rfc822 format available.

Message #119 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9185 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 25 Aug 2011 12:10:14 +0200
>> [*] FWIW: This is indeed the current behavior (use the last entry if
>> the minibuffer is empty), but I don't find it very suitable.  If the
>> user wanted to use the last entry, s?he would have typed M-p.
>> Therefore, IMO TRT here would be to return to Isearch with an empty
>> string.
>
> I suppose the last entry is used because otherwise an empty search
> string makes no sense.

It makes sense, I think: by "to set an empty search string" I mean to
return to the same state that had at the very beginning the Isearch
session, i.e., as if the user had deleted the current search string by
typing <DEL> repeatedly.

> I have nothing against this functionality
> because I never exit from the M-e minibuffer with empty input.

Neither me.  So this is not a very important issue (at least to us),
and we can leave it for now.  But I believe that setting an empty
search string would be TRT in that case.

>> Another failing use-case:
>> 0. C-s a <RET> C-s b <RET> C-s c <RET> C-s d <RET>
>> 1. C-s C-s        --> "d" is selected (ok).
>> 2. M-p M-p <RET>  --> "b" is selected (ok).
>> 3. M-p            --> "a" should have been selected, but I see that
>> "b" remains selected instead.
>
> We can't reliably count the number of typed M-p in `read-from-minibuffer'
> in `isearch-edit-string' to adjust the index accordingly and to add the
> same number of typed M-p to the index.  There is no reliable way to do this:

As you know, I still lack the knowledge of Elisp to help you in
implementation details, so I can say very little about this.  But I
think I should be possible to implement, since the intended behavior
is well defined and relatively simple:
* At the beggining of the Isearch session, the index would start at
the top of the ring (as does now).
* During the Isearch session, each typed M-p/M-n should use the index
to retrieve the suitable entry, and then should update the index,
regardless of whether we are in the minibuffer or outside it.

IMO, this is the behaviour most users would expect.  But if you find
it difficult to implement, you can adopt (by now) the alternative
behavior you've pointed out:

> Since `read-from-minibuffer' can't return the exact number of typed `M-p'
> then I think that M-p after `M-e M-p M-p <RET>' should start from the
> top of of the search ring, so `C-s C-s M-p M-p RET M-p' should select "d".
> This will provide a predictable result.

Since this is a different issue than the original one of this bug
report, I could file a separate bug asking for the wanted behavior.
WDYT?

-- 
Dani Moncayo




Message #120 received at 9185-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 9185-done <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Thu, 25 Aug 2011 23:34:20 +0300
> * During the Isearch session, each typed M-p/M-n should use the index
> to retrieve the suitable entry, and then should update the index,
> regardless of whether we are in the minibuffer or outside it.

We can't count the number of typed M-p/M-n in the minibuffer
activated by `read-from-minibuffer' in `isearch-edit-string'
because `read-from-minibuffer' lacks this functionality.

One way would be to let `read-from-minibuffer' return
the selected history element in the same format (HISTVAL . HISTPOS)
as used for its input argument HIST.

But I doubt that it makes sense to implement this for consistency
of the rarely used search ring browsing with M-p/M-n in Isearch.

> Since this is a different issue than the original one of this bug
> report, I could file a separate bug asking for the wanted behavior.
> WDYT?

You could file a separate feature request or reopen this bug report
only when someone will propose a good idea that would make sense
to implement.  Or when you discover a new bug.

I committed the fix I already posted here yesterday for the previous
problem with comments explaining the remaining problem.

So I'm closing this bug report since most bugs you reported
are fixed now.  Thank you for your help to improve Emacs.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 23 Sep 2011 11:24:04 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Juri Linkov <juri <at> jurta.org> to control <at> debbugs.gnu.org. (Sat, 19 Nov 2011 19:49:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9185; Package emacs. (Sat, 19 Nov 2011 20:03:02 GMT) Full text and rfc822 format available.

Message #127 received at 9185 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 9185 <at> debbugs.gnu.org
Subject: Re: bug#9185: 24.0.50;
	"C-s M-p" does not bring the tip of the search ring
Date: Sat, 19 Nov 2011 21:59:58 +0200
>> But I've found another use-case that seems to need a fix too:
>> 0. C-s a <RET> C-s b <RET> C-s c <RET>
>> 1. C-s C-s     --> "c" is selected, OK.
>> 2. M-p <RET>   --> "b" is selected, OK.
>> 3. M-p         --> Now "c" (the previous used entry) should have been
>> selected, but I see that "b" (the current entry) remains selected
>> instead.
>
> This is a separate problem caused when exiting from the minibuffer in
> `isearch-edit-string' by `read-from-minibuffer' (i.e. step 2
> `M-p <RET>' above) adds a new element "b" to the history (search ring).
>
> I agree that `isearch-edit-string' should not update the search ring.
> It should be updated only by `isearch-update-ring' in `isearch-done'.
> So e.g. `C-s C-s M-e RET C-g' or `C-s M-p RET C-g' should keep the
> search ring unchanged.  Note also that `isearch-done' with the arg
> NOPUSH=t already tries to take care of not updating the search ring,
> but unsuccessfully.  It requires the following patch for the complete fix:

I noticed now that `isearch-edit-string' should not add new elements
to the search ring, but should allow old elements to be deleted
from the search ring with a command like `delete-history-element'
(published in http://thread.gmane.org/gmane.emacs.devel/24353/focus=25269)
So I installed another fix that let-binds `history-add-new-input' to nil.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 18 Dec 2011 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 137 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.