Skip to main content
added 688 characters in body
Source Link
glucas
  • 20.9k
  • 1
  • 56
  • 84

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'.

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 as a Windows path, though. You would need a function that knows how to map the Windows path to a Unix-style path. Alternatively, you might be able to use the same approach and advise bookmark-set-filename to always save the path in a specific (e.g. unix-style) format.

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)

Update

To be able to share a bookmarks file between systems, you need some way to map between paths. In your example it looks like you have a 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'.
added 171 characters in body
Source Link
glucas
  • 20.9k
  • 1
  • 56
  • 84

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 as a Windows path, though. You would need a function that knows how to map the Windows path to a Unix-style path. Alternatively, you might be able to use the same approach and advise bookmark-set-filename to always save the path in a specific (e.g. unix-style) format.

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 as a Windows path, though. You would need a function that knows how to map the Windows path to a Unix-style path.

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 as a Windows path, though. You would need a function that knows how to map the Windows path to a Unix-style path. Alternatively, you might be able to use the same approach and advise bookmark-set-filename to always save the path in a specific (e.g. unix-style) format.

added 171 characters in body
Source Link
glucas
  • 20.9k
  • 1
  • 56
  • 84

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 as a Windows path, though. You would need a function that knows how to map the Windows path to a Unix-style path.

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)

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 as a Windows path, though. You would need a function that knows how to map the Windows path to a Unix-style path.

Source Link
glucas
  • 20.9k
  • 1
  • 56
  • 84
Loading