It looks like the relevant bookmark function is bookmark-get-filename
. You could advise this to expand or otherwise transform the path.
For example, add some 'filter return' advice to call expand-file-name
:
(advice-add 'bookmark-get-filename :filter-return 'expand-file-name)
I don't think this helps if the bookmark is saved asUpdate
To be able to share a Windows pathbookmarks file between systems, though. You wouldyou need a function that knows howsome way to map the Windows path to a Unix-style pathbetween paths. Alternatively,In your example it looks like you might be able to use the same approach and advise bookmark-set-filename
to always save the path inhave a specific (e.g. unix-style) format.root 'sync' directory on each system, so you could do something like this:
(defconst sync-dir
(if (eq system-type 'windows-nt)
"C:/sync/"
"/user/sync/"))
(defun sync-relative-name (file)
(cond
((file-exists-p file)
file)
((string-match "^.+/sync/\\(.+\\)" file)
(expand-file-name (match-string 1 file) sync-dir))
(t file)))
(advice-add 'bookmark-get-filename :filter-return 'sync-relative-name)
That is:
- Define the root path for your sync tree on each system.
- Define a function that can take the absolute path from one system and convert it to the equivalent on the other system. Here I'm just taking everything after
sync/
and using that to build a new path, relative to the local sync dir. - Use this function to advise `bookmark-get-filename'.