1

I am trying to apply following solution(How to jump to backward found word when switched into reverse incremental search?) into Emacs >27.1, (which works in emacs 26.3):

(define-advice isearch-repeat (:before (direction) goto-other-end)
  "If reversing, start the search from the other end of the current match."
  (unless (eq isearch-forward (eq direction 'forward))
    (when isearch-other-end
      (goto-char isearch-other-end))))

But I am having following error message when I use emacs >27.1:

Wrong number of arguments: (lambda (direction) "If reversing, start the search \
from the other end of the current match." (if (eq isearch-forward (eq direction\
 'forward)) nil (if isearch-other-end (progn (goto-char isearch-other-end))))),\
 2

How could I fix this error?

1 Answer 1

1
  1. It's always more informative to set debug-on-error to t and repro the error, then post the backtrace (at least the beginning). That will show the complete error message, which tells what function raised the error and how many args it expected versus how many it received.

  2. After Emacs 26.3, function isearch-repeat, which you are advising, and whose advice accepts only one argument, was changed to accept either one or two args.

(defun isearch-repeat (direction) ; Emacs 26.3
(defun isearch-repeat (direction &optional count) ; Emacs 27.1 and later

So try this - it matches the lambda list of the Emacs 27 isearch-repeat:

(define-advice isearch-repeat (:before (direction &optional count) goto-other-end)
  "If reversing, start the search from the other end of the current match."
  (unless (eq isearch-forward (eq direction 'forward))
    (when isearch-other-end
      (goto-char isearch-other-end))))
2
  • Can I also keep the function for 26.3 under` (if (version< "27.0" emacs-version)` condition?. I have tried something as follows which didn't work: gist.github.com/avatar-lavventura/…
    – alper
    Commented Jul 23, 2021 at 16:52
  • 1
    I think you have (version< "27.0" emacs-version), but what you're saying is that you really want (version< emacs-version "27.0")
    – Drew
    Commented Jul 23, 2021 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.