From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs 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 Organization: JURTA Message-ID: <87liukxxtj.fsf@mail.jurta.org> References: <87livig3cr.fsf@mail.jurta.org> <87r55aenuc.fsf@mail.jurta.org> <87oc0c176d.fsf@mail.jurta.org> <87fwkuppz3.fsf@mail.jurta.org> <8739gtg0wp.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1314093346 28242 80.91.229.12 (23 Aug 2011 09:55:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 23 Aug 2011 09:55:46 +0000 (UTC) Cc: 9185@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 23 11:55:42 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qvnhs-0005QF-Gu for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Aug 2011 11:55:40 +0200 Original-Received: from localhost ([::1]:47175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qvnhr-0007RQ-Qv for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Aug 2011 05:55:39 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:60752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qvnho-0007RH-Vc for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2011 05:55:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qvnhn-0000Ua-Ow for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2011 05:55:36 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qvnhn-0000UW-MD for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2011 05:55:35 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QvnkA-0000q2-5p; Tue, 23 Aug 2011 05:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Aug 2011 09:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9185 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9185-submit@debbugs.gnu.org id=B9185.13140934273131 (code B ref 9185); Tue, 23 Aug 2011 09:58:02 +0000 Original-Received: (at 9185) by debbugs.gnu.org; 23 Aug 2011 09:57:07 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QvnjH-0000oS-BZ for submit@debbugs.gnu.org; Tue, 23 Aug 2011 05:57:07 -0400 Original-Received: from smarty.dreamhost.com ([208.113.175.8]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QvnjE-0000oK-Uk for 9185@debbugs.gnu.org; Tue, 23 Aug 2011 05:57:05 -0400 Original-Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id 3B24E6E80B4; Tue, 23 Aug 2011 02:54:37 -0700 (PDT) Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 1CE64451C3F6; Tue, 23 Aug 2011 02:54:35 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Mon, 22 Aug 2011 17:34:08 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 23 Aug 2011 05:58:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:50242 Archived-At: > 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)