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-auto-idle-bookmark-mode-hook
bmkp-eww-auto-bookmark-mode-hook
bmkp-global-auto-idle-bookmark-mode-hook
bmkp-info-auto-bookmark-mode-hook
bmkp-read-bookmark-file-hook (option)
bmkp-temporary-bookmarking-mode-hook (option)
bmkp-write-bookmark-file-hook (option)
bookmark-after-jump-hook
bookmark-bmenu-mode-hook
bookmark-edit-annotation-mode-hook
bookmark-exit-hook
bookmark-load-hook
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":
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).
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.
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).