0

I use emacs's session-capabilities (i.e. desktop-change-dir and desktop-save-in-desktop-dir) to persist various sessions across different projects where each one has its own “.emacs.dektop”-file. I want to store as well bookmarks in a session-specific way.

O.K. it already works out of the box for registers because they are stored directly in the desktop-file. But they lack the ability to name locations, to find them again properly if the files receive some editing, show that nice symbols in the line-numbering and so on. A single non-project-specific file for all my bookmarks is as well … absolutely not what I want. Those lists can get huge and mix up apples and pears.

Has someone a proposal on how to reach this goal?

Something I though of was, to use a hook when one of the two desktop-…-dir-functions above is called. However I don't know if there exists a hook that serves this purpose. Does someone of you know that? Potentially, this hook could then be used to set the path for the bookmark-file to the same folder where the “.emacs.desktop” resides in.

2
  • 1
    Ask Emacs: do C-h v desktop--hook TAB to find all the variables named desktop-*-hook and then check each one (there are only six) with C-h v to see where each one is run. Commented Mar 23 at 12:04
  • Clarify what you're trying to do. What do you mean by session-specific etc. What's the connection with projects, etc. The question is vague, at best. This isn't a site for brainstorming - maybe try a discussion site such as Reddit for that. This is a site for specific Q & A - one Q per post. Commented Mar 23 at 19:50

1 Answer 1

0

Just for future reference I add the solution that I have found myself following the advice of NickD:

(let ((get-bookmarks-file-path (lambda () (concat (file-name-as-directory desktop-dirname) ".emacs.bookmarks")))) (add-hook 'desktop-after-read-hook (lambda () (message "Load session-specific bookmarks-file: %s" (funcall get-bookmarks-file-path)) (bookmark-load (funcall get-bookmarks-file-path) t nil t))) (add-hook 'desktop-save-hook (lambda () (message "Store bookmarks in session-specific file: %s" (funcall get-bookmarks-file-path)) (bookmark-save nil (funcall get-bookmarks-file-path) t)))) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.