1

I am trying to write a function which will perform a bookmark-jump but then reset the the bookmark line to the top of the screen. So far I have:

  (defun foo ()
    (interactive)
    (bookmark-jump)
    (evil-scroll-line-to-top nil)
    )

  (define-key evil-normal-state-map [f9] 'foo)

But hitting F9 gives this message. What am I doing wrong please?

enter image description here

Drew
  • 75,699
  • 9
  • 109
  • 225
user2567544
  • 291
  • 1
  • 9

1 Answers1

0

Your command needs to call bookmark-jump interactively, so it can prompt for the bookmark you want to jump to. It requires a bookmark, to know where to take you.

(defun foo ()
    (interactive)
    (call-interactively #'bookmark-jump)
    (message "XXXXXXXXXX"))

On the other hand, if you always want foo to jump to the same bookmark, and you know which bookmark that is:

(defun foo ()
    (interactive)
    (bookmark-jump "my-bookmark-name")
    (message "XXXXXXXXXX"))
Drew
  • 75,699
  • 9
  • 109
  • 225
  • Thanks, I think this is what I need. I notice an issue though, which occurs calling the first foo function above and when doing `M-x bookmark-jump`: if the bookmark is in a buffer other than the visible one, the bookmarked buffer gets focus but the cursor position is unchanged - in other words the jump visits the correct buffer but not the correct location. – user2567544 Oct 23 '20 at 18:57
  • You comment suggests a bug somewhere. Is this Emacs bug #[44185](https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44185)? Does your recipe's "Start Emacs" use `emacs -Q`? If not, provide a recipe to repro the problem that does start with that (i.e., no init file). – Drew Oct 23 '20 at 22:10
  • Yes, I submitted that bug report. Apologies if the recipe did not start with with emacs -Q, it should have. – user2567544 Oct 23 '20 at 23:22