0
  1. Add the following to .spacemacs:
      (defun my-bookmark-set (char)
        (interactive "cPlease enter a bookmark name to set: ")
        (bookmark-set (char-to-string char)))

      (defun my-bookmark-jump (char)
        (interactive "cPlease enter a bookmark name to jump to: ")
        (bookmark-jump (char-to-string char)))

      (define-key evil-normal-state-map (kbd "'") 'my-bookmark-jump)
      (define-key evil-normal-state-map (kbd "m") 'my-bookmark-set)
  1. Set a bookmark a with C-x r m a or ma, and quit and restart emacs

  2. Navigation to bookmark a fails with "Invalid bookmark a" displayed

'a
  1. Navigation to bookmark a succeeds
C-x r b a
  1. Move cursor to another location

  2. Navigation to bookmark a succeeds

'a 

Why does the action at step 3. fail, when at step 6. and subsequently it succeeds?

2 Answers 2

0

Your problem is that bookmark-jump doesn't load the bookmark file, and until that happens your bookmark is unknown.

If you check the interactive declaration for that function, you'll see that it uses bookmark-completing-read which in turn calls bookmark-maybe-load-default-file which is what you also need to do if you're not going to use the same method of reading the bookmark name.

(defun my-bookmark-jump (char)
  "Jump to bookmark CHAR."
  (interactive "cPlease enter a bookmark name to jump to: ")
  (require 'bookmark)
  (bookmark-maybe-load-default-file)
  (bookmark-jump (char-to-string char)))
0

It's not clear what error you're getting, and when. First you say that you get an Invalid bookmark error, without providing a recipe. Then you provide a recipe, I think, for the void-function-definition error. What's the real problem/question?


Anyway, ignoring the invalid-bookmark problem, do you see the same void-function-definition problem if you start Emacs using emacs -Q (no init file)? If not, bisect your init file to find the culprit.

If you do see the same thing, do M-x debug-on-entry my-bookmark-jump and show the Backtrace you get when you invoke my-bookmark-jump.

Your Answer

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

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