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

support xref apropos (C-M-.) #145

Closed peterzky closed 1 year ago

masatake commented 1 year ago

If the pattern has a constant part as its prefix like "foo." (unlike ".bar"), there is an area of optimization; we can use --prefix-match option of readtags.

AmaiKinono commented 1 year ago

Thanks for the patch! However, there's several problems in it.

First, citre-tags-get-tags is called like

(citre-tags-get-tags nil pattern 'regexp ...)

But passing regexp to the third argument MATCH doesn't do anything meaningful, which can be seen from its docstring.

It is practical to use citre-get-backend-and-id-list here to get all the tags first, then filter them according to PATTERN.

Second, citre-tags-get-tags should not be used here. Citre has a pluggable backend design, and we have tags and global backend for now, so we couldn't make it only work for tags backend here.

If you use citre-get-backend-and-id-list to get the tags, you are reusing the existing backend interface so there's no need to write backend-specific logic. But if you need to do different things in different backends (e.g., the optimization proposed by @masatake, which only works for the tags backend), you need to read citre-backend-interface.el and extend the interface, then implement the interface in the backends.

peterzky commented 1 year ago

Thanks for the detailed reply. But citre-get-backend-and-id-list are missing fields required by xref apropos. Create new interface 'find-tags-in-project'.