From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Eric M. Ludlam" Newsgroups: gmane.emacs.devel Subject: Re: Identifying DEFUNs in which-func-mode Date: Tue, 06 Oct 2009 22:29:47 -0400 Message-ID: <1254882587.6961.281.camel@projectile.siege-engine.com> References: Reply-To: eric@siege-engine.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1254882690 22353 80.91.229.12 (7 Oct 2009 02:31:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 Oct 2009 02:31:30 +0000 (UTC) Cc: Emacs developers To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 07 04:31:20 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MvMJD-0006e3-KI for ged-emacs-devel@m.gmane.org; Wed, 07 Oct 2009 04:31:19 +0200 Original-Received: from localhost ([127.0.0.1]:46353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvMJD-0008Lt-1n for ged-emacs-devel@m.gmane.org; Tue, 06 Oct 2009 22:31:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MvMHb-0007kV-Ai for emacs-devel@gnu.org; Tue, 06 Oct 2009 22:29:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MvMHZ-0007jp-Rq for emacs-devel@gnu.org; Tue, 06 Oct 2009 22:29:39 -0400 Original-Received: from [199.232.76.173] (port=46401 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvMHZ-0007jg-PV for emacs-devel@gnu.org; Tue, 06 Oct 2009 22:29:37 -0400 Original-Received: from static-71-184-83-10.bstnma.fios.verizon.net ([71.184.83.10]:44076 helo=projectile.siege-engine.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MvMHZ-0004ZY-Ep for emacs-devel@gnu.org; Tue, 06 Oct 2009 22:29:37 -0400 Original-Received: from projectile.siege-engine.com (localhost [127.0.0.1]) by projectile.siege-engine.com (8.14.3/8.14.3/Debian-6) with ESMTP id n972TlDZ016361; Tue, 6 Oct 2009 22:29:47 -0400 Original-Received: (from zappo@localhost) by projectile.siege-engine.com (8.14.3/8.14.3/Submit) id n972TlLT016360; Tue, 6 Oct 2009 22:29:47 -0400 X-Authentication-Warning: projectile.siege-engine.com: zappo set sender to eric@siege-engine.com using -f In-Reply-To: X-Mailer: Evolution 2.26.1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115943 Archived-At: 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