Ticket #4169 (closed enhancement: wontfix)
[patch] Selection of objects from TAGS file
Reported by: | psprint | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | mcedit | Version: | master |
Keywords: | tags, etags, symbols, Find, FilePrev, FileNext | Cc: | |
Blocked By: | Blocking: | ||
Branch state: | no branch | Votes for changeset: |
Description
Hi,
currently, the TAGS file support is:
– on the "Find declaration' command, the left-word is being searched in the symbols in the TAGS,
– a list of the found symbols is being shown, allowing selection of one to jump to,
– the jump is being made (after selecting), by: replacing of the file in the current WEdit object,
– this discards the changes in the current file and undo history.
The method works well for a cross-file jumps. It doesn't add new files to the editor which is IMO a good thing. The patch introduces a new method of using the TAGS file – selection of all symbols for current file. It works as follows;
– for the requested type (either a function, a variable, a typedef, an other kind, all kinds) a list of all symbols for the current file is being shown,
– after a selection has been made, a jump to the line is being done (without any WEdit file replacing),
– the list has the symbol that's nearest to the current line selected (this means that the current function will be selected, etc.).
The patch works well with the other patch – MultiSearch, as it allows for efficient grepping of the list that's shown. I submit two version of the patch, one that's MS aware (it contains single additional function invocation) and one that's not.
Attachments
Change History
Changed 4 years ago by psprint
- Attachment 0001-Selectable-listing-of-various-object-types-from-TAGS.patch added
Changed 4 years ago by psprint
comment:1 Changed 4 years ago by zaytsev
I cannot comment on the functionality itself, because I don't use TAGS at all, but I'd like to point out, that the patch quality is lacking. I'm afraid that Andrew will not be happy about that either. The problems that I can see by just quickly skimming through the code without trying to understand how/what it does:
- Bad indentation
- Questionable use of types (int vs size_t etc.)
- New string functions instead of using stuff like g_strcanon()
- Lots of changes to existing complex code without a single test
I wouldn't want to take responsibility to commit something like this to the tree.
comment:2 Changed 4 years ago by psprint
I think that most of your objections can be addressed:
- The indentation is rather correct as I did run make indent before committing.
- Which ones? I'll take a look into them.
- I've scanned through glib's string functions and there's no function that collapses whitespace. g_strcanon is a different function – it doesn't collapse the whitespace, it could be only used to replace different kinds of them with a regular space.
- The changes and the tests — I wasn't aware that there are tests available. That said, the changes to the existing code are very limited – it only:
- replaces/extends edit_get_match_keyword_cmd with the more general edit_select_object_from_tags,
- replaces/extends editcmd_dialog_select_definition_show with the more general editcmd_dialog_select_tags_object_show,
- does some refactoring, like extracting of some code to the functions etags_locate_tags_file, edit_get_left_whole_word, etc.,
- adds registering of the new commands SelectFunction, SelectVariable, etc. to the keybindings (src/keybind-defaults.c, lib/keybind.h, etc.).
comment:3 Changed 4 years ago by psprint
BTW. In case anyone would like to try using tags, here's a command that will generate them for a C project:
ctags -e -R --language=c --exclude='*~' -h '.h' .
comment:4 Changed 4 years ago by psprint
PS. I was using wrong option for setting files that should be browsed – it should be --languages=c, not --language=c, as the second forces all text files to be treated as C, not limits the search to the C source files. So that Makefile.in, etc. files are being searched as C source, etc. So the command should be:
ctags -e -R --languages=c --exclude='*~' -h '.h' .