1

If I create a bookmark on one platform, then try to use that bookmark on another platform, and if the bookmarks file isn't reloaded, then that new bookmark isn't available.

How can I make sure my bookmark file gets reloaded when it's externally changed?

2
  • You also need to save your bookmarks file after creating the bookmark on the other platform, and before loading it on the first platform.
    – Drew
    Oct 3 at 15:04
  • This really is no different from dealing with any other file between platforms - and even between Emacs sessions on the same platform. If you change a file buffer in one Emacs session then it needs to be saved there and then reloaded (or just revisited, if not Lisp code) in the other session.
    – Drew
    Oct 3 at 15:06

2 Answers 2

1
(add-hook 'lisp-data-mode-hook
  (lambda ()
    (when (string= (buffer-name) "bookmarks")
      (auto-revert-mode))))
1
  • 1
    Good use of lisp-data-mode-hook (new for Emacs 29). But the buffer name won't necessarily be bookmarks. It could be anything at all. Better to use some other test. Maybe check some text in the file header, such as Emacs Bookmark Format Version.
    – Drew
    Oct 3 at 23:14
1

auto-revert-mode works well for cases where the file is visited by emacs, but that is not the case here, so you could use the filenotify api instead:

(file-notify-add-watch bookmark-default-file '(change)
                       (lambda (ev)
                         (bookmark-load bookmark-default-file)))

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.