1

I created a bookmark-file bookmark, with Bookmark+. Now when I open it using C-u C-x j y I need to answer 3 questions:

Jump to bookmark-file bookmark (test): <enter>
SWITCH to new bookmark file, instead of just adding it? (y or n) y
Save current bookmarks before loading? (y or n) y

How to get rid of these questions and just silently load the file answering y everywhere?

2
  • Are you talking about Emacs' built-in Bookmarks? And what is C-x j? Vanilla Emacs doesn't have such key binding.
    – xuchunyang
    Commented Apr 22, 2018 at 12:17
  • 1
    @xuchunyang: OP is using Bookmark+, where C-x j y is bound, by default, to bmkp-bookmark-file-jump, which loads a bookmark file.
    – Drew
    Commented Apr 22, 2018 at 16:10

1 Answer 1

1

Use a command such as this one, binding it to a key:

(defun my-bookmark-file-switch (bookmark)
  "Prompt for a bookmark-file BOOKMARK and switch to that bookmark file."
  (interactive
   (let ((alist  (bmkp-bookmark-file-alist-only)))
     (list (bmkp-read-bookmark-for-type "bookmark-file" alist nil nil
                                        'bmkp-bookmark-file-history))))
  (let ((file  (bookmark-prop-get bookmark 'bookmark-file)))
    (bookmark-load file t 'save)))

This command first saves the current bookmark list to the current bookmark file, before switching to the new bookmark file. If you do not want that behavior (you want to just abandon any unsaved changes to the current bookmark list) then replace save in this code with just t.

But as always, back up your current bookmark file before trying this or other new bookmark code.


UPDATE:

I've now added these two commands to Bookmark+: bmkp-bookmark-file-load-jump, bmkp-bookmark-file-switch-jump They are like bmkp-bookmark-file-jump (C-x j y), but they do not prompt for prior saving or confirmation. The second of these is what you requested.

7
  • "I've now added these two commands to Bookmark+" - where can I see the new file? git repository is not modified
    – user4035
    Commented Apr 22, 2018 at 20:47
  • Your function works, but the contents of the bookmarks list is not updated. I need to close the list and load it again manually using bookmark-bmenu-list
    – user4035
    Commented Apr 22, 2018 at 20:47
  • No, you don't need to do that - just hit g. And bmkp-bookmark-file-switch-jump does that automatically. Why didn't you update bookmark+-1.el?
    – Drew
    Commented Apr 22, 2018 at 21:36
  • Tried your function. It works, but still asks a question: "Jump to bookmark-file bookmark (teat):" Is it possible to get rid of this as well?
    – user4035
    Commented Apr 23, 2018 at 19:34
  • No. It's asking you which bookmark-file bookmark you want to use, that is, which bookmark file you want to switch to. The default is the last one you used, other than the current one. If that's what you want then just hit RET.
    – Drew
    Commented Apr 23, 2018 at 21:20

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.