universal-ctags / citre

A superior code reading & auto-completion tool with pluggable backends.
GNU General Public License v3.0
326 stars 26 forks source link

how to customize readtags path for a remote machine? #120

Open askeySnip opened 2 years ago

askeySnip commented 2 years ago

the question is when I use tramp for remote dev, it use the remote readtags or the local readtags? and how can I config the readtags located in remote machine for citre to use? thanks!

AmaiKinono commented 2 years ago

Actually I don't have a remote machine so I can't answer this question. I test TRAMP using local files.

To the best of my knowledge, TRAMP uses remote programs when visiting remote files.

askeySnip commented 2 years ago

Actually I don't have a remote machine so I can't answer this question. I test TRAMP using local files.

To the best of my knowledge, TRAMP uses remote programs when visiting remote files.

You are right. So I want to know how to config different path? The temp solution is using source to add the remote different readtags path into PATH. Thanks for your reply.

AmaiKinono commented 2 years ago

What about this:

(defun set-remote-ctags-env ()
  "Set readtags path according to host name."
  (when-let* ((remote-host (file-remote-p (buffer-file-name) 'host)))
    (setq-local citre-readtags-program
                (pcase remote-host
                  ;; Put your pair of hostname and readtags path here
                  ("remote-host-1" "readtags-program-path-1")
                  ("remote-host-2" "readtags-program-path-2")))))

(add-hook 'find-file-hook #'set-remote-ctags-env)
fuzy112 commented 1 year ago

citre-readtags-program is defined as (set file (const nil)) in citre-core.el, but it is used as a string, so if you customize this variable using Easy Customization, an error will occur when running citre commands.

https://github.com/universal-ctags/citre/blob/1c0ca637c7993559a0175e3001941457b8c71211/citre-core.el#L58-L65

Ergus commented 1 year ago

Hi:

Related to this, the oficial emacs solution for these problems is to use connection-local-variables.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Connection-Local-Variables.html

I made the gtags-mode implementation for emacs with full tramp support and I use them to enable full remote executable detection and some memoization (to avoid the impact of calling executable-find more than needed) but at the same time it checks when gtags is not available remotely to avoid nasty errors

https://github.com/Ergus/gtags-mode

Just my 5 cents

AmaiKinono commented 4 months ago

@Ergus Thanks very much, and sorry for the late response.

I think I understand the overall approach, but I have trouble understanding your implementation. To me it seems like all the things we should do is wrapping the codes that start a process in with-connection-local-variables.

Also, as I don't have a remote machine, I cannot test the code or write a user document explaining how to customize executable paths on remote machines.

What we need is a TRAMP user to help use write the code and documentation.