bastibe / annotate.el

Annotate.el
Other
384 stars 20 forks source link

Accessing both annotated file and annotations database via TRAMP? #105

Closed glvno closed 3 years ago

glvno commented 3 years ago

Hello!

I just took a crack at working on an annotated file using TRAMP.

I configured annotate-file with (setq annotate-file "/ssh:username@host:/path/to/annotations/database") and then opened the annotated file via command line: emacs /ssh:username@host:/path/to/file.org

The annotations were nowhere to be found. Upon further investigation, annotate-show-annotation-summary revealed that the database was looking for the annotated file relative to the local home path. So, working from my Mac on a file stored on a Linux machine, it had a bunch of annotations listed for /Users/mac-username/path/to/file.org when the file it should have been looking for was in /ssh:linux-username@host:/home/linux-username/path/to/file.org.

I feel like I'm missing something very obvious or maybe just not using TRAMP as intended. Can anyone point me in the right direction?

Thank you for all your work on this excellent package!

cage2 commented 3 years ago

Hi!

The problem you issued seems interesting, i just need some time to address it because we are working on a new release and there is another problem for this package waiting. Please allow some delay before i can check this report.

Thank you. C.

cage2 commented 3 years ago

Hi @glvno !

Unfortunately i can not reproduce the issue, these are the step i made to investigate the problem:

  1. set the annotation file as remote:
    (setq annotate-file "/ssh:user@host:/home/user/annotation-remote")
  2. annotate a remote file (using TRAMP of course :))
  3. save the annotated file and the annotations
  4. the remote annotated file can be found in the database file and annotation are restored when the file is visited: contents of the database:
    (("/ssh:user@host:/home/user/test-ann.lisp" ((1 5 "annotation text" "annotated text")) "hashdigits"))

    Can you help me how to reproduce this issue?

Thanks! C.

glvno commented 3 years ago

Hi! Thanks for your reply.

To reproduce, you might try annotating a file using the remote machine first so that there is already an existing annotations database that you then try to access and edit via TRAMP.

My guess as to what is happening is that the database is recording file locations using a tilde to represent the home folder, but then when the database is accessed remotely, that tilde means something completely different.

I hope this makes sense. If you still can't reproduce, let me know and I'll keep trying to figure it out. Thank you for your help!

cage2 commented 3 years ago

Hi!

I hope this makes sense.

It does a lot of sense to me, thanks to the explanation!

the database is recording file locations using a tilde

Your guessing is good, the database use tilde to abbreviate the patch so that "/home/user/foo" become "~/foo" the motivation for this kind of behaviour can be found here: https://github.com/bastibe/annotate.el/issues/89

Unfortunately when the database is updated the files are saved with paths abbreviated (with tilde) to the computer where Emacs is running. And i believe (correct me if i am wrong) that even if i got rid of the tilde using absolute path changing computer likely does not change the problem you are getting here, if a path is local is local respect of the host where the Emacs instance that loaded the annotation database is running.

The best thing i can figure out is to always edit your remote file using TRAMP, but i understand this is not a proper solution so i am very open to any suggestion here. :)

Bye! C.

glvno commented 3 years ago

This solution works for me. Thanks for your help!

cage2 commented 3 years ago

Hi @glvno !

I am happy that this solution was acceptable, i wish you happy hacking with annotate-mode! :)

Bye! C.