From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: which-function => DEFUN? Date: Mon, 10 May 2010 16:39:13 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1273502440 5631 80.91.229.12 (10 May 2010 14:40:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 10 May 2010 14:40:40 +0000 (UTC) Cc: Emacs-Devel devel To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 10 16:40:36 2010 connect(): No such file or directory 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.69) (envelope-from ) id 1OBU9o-0006Jb-6D for ged-emacs-devel@m.gmane.org; Mon, 10 May 2010 16:40:32 +0200 Original-Received: from localhost ([127.0.0.1]:37240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OBU9D-0002ou-26 for ged-emacs-devel@m.gmane.org; Mon, 10 May 2010 10:39:55 -0400 Original-Received: from [140.186.70.92] (port=53549 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OBU8z-0002h1-OD for emacs-devel@gnu.org; Mon, 10 May 2010 10:39:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OBU8r-0006tH-PM for emacs-devel@gnu.org; Mon, 10 May 2010 10:39:41 -0400 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:49209) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBU8r-0006mS-JM for emacs-devel@gnu.org; Mon, 10 May 2010 10:39:33 -0400 Original-Received: by mail-fx0-f41.google.com with SMTP id 9so761343fxm.0 for ; Mon, 10 May 2010 07:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=/65qXrVH2bPQLYWveq9coATXDzLvt4cDLRpZsv0xYVE=; b=BP4gzgtmfb5C7Tp99fg1wifr2rMYa9sp96J/1Lzp+59X2AvB8kJS7bXKEGkYCrGY1K GJ5oXYnz3KGlAXPhlJrt1atidD1r4CPmZfufZ2q2h5UgvoAlwKOFypD82zFPg+lOoLHS ILf/PA7CJ2IyNaUQ9V1TLY9lsnfU9L+zKmLY0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=pdZZQDKhcC45xqscnxvPDBVmpnbuyAmP+wlB/IuN+Uikpdy0fiiqjHlO/fjNb35MWU hvDlxdD+PR4E8E6WoW/DJNuZJAeVaQXa6t/O9asTO+VjayBmqn1HxHbBdAndPv7QVQUY g3pczymVJ0KAAcyb6lcbHRlLAoprhOo5BJYcI= Original-Received: by 10.239.136.20 with SMTP id f20mr422326hbf.19.1273502373107; Mon, 10 May 2010 07:39:33 -0700 (PDT) Original-Received: by 10.239.164.81 with HTTP; Mon, 10 May 2010 07:39:13 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:124661 Archived-At: On Mon, May 10, 2010 at 4:22 PM, Juanma Barranquero wrot= e: > On Mon, May 10, 2010 at 15:58, Lennart Borgman > wrote: > >> It is a bit annoying to see DEFUN as the function shown by which-functio= n-mode. >> >> I am sure someone here has written an >> imenu-extract-index-name-function for use in Emacs C sources... ;-) > > (defun which-func-identify-DEFUN () > =C2=A0(save-excursion > =C2=A0 =C2=A0(save-match-data > =C2=A0 =C2=A0 =C2=A0(beginning-of-defun) > =C2=A0 =C2=A0 =C2=A0(and (looking-at "DEFUN +(\"[^\"]+\",[ \n]+\\(F[^,]+\= \),") > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (match-string-no-properties 1))))) > > Likely the `save-match-data' is not required, but I tend to err on the > side of saving it on my code. > >> Where is it? How do you set it up? > > =C2=A0(add-hook 'which-func-functions 'which-func-identify-DEFUN nil t) > > on the required buffers (I set it through `c-mode-hook'). Thanks Juanma, here is my slightly modified version built from your version= : (defun my-which-func-identify-DEFUN () (let ((here (point))) (save-match-data ;; Check if we are at the beginning of the function already (unless (eobp) (forward-char)) (beginning-of-defun) (when (< here (point)) (beginning-of-defun)) (prog1 (and (looking-at "DEFUN +(\"[^\"]+\",[ \n]+\\(F[^,]+\\),") (match-string-no-properties 1)) (goto-char here))))) (defun my-add-DEFUN () (add-hook 'which-func-functions 'my-which-func-identify-DEFUN nil t)) (add-hook 'c-mode-hook 'my-add-DEFUN)