universal-ctags / citre

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

global, enh: add function for global to update single file #165

Closed norris-young closed 3 weeks ago

norris-young commented 5 months ago

global supports updating tags for a single file. we can add this function which might be used in after-save-hook.

AmaiKinono commented 3 months ago

Thanks, and sorry for the late response.

I've noticed the tramp-file-name-localname, tramp-dissect-file-name and tramp-handle-expand-file-name combination in your patch. I've used file-local-name for similar purpose in other parts of the code. Are they doing the same thing?

Also, seems expand-filename already does what tramp-handle-expand-file-name do:

(expand-file-name "/ssh:kino@localhost:~/.emacs.d/")
;; => "/ssh:kino@localhost:/home/kino/.emacs.d/"

So, could we replace it with something like (file-local-name (expand-file-name filename)), if they are doing the same thing? Then we can remove the dependency on TRAMP.

norris-young commented 3 weeks ago

So, could we replace it with something like (file-local-name (expand-file-name filename)), if they are doing the same thing? Then we can remove the dependency on TRAMP.

It works and PR has been updated. Besides, I reworked the fix I submitted before with the same way.

AmaiKinono commented 3 weeks ago

Thanks!

AmaiKinono commented 3 weeks ago

We can add this function which might be used in after-save-hook.

I'd like to ask how are you using this, as adding it to after-save-hook will prompt the user to create a global database for every file they save. Are there some special configuration on your side, or could we make it do nothing when no global database is found?

norris-young commented 3 weeks ago

We can add this function which might be used in after-save-hook.

I'd like to ask how are you using this, as adding it to after-save-hook will prompt the user to create a global database for every file they save. Are there some special configuration on your side, or could we make it do nothing when no global database is found?

FYI, I add some conditions.

(lambda ()
  (when (and (eq major-mode 'c-ts-mode)
             (citre-global-dbpath))
    (citre-global-update-file)))