* Advice on advice needed
@ 2015-02-13 23:02 Marcin Borkowski
2015-02-14 0:22 ` John Mastro
0 siblings, 1 reply; 2+ messages in thread
From: Marcin Borkowski @ 2015-02-13 23:02 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hello,
and sorry for the lame pun in the topic.
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.
TIA,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Advice on advice needed
2015-02-13 23:02 Advice on advice needed Marcin Borkowski
@ 2015-02-14 0:22 ` John Mastro
0 siblings, 0 replies; 2+ messages in thread
From: John Mastro @ 2015-02-14 0:22 UTC (permalink / raw)
To: Help Gnu Emacs mailing list; +Cc: Marcin Borkowski
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-14 0:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-13 23:02 Advice on advice needed Marcin Borkowski
2015-02-14 0:22 ` John Mastro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).