Ticket #4169 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 3 years ago

[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.

Change History

comment:1 Changed 3 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:

  1. Bad indentation
  2. Questionable use of types (int vs size_t etc.)
  3. New string functions instead of using stuff like g_strcanon()
  4. 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 3 years ago by psprint

I think that most of your objections can be addressed:

  1. The indentation is rather correct as I did run make indent before committing.
  2. Which ones? I'll take a look into them.
  3. 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.
  4. 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 3 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' .
Last edited 3 years ago by psprint (previous) (diff)

comment:4 Changed 3 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' .

comment:5 Changed 3 years ago by psprint

Turns out that the correct ctags command is actually:

ctags -e -R --languages=C --langmap=C:.h.c --c-kinds=+px --fields=+iaS --extra=+q .

It'll index also headers, thanks to the --langmap.

comment:6 Changed 3 years ago by andrew_b

  • Status changed from new to closed
  • Resolution set to wontfix
  • Milestone Future Releases deleted
Note: See TracTickets for help on using tickets.