emacs-devel
[Top][All Lists]
Advanced

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

Re: which-function => DEFUN?


From: Stefan Monnier
Subject: Re: which-function => DEFUN?
Date: Mon, 10 May 2010 11:42:19 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> (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



reply via email to

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