From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: isearch-push-state (was: First two elements of search-ring shown twice in minibuffer when using M-p multiple times?) Date: Mon, 10 Mar 2008 19:59:57 +0200 Organization: JURTA Message-ID: <878x0q1n2q.fsf_-_@jurta.org> References: <87myp99rd3.fsf@jurta.org> <87od9n36ew.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1205172737 446 80.91.229.12 (10 Mar 2008 18:12:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Mar 2008 18:12:17 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 10 19:12:45 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JYmUA-0000BS-4N for ged-emacs-devel@m.gmane.org; Mon, 10 Mar 2008 19:12:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JYmTb-0003ND-NR for ged-emacs-devel@m.gmane.org; Mon, 10 Mar 2008 14:11:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JYmTX-0003Mj-Pj for emacs-devel@gnu.org; Mon, 10 Mar 2008 14:11:51 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JYmTU-0003LS-A1 for emacs-devel@gnu.org; Mon, 10 Mar 2008 14:11:51 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JYmTU-0003LM-3T for emacs-devel@gnu.org; Mon, 10 Mar 2008 14:11:48 -0400 Original-Received: from relay01.kiev.sovam.com ([62.64.120.200]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JYmTT-0008Fl-Uj for emacs-devel@gnu.org; Mon, 10 Mar 2008 14:11:48 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay01.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1JYmTI-0001FK-Ab for emacs-devel@gnu.org; Mon, 10 Mar 2008 20:11:44 +0200 In-Reply-To: <87od9n36ew.fsf@jurta.org> (Juri Linkov's message of "Sun, 09 Mar 2008 23:59:35 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-unknown-linux-gnu) X-Scanner-Signature: b565934a9b6505813531773f2f5625c7 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 2374 [Mar 9 2008] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 11 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.8-5.1 (or MacOS X 10.2-10.3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:92079 Archived-At: The recent change that highlights the failed part of the search string helped to discover the following bug: typing `C-s M-e foo C-s' (where `foo' is a string that doesn't exist in the current buffer) doesn't highlight the failed search string in the isearch-fail face after exiting from the edit-string minibuffer. This is because `isearch-edit-string' puts the wrong search state to the search status stack. It calls `isearch-push-state' that stores the new search string (that will fail to find) and the old successfull state to `isearch-cmds'. There are two calls of `isearch-push-state' in `isearch-edit-string' and I think the first one is unnecessary because the state before M-e is already recorded on the stack. I also discovered another bug that the ring advancing command M-p puts one unnecessary search state to the search status stack, but this is only necessary when `search-ring-update' is non-nil. Otherwise, `isearch-edit-string' already has the call to `isearch-push-state'. I tried different test cases and see no possible scenario that there the following patch would fail: 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 10 Mar 2008 17:56:09 -0000 *************** *** 1096,1104 **** ;; Only the string actually used should be saved. )) - ;; Push the state as of before this C-s. - (isearch-push-state) - ;; Reinvoke the pending search. (isearch-search) (isearch-push-state) --- 1081,1086 ---- *************** *** 1895,1904 **** (if search-ring-update (progn (isearch-search) (isearch-update)) ! (isearch-edit-string) ! ) ! (isearch-push-state)) (defun isearch-ring-advance () "Advance to the next search string in the ring." --- 1887,1895 ---- (if search-ring-update (progn (isearch-search) + (isearch-push-state) (isearch-update)) ! (isearch-edit-string))) (defun isearch-ring-advance () "Advance to the next search string in the ring." -- Juri Linkov http://www.jurta.org/emacs/