help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Advice on advice needed


From: John Mastro
Subject: Re: Advice on advice needed
Date: Fri, 13 Feb 2015 16:22:29 -0800

Marcin Borkowski <mbork@wmi.amu.edu.pl> wrote:
> There is a function in Emacs which really should be wrapped in
> `save-excursion' (it's `message-insert-signature').  I advised it, so
> that I can repeatedly press C-c C-w to cycle between a few signatures.
> However, it puts the point at the end of the buffer.
>
> Is there a way to wrap it in `save-excursion' using advice, or is
> writing a wrapper function the only way to do it?  (I guess the latter,
> but maybe I'm wrong?)  I'm on Emacs 25.0.50.1, so I have the "new
> advice" system on board.

I think something like this should work:

    (defun save-excursion-wrapper (function &rest args)
      (save-excursion
        (apply function args)))

    (advice-add 'message-insert-signature
                :around
                #'save-excursion-wrapper)

-- 
john



reply via email to

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