[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: patch: add-log.el: changelog find file under point

From: martin rudalics
Subject: Re: patch: add-log.el: changelog find file under point
Date: Mon, 25 Feb 2008 15:05:01 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> Using a regexp is just one of the methods Imenu supports.
> This would need special-purpose Lisp code, but it isn't very hard.

Using a function would be much better but require a complete redesign of
imenu support for c-mode.  Also note that currently
`cc-imenu-objc-generic-expression' depends on
`cc-imenu-c++-generic-expression', hence we would have to decide about
the former as well.

So far I added the following to `cc-imenu-c++-generic-expression':

       "DEFUN[ \t]*(\"[" c-alnum "-]+\",[ \t]*"
       "\\([" c-alnum "_]+\\),[ \t]*[" c-alnum "_]+,[ \t\n]+"
       "\\(?:[ \t]*[0-9]+,\\)*\n"
       "[ \t]*doc:[ \t]*/\\*"
       "[ \t]*)") 1)

This gets me a list of all Fcons, Flist, ... names provided they have
been written well.  It does _not_ remove the DEFUN entries and it does
_not_ remove the entries in comments.  A major cuplrit is the

       "[^()\n]*"                             ; no parentheses before

line in `cc-imenu-c++-generic-expression' which is supposed to avoid
leading parens.  Obviously, this expression matches anything on a line
if only the remainder of the line matches something like a function
definition.  Removing this line helps to redeem the problem.

It doesn't help in the following cases:

(1) Commented-out code.

(2) Comments starting at bol.  Even if an item is in a doc-string of a
DEFUN it will be listed since the very nature of imenu regexp
specifications means the DEFUN scan and that for normal functions are
separate (with DEFUNs imenu will scan C-mode buffers up to six times).
The latter scan _will_ report any function definition found on the bol
of a doc-string handled by the former.

(3) Strings starting at bol (you can see some nasty implications of this
by running imenu on lib-src/etags.c).

(4) An expression at bol like "while (0)" (you can find one in buffer.h,
lisp.h, search.c, a couple in ccl.c).

Using a function for Imenu + `syntax-ppss' could help us get rid of
problems (1)-(3).  It could also help to not list defs with leading
parens.  Things like (4) can then be either considered bad style or
could be handled by applying certain heuristics.

Writing a function obviously doesn't get me

- macros like #define ...

- type definitions like typedef union Lisp_Object

- enumerations like enum Lisp_Type

and many more automatically.  All these are used in change-log entries
and not finding them via imenu makes it hardly worth the effort to run
imenu in the first place.  (Please recall: This thread started out as
finding a definiton from a corresponding change log entry.)

Adding these would mostly require to reinvent things that have been
written and validated in etags before.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]