emacs-devel
[Top][All Lists]
Advanced

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

Re: Identifying DEFUNs in which-func-mode


From: Eric M. Ludlam
Subject: Re: Identifying DEFUNs in which-func-mode
Date: Tue, 06 Oct 2009 22:29:47 -0400

On Wed, 2009-10-07 at 03:27 +0200, Juanma Barranquero wrote:
> IMO, defining this function somewhere
> 
> (defun which-func-identify-DEFUN ()
>   (save-excursion
>     (save-match-data
>       (beginning-of-defun)
>       (if (looking-at "DEFUN +(\"[^\"]+\", +\\(F[^,]+\\),")
>           (match-string-no-properties 1)
>         nil))))
> 
> and adding it to `which-func-functions' for C files in the Emacs tree
> would be useful.
> 
> Alas, it can't be added through .dir-locals.el, because hooks are
> unsafe as directory-local variables. One (not particularly elegant)
> way to fix it would be to add to C mode the function and a boolean
> variable to set it; that variable could be safely set in
> .dir-locals.el. Surely others can think of better ways.
> 
> But before taking the trouble, does anyone else think that it would be
> useful to have this in standard Emacs, or it is the intersection of
> Emacs developers and which-func-mode users too small?

If you enable semantic-mode in Emacs (via the recent integration) and
also enable EDE (via the integration), then Emacs will identify your
Emacs sources as a project, and setup the parsing system to recognize
DEFUN macros.  A piece of Semantic that supports which-func mode is,
AFIAK, not yet integrated as the file is waiting for papers.  The
which-func support there is, however, not dependent on that paperwork
and could be used.

Anyway, the Semantic parsers put overlays on tags, so looking up which
function you are on is very fast.

You can see how the which-func support works at the bottom of this file:

http://cedet.cvs.sourceforge.net/viewvc/*checkout*/cedet/cedet/semantic/semantic-imenu.el

This support was added a long time ago, and judging by the description
you posted, should be re-written to some new APIs anyway.  I'd be glad
to see that old code refreshed as needed, as which-func is exactly the
type of functionality that CEDET excels at.

On the flip-side, if you enable the CEDET tools, you could enable
semantic-stickyfunc-mode instead of which-func.  IMO this is a much
slicker way of doing the same thing, but only if you don't use your
header line for other tasks already.

Eric





reply via email to

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