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

test, feat: a make target to update tags file in the tests #59

Closed AmaiKinono closed 3 years ago

AmaiKinono commented 3 years ago

See https://github.com/AmaiKinono/citre/issues/58#issuecomment-849371758 for the idea.

Now a problem is: TAG_PROC_CWD is recorded in the tags files, so apparently the relevant test cases will only pass on my PC, unless the tags files are regenerated.

I'm thinking about suppress this ptag. Since Citre could guess the CWD without this ptag, this shouldn't cause any problem. And, we create a dedicated test case to test TAG_PROC_CWD related things, where we "hand craft" a tags file.

masatake commented 3 years ago

If we have a command edittags, does it help you?

$ edittags -i --rewrite-ptag TAG_PROC_CWD=$(pwd) tags

-i has the same effect of -i in sed.

AmaiKinono commented 3 years ago

If we have a command edittags, does it help you?

It would definitely help, but implementing edittags for this one purpose is a little bit overkill.

Letting Citre guess cwd works for our directory structure. If one day this couldn't fulfill our need, I'll see if sed can help.

masatake commented 3 years ago

edittags is not only for this purpose.

I have been thinking about edittags and linktags. However, I didn't write it because there is no real user. I like adding a new feature. However, in some cases, such attitude of the project maintainer is good for the project. So I always wait for a real need for the feature I would like to add. I found one need for edittags in this issue:-)

Let's assume we have edittags command already. I wonder what kind of features and what kind of command line interface edittags should provide. I never promise implementing it now. However, you have fastpath ticket!

AmaiKinono commented 3 years ago

I happen to know a use case: http://blog.binchen.org/posts/javascript-code-navigation-in-counsel-etags.html

Let me explain the idea (but keep in mind I don't know javascript well).

The author did the following things:

  1. Find all object property names in current buffer using regexp.
  2. Use an api in js2-mode called js2-print-json-path. It gets the JSON path of the properties.
  3. Write these info to a TAGS file. The author uses Emacs TAGS format and he manually assembles the tag lines.
  4. Now he can jump to the definition using plugins that supports TAGS file.

Edittags can do step 3 for a (ctags format) tags file.