all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Juanma Barranquero <lekktu@gmail.com>
Cc: Lennart Borgman <lennart.borgman@gmail.com>,
	Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: which-function => DEFUN?
Date: Mon, 10 May 2010 11:42:19 -0400	[thread overview]
Message-ID: <jwveihjdaxj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <AANLkTil8m_1LWf1QeSmeIkCzuD2Y760LnrwBX8MMQPvo@mail.gmail.com> (Juanma Barranquero's message of "Mon, 10 May 2010 16:22:30 +0200")

> (defun which-func-identify-DEFUN ()
>   (save-excursion
>     (save-match-data
>       (beginning-of-defun)
>       (and (looking-at "DEFUN +(\"[^\"]+\",[ \n]+\\(F[^,]+\\),")
>            (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.

The rule for where to place a save-match-data is:

  around the code run between "looking-at" and
  "match-string-no-properties".

In this case (as in 99% of the cases) this code is empty, so the
save-match-data can be dropped.

> (add-hook 'which-func-functions 'which-func-identify-DEFUN nil t)

If your save-match-data were needed, which-func-functions should say
so explicitly.


        Stefan



  parent reply	other threads:[~2010-05-10 15:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-10 13:58 which-function => DEFUN? Lennart Borgman
2010-05-10 14:22 ` Juanma Barranquero
2010-05-10 14:39   ` Lennart Borgman
2010-05-10 15:09     ` Juanma Barranquero
2010-05-10 15:56       ` Lennart Borgman
2010-05-10 17:30         ` Juanma Barranquero
2010-05-10 15:42   ` Stefan Monnier [this message]
2010-05-10 16:05     ` Lennart Borgman
2010-05-10 17:34       ` Stefan Monnier
2010-05-10 17:34     ` Juanma Barranquero
2010-05-11  2:09     ` Global match data considered harmful Stephen J. Turnbull
2010-05-11 13:54       ` Stefan Monnier
2010-05-12  2:01         ` Stephen J. Turnbull
2010-05-12  5:09           ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwveihjdaxj.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=lennart.borgman@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.