From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#46469: 27.1; `isearch-del-char' should move point further back Date: Tue, 27 Apr 2021 20:44:32 +0200 Message-ID: <875z074lf3.fsf@gmail.com> References: <87zh09xggr.fsf@gmail.com> <87eehjstt9.fsf@mail.linkov.net> <87a6s7nngp.fsf@gmail.com> <87sg5yekf6.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18270"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cc: 46469@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 27 20:46:39 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lbSjG-0004T7-Ss for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Apr 2021 20:46:38 +0200 Original-Received: from localhost ([::1]:35968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbSjG-0000oD-0O for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Apr 2021 14:46:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbShi-0008H4-Bn for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 14:45:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbShi-0008Lt-41 for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 14:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lbShi-0004c9-2p for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 14:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 27 Apr 2021 18:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46469 X-GNU-PR-Package: emacs Original-Received: via spool by 46469-submit@debbugs.gnu.org id=B46469.161954908217688 (code B ref 46469); Tue, 27 Apr 2021 18:45:02 +0000 Original-Received: (at 46469) by debbugs.gnu.org; 27 Apr 2021 18:44:42 +0000 Original-Received: from localhost ([127.0.0.1]:50885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbShO-0004bD-66 for submit@debbugs.gnu.org; Tue, 27 Apr 2021 14:44:42 -0400 Original-Received: from mail-ej1-f44.google.com ([209.85.218.44]:38826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbShN-0004b1-Ac for 46469@debbugs.gnu.org; Tue, 27 Apr 2021 14:44:41 -0400 Original-Received: by mail-ej1-f44.google.com with SMTP id r12so90933418ejr.5 for <46469@debbugs.gnu.org>; Tue, 27 Apr 2021 11:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=P/u9tsiFPXF4Bft9B/aQV7+J6QG91I/INhvhlJkYBfM=; b=ETljpMcRKe3UatrzLKHWSH5dRU2ud59tgxgHfYKEpMM69MnMd2Qo0yUZDovv76REr+ +VVuzMNjaI+AtMTCuq9XEy1GOLFEOjCo6U1ce6+twl1zBaRUClLCXt1vZov22NSyNhOE niwWCryayidig3MUMYFBTg2eYNPUveHRMijtg4QgycIOShQLRRlLKRnliNsWhYw1lqxT b7h0CRqgSLlr4s+KgwxltWsxa7v5tsOrXAcVWFyZbvGLKmcJ23KgX11ZJhsi5Lxq9kE4 W5+5QQtHQi/A0TJ2iHcExH0mHd/VhUhtpPjzWxP0TzfaQTqvV+GbYGLA/hJulIOfq+lh 9LLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=P/u9tsiFPXF4Bft9B/aQV7+J6QG91I/INhvhlJkYBfM=; b=JQ23GoqrbXNheiyasoP4JR5OH42NWx15GJf3OZg0Io9/BnS8tM2h6I7sCgbJm2lAzu ZYOorB5ei7yJqfamuHXYTiMoRyTQqHIkAIa6yt7gfX71dY6L/1QtWmz++DV0C+sL7nJV gLlhbDpI1jveaBiWSQWRVQMve0uN9e9ZjWzFmySgUMHO/LwWHOQAeW08wKRD+Cg3n5Ur bPtStbgxXIPL+D7CJYmGOMfcSgAzEM+6mPAZvNA/jvFLo90X7a3ogaoFWgmySXbTIbAn EmN0WHvaPt5x9spbcV7nGhAKqq35yRw+K3XqeUhS/Rhy8HQZyGqTrzbosSpPTlY6rSXa If7A== X-Gm-Message-State: AOAM532lo+BIrX+h17R/0302DoeWmHivqTTPxYvGf2f5nzKjL48xi75A pBBgpO69YPMfuc4sd67pIfXBaGcw3zs= X-Google-Smtp-Source: ABdhPJzOL7sdQ9TTxyuRxrlNgrAnw5BFIpqpOsxyvmxOeNzh6/Gy+QG+yNpnCBueY5vleyFH+rqhYA== X-Received: by 2002:a17:906:590b:: with SMTP id h11mr12491865ejq.147.1619549075157; Tue, 27 Apr 2021 11:44:35 -0700 (PDT) Original-Received: from ars3 ([2a02:908:2211:8540::68a]) by smtp.gmail.com with ESMTPSA id sb20sm388519ejb.100.2021.04.27.11.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 11:44:34 -0700 (PDT) In-Reply-To: <87sg5yekf6.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 14 Feb 2021 19:45:37 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205042 Archived-At: --=-=-= Content-Type: text/plain For the record, the search ring advance/retreat commands suffer from a bug similar to the `isearch-del-char' one described here. Namely, `C-s M-p M-p M-p' presumably takes you to the first match, after the starting point, of the third history element. It would be very strange to expect that the result of this key sequence depends on the first and second history elements, or on the contents of the buffer beyond the first match of the third history element. And, in fact, everything is fine when `search-ring-update' is nil. However: (progn (setq search-ring-update t search-ring '("1" "2" "3") search-ring-yank-pointer nil) (save-excursion (insert "expect point here -> 3 2 1 2 3 <- but instead get here")) (isearch-mode t) (isearch-ring-retreat) (isearch-ring-retreat) (isearch-ring-retreat)) On Sun, 14 Feb 2021 at 19:45, Juri Linkov wrote: > I tried again, but your patch still doesn't work. With > > (progn > (define-key isearch-mode-map (kbd "DEL") 'isearch-del-char) > (execute-kbd-macro [?\C-s ?y backspace ?x ?1])) > x1yx2 > > It signals the error "Keyboard macro terminated by a command ringing the bell". Now I see, my old patch only worked in regexp mode (which is `C-s' for me). The attached one seems to work (but this is subtle stuff, there may be edge cases). --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Make-isearch-del-char-backtrack-the-search-more-aggr.patch >From a29f3c0b2b43af6b9c283205643a1e2ac43030b7 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Fri, 12 Feb 2021 19:37:14 +0100 Subject: [PATCH] Make `isearch-del-char' backtrack the search more aggressively This allows to always find the first occurrence of the search string after the last `isearch-repeat' or the start of search. * lisp/isearch.el (isearch-del-char): Go to barrier before updating the search. --- lisp/isearch.el | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lisp/isearch.el b/lisp/isearch.el index 9f3cfd70fb..f6a55c7918 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2505,13 +2505,12 @@ isearch-del-char isearch-string ""))) ;; Do the following before moving point. (funcall (or isearch-message-function #'isearch-message) nil t) - ;; Use the isearch-other-end as new starting point to be able - ;; to find the remaining part of the search string again. - ;; This is like what `isearch-search-and-update' does, - ;; but currently it doesn't support deletion of characters - ;; for the case where unsuccessful search may become successful - ;; by deletion of characters. - (if isearch-other-end (goto-char isearch-other-end)) + ;; Go to `isearch-barrier' to be able to find an earlier occurrence + ;; of the remaining part of the search string. + (if isearch-regexp + (isearch-fallback nil nil t) + (goto-char isearch-barrier) + (setq isearch-adjusted t)) (isearch-search) (isearch-push-state) (isearch-update)) -- 2.30.2 --=-=-=--