emacs bookmark+ :How to create a file specific bookmark file?

1.3k Views Asked by At

bookmark+ package provides a (bmkp-this-file-bmenu-list) function. This, I suppose, loads a file specific bookmark file and filters only the bookmarks, which relate to the file.

Question: how to create this specific bookmark file for a specific file?

The result should be a filtered list of bookmarks, when using C-x p , command (which is bound to (bmkp-this-file-bmenu-list) ).

Edit: I use only one default bookmark file ~/.emacs.d/bookmarks. This file has some bookmarks for ~/.emacs file. Now, when I visit, say, ~/.emacs file, then run C-x p ,, I get the following error: bmkp-this-file-bmenu-list: No bookmarks for file ~/.emacs.

2

There are 2 best solutions below

4
On BEST ANSWER

No, actually, command bmkp-this-file-bmenu-list does this (from the doc string):

Show the bookmark list just for bookmarks for the current file.
Set `bmkp-last-specific-file` to the current file name.
If the current buffer is not visiting a file, prompt for the file name.

It shows the *Bookmark List* display, listing only and all bookmarks that target the current file.

So if you use this command in a file buffer then you see displayed, in buffer *Bookmark List*, all of the bookmarks to the current file, and only those bookmarks.

This has nothing to do with using a different bookmark file.


Beyond what this command does, it's not clear to me what behavior you would like. What, for instance, do you mean by a "specific bookmark file for a specific file"?

4
On

You can create a different bookmark file using bookmark+ with M-x bookmark-load. You will be prompted for a filename. You can either merge bookmarks from different files or replace the current bookmark set entirely with this fileset by supplying a prefix argument.

Saving bookmarks bookmark-save will write all current bookmarks to the current value of the variable bmkp-current-bookmark-file , or if you supply a prefix arg you can choose a bookmark filename to save them to.

If you want a set of bookmarks in a distinct file, associated with particular files you could perhaps achieve this by running bookmark-load , and bookmark-save with prefixes. You could probably even automate this with hooks to match your editing contexts, although I expect that would be a little fiddly to achieve.

It sounds like your question might be rooted in some confusion about existing bookmark behaviour, and perhaps you don't even need to maintain separate bookmark files.