Search code examples
emacselispbookmarks

Emacs bookmark and accessing across different local path


When I bookmark a File in emacs, it has the full-path C:/WindowPath/CommanPath/File I can access the same directory from Linux with /LinuxPath/CommanPath/File. But, when I try to bookmark in one OS and access in other OS, the file-path are different and I cannot access the same file from M-x list-bookmark interface. How I can resolve this? Please note that the 'CommanPath' is same for both OS. Is there something in bookmark library that I can use? If that is not the case, then how should I create shortcuts so it can work seamlessly in both OS, or for that matter in any path ?

Thanks.


Solution

  • Hm. How does Emacs find the same file starting with different absolute file names on different OS's? If you can track that down then you can likely make the bookmark code do the same thing. The bookmark just saves the absolute file name in the form of the OS you were using at the time you created the bookmark. Giving that to Emacs to find should be no different from giving it to find-file, which you say works.

    (That is, I think that's what you're saying: you can type the Windows form of the file name at C-x C-f when on Linux and it just works, and vice versa.)

    The basic file-finding function is find-file-noselect, but all it seems to do in this regard is (abbreviate-file-name (expand-file-name FILENAME)), which would not be sufficient if given FILENAME as an absolute name from the wrong file system.

    If you cannot figure out how to code this generally, you might be able to use directory-abbrev-alist to make your own explicit correspondence between the two directory prefixes. Dunno.

    Interesting question.