From: Lars Ingebrigtsen <larsi@gnus.org>
To: Ergus <spacibba@aol.com>
Cc: 50466@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#50466: 28.0.50; isearch isearch-repeat-on-direction-change vs isearch-beginning-of-buffer
Date: Wed, 08 Sep 2021 08:01:55 +0200 [thread overview]
Message-ID: <871r5z8v1o.fsf@gnus.org> (raw)
In-Reply-To: <87zgsnzz8k.fsf@aol.com> (Ergus's message of "Wed, 08 Sep 2021 02:29:15 +0200")
Ergus <spacibba@aol.com> writes:
> (setq isearch-repeat-on-direction-change t)
> (define-key isearch-mode-map (kbd "M-<") #'isearch-beginning-of-buffer)
>
> If I have the cursor on the beginning of:
>
> 1abc
> 2abc
> 3abc
> 4abc
>
> and do
>
> C-s abc ;; cursor at the end of 1abc
> C-s ;; cursor at the end of 2abc
> C-s ;; cursor at the end of 3abc
> C-r ;; cursor at the beginning of 2abc
> M-< ;; cursor at the end of 3abc <- this is wrong
>
> The cursor goes to the end of 3abc (next candidate) instead of 1abc
> (first) as expected from isearch-beginning-of-buffer.
Simpler reproduction: Go to the end of the 3abc line and
C-r abc
M-<
That'll take you to the end of 4abc. And it's because:
(defun isearch-beginning-of-buffer (&optional arg)
[...]
(setq isearch-just-started t)
(goto-char (point-min))
(isearch-repeat 'forward arg)))
(defun isearch-repeat (direction &optional count)
[...]
;; C-s in reverse or C-r in forward, change direction.
(if (and isearch-other-end isearch-repeat-on-direction-change)
(goto-char isearch-other-end))
The following patch seems to fix the problem:
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 1c776a06e1..6abd12700c 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1898,7 +1898,8 @@ isearch-repeat
(funcall isearch-wrap-function)
(goto-char (if isearch-forward (point-min) (point-max))))))
;; C-s in reverse or C-r in forward, change direction.
- (if (and isearch-other-end isearch-repeat-on-direction-change)
+ (if (and isearch-other-end isearch-repeat-on-direction-change
+ (not isearch-just-started))
(goto-char isearch-other-end))
(setq isearch-forward (not isearch-forward)
isearch-success t))
But I'm not really very familiar with the isearch machinery, so I've
added Juri to the CCs; perhaps he has a comment here.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2021-09-08 6:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87zgsnzz8k.fsf.ref@aol.com>
2021-09-08 0:29 ` bug#50466: 28.0.50; isearch isearch-repeat-on-direction-change vs isearch-beginning-of-buffer Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-08 6:01 ` Lars Ingebrigtsen [this message]
2021-09-09 19:15 ` Juri Linkov
2021-09-10 10:44 ` Lars Ingebrigtsen
2021-09-13 18:18 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871r5z8v1o.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=50466@debbugs.gnu.org \
--cc=juri@linkov.net \
--cc=spacibba@aol.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).