Simon Wright <[email protected]> writes: > On 17 Nov 2015, at 22:28, Stephen Leake <[email protected]> > wrote: >> >> Stephen Leake <[email protected]> writes: >> >>> Simon Wright <[email protected]> writes: >>> >>>> imenu (ada-imenu.el) is responsible for the Entities menu. The >>>> regexps don't recognise all subprograms; specifically the two >>>> forms of Iterate in containers, either as specs or bodies: > […] >>>> Stephe, I could work on this in a branch or as a patch - I already >>>> have org.emacs.ada-mode.sjw, used for gpr-mode work - what do you >>>> think? >>> >>> I have not studied your branch, so I don't know if it is ready for >>> merge. >>> >>> I think the best approach to fixing ada-imenu.el is to drop the regexp >>> and use the parse results instead; that way we only have to maintain one >>> set of rules for recognizing a subprogram. >> >> imenu-generic-expression can take a function instead of a regexp; the >> function must search backward, and set `match-data'. > > I saw that. There's a caveat in 'set-match-data'; the match data > should result from a previous parse. Exploration needed.
You can use wisi functions to do the real search, then `string-match' on the found name to set the match data. >> That could be a function that uses a new wiis-backward-find-class >> (similar to wisi-forward-find-class). >> >> Currently the grammar sets a "name" class on everything that looks like >> a name; it might make sense to enter all of those into the imenu. If >> not, you can either search for name and then check the rest of that >> statement, or add a new class to the grammar actions for this. > > So one would search backward for e.g. 'subprogram_declaration' and > then forward for 'name'? "subprogram_declaration" is a token; "name" is a class. Tokens are defined directly in the ada-grammar.wy; that's what %keyword, %token, and ":" do. Classes are a wisi concept; they are defined in wisi-statement-actions in the grammar actions. I would start by searching backward for class "name", then find out what kind of name it is (typically by wisi-goto-statement-start, check the token there), to see how to put it into imenu. (going out on a limb) There's no reason not to include all names in imenu. Well, perhaps only "file top-level" names, but I'm not sure that's easy to determine via the grammar. I'd start with "all names" and see if that's too many. -- -- Stephe _______________________________________________ Emacs-ada-mode mailing list [email protected] http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org
