Creating bookmarks in different emacs instances leads to loss of bookmarks data. Is there an easy way to fix this?
Something like merge current bookmark data with bookmark data from bookmarks file, before saving a new bookmarks-file version, would be nice.

Step by step example to reproduce:

  1. run two emacs instances at once via command line: emacs -Q & emacs -Q
  2. on each instance open an existing bookmark (C-x r b)
  3. on each instance create a new bookmark (C-x r m) with different locations. On one instance name the bookmark test1 on the other instance name it test2
  4. close the emacs instance with bookmark test1
  5. close the other emacs instance with bookmark test2
  6. open a new emacs instance with: emacs -Q
  7. get a list of all bookmarks with C-x r l, you will see that bookmark test1 is lost

2 Answers 2


After you create or update a bookmark you need to save the bookmark file, or the change will be lost. You can have Emacs save it automatically when you quit Emacs, or you can save it anytime, by program or interactive (command bookmark-save).

But if you want to be sure, in a separate Emacs session, to get the latest saved bookmark file, then you should reload the file before you add a new bookmark or update an existing bookmark.

In other words, it's like for any situation of synchronizing two things. (Re-)load just before you create or update, and save just after you create or update.

(If you are the only one accessing the bookmark file then at least you don't need to worry about simultaneous access and other real synchronization problems.)

Be aware that you can put loading and saving on various hooks. These hooks are available with Bookmark+, for example:

bmkp-read-bookmark-file-hook  (option)
bmkp-temporary-bookmarking-mode-hook  (option) 
bmkp-write-bookmark-file-hook  (option)

The ones whose names start with bmkp- are specific to Bookmark+. The ones whose names start with bookmark are available also in vanilla Emacs.

Another thing you can do is to use two or more bookmark files. Bookmark+ makes it easy to do this. You can load a second bookmark file either to replace the set of bookmarks currently available in your session or to augment it.

In two simultaneous sessions you could thus use two different bookmark files. But if you intend to deal with the same bookmark in both files then you run into the same problem discussed above. That is, using multiple bookmark files for harmonizing two different sessions won't help with any bookmark that is common to both files.

A wild guess whispers to me that you might not be using Emacs the way you should, for your use case. Maybe instead of multiple, simultaneous Emacs sessions you should use emacsclient or Emacs daemon, with a single session. Then you won't have any such need for synchronization.

Update after your comment, including "Emacs buffers are a mess if multiple projects have the same filenames":

  1. You can likely use emacslient or Emacs daemon with no change from how you are using multiple sessions (except without the problem you asked about).

  2. With Bookmark+ you can bookmark Emacs desktops (in addition to bookmarking Dired sets of files and directories). So different bookmarks put you in different projects (or even different views of the same project) - different variables, buffers, etc.

  3. With Bookmark+ you can have multiple bookmarks with the same name. In particular, you can have autofiles, which are bookmarks whose names are the same as their non-directory file names. They can be created automatically, if you like. You can treat them like files, and you can also treat them like bookmarks (e.g. tag them, or put them in particular bookmark files/lists).

  • Thank you for the detailed, answer! I hoped there is a more automatic solution available. I considered using bmkp but it looks heavy and I'm interested only in the Tags feature. As for my emacs usage: I use several instances to separate projects (students homeworks with a provided framework). Emacs buffers are a mess if multiple projects have the same filenames and even ibuffer only slightly improves this.
    – jue
    Jul 19, 2018 at 10:07
  • I updated the post with a bit more info, responding to your comment. HTH.
    – Drew
    Jul 19, 2018 at 13:57
  • I'm sure that Bookmark+ is great software. I just don't see me using those features, I have read the emacswiki page. It took me even years to see a use for plain emacs bookmarks. Following is quite of topic: how could emacsclient or daemon help separating the files. I have several emacs instances because I look and edit in those at the same time. Using multiple instances simply prevents me from selecting or editing the wrong file with the same name. The different directory name is not enough because they are called in a way like this: 2018-07-01-group001 and 2018-07-03-group032
    – jue
    Jul 19, 2018 at 15:33
  • Dunno whether emacsclient or Emacs daemon will help. Have you tried using uniquify.el (standard library)? Customize option uniquify-buffer-name-style to your liking. That should let you keep buffers for the same file name straight.
    – Drew
    Jul 19, 2018 at 20:32

A simpler solution is just to add this to your dot Emacs file:

'(bookmark-save-flag 0)

  • 2
    The above Elisp snippet does not do anything at all on its own. You likely copy&pasted it from your .emacs where it's probably placed within a custom-set-variables.
    – Stefan
    Feb 25, 2019 at 14:01
  • Can you change your snippet to one that will actually work? You probably want to call setq to have a standalone solution to the problem.
    – user12563
    Feb 25, 2019 at 17:10

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.