all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: 46469@debbugs.gnu.org
Subject: bug#46469: 27.1; `isearch-del-char' should move point further back
Date: Tue, 27 Apr 2021 20:44:32 +0200	[thread overview]
Message-ID: <875z074lf3.fsf@gmail.com> (raw)
In-Reply-To: <87sg5yekf6.fsf@mail.linkov.net> (Juri Linkov's message of "Sun,  14 Feb 2021 19:45:37 +0200")

[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]

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 <juri@linkov.net> 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).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-isearch-del-char-backtrack-the-search-more-aggr.patch --]
[-- Type: text/x-patch, Size: 1591 bytes --]

From a29f3c0b2b43af6b9c283205643a1e2ac43030b7 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
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


  reply	other threads:[~2021-04-27 18:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-12 18:56 bug#46469: 27.1; `isearch-del-char' should move point further back Augusto Stoffel
2021-02-12 20:00 ` Eli Zaretskii
2021-02-12 20:20   ` Augusto Stoffel
2021-02-13  7:04     ` Eli Zaretskii
2021-02-13  7:32       ` Augusto Stoffel
2021-02-13  8:59         ` Eli Zaretskii
2021-02-13  9:53           ` Augusto Stoffel
2021-02-13 13:28             ` Eli Zaretskii
2021-02-13 23:14           ` bug#46469: [External] : " Drew Adams
2021-02-14  3:42             ` Eli Zaretskii
2021-02-14  7:18               ` Augusto Stoffel
2021-02-14 15:24                 ` Eli Zaretskii
2021-02-14 17:49                 ` Juri Linkov
2021-02-15 19:31                   ` Augusto Stoffel
2021-02-15 19:41                     ` Eli Zaretskii
2021-02-13 18:31 ` Juri Linkov
2021-02-14  7:00   ` Augusto Stoffel
2021-02-14 17:45     ` Juri Linkov
2021-04-27 18:44       ` Augusto Stoffel [this message]
2021-04-28 20:53         ` Juri Linkov
2021-04-28 21:16           ` Augusto Stoffel
2021-04-28 21:37             ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875z074lf3.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=46469@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.