[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replacing a function with another one
From: |
Michael Heerdegen |
Subject: |
Re: replacing a function with another one |
Date: |
Wed, 12 Mar 2014 08:07:59 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Michael Heerdegen <michael_heerdegen@web.de> writes:
> (defun my-fac--print-result-around-advice (orig-fun n)
> "Print result in the echo area."
> (let ((result (funcall orig-fun n)))
> (message "The faculty of %d is %d" n result)
> (sit-for 3)
> result))
BTW, what you also see is that advices in nadvice are just normal,
independently defined functions, and not some obscure expressions. It's
your function definition, you can name and use the arguments as you
like. In case of an around advice, your advice FUNCTION will be called
that way:
(apply function oldfun r)
which means, with the arguments that the original function is called
with, prepended with the old function definition. It must accept these
arguments.
So, for example, the above defun could also be written as
(defun my-fac--print-result-around-advice
(orig-fun &rest argument-list-to-pass-over)
"Print result in the echo area."
(let ((result (apply orig-fun argument-list-to-pass-over)))
(message "The faculty of %d is %d" n result)
(sit-for 3)
result))
Michael.
- Re: replacing a function with another one, (continued)
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/09
- Re: replacing a function with another one, lee, 2014/03/09
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/09
- Re: replacing a function with another one, lee, 2014/03/09
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/09
- Re: replacing a function with another one, lee, 2014/03/10
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/10
- Re: replacing a function with another one, lee, 2014/03/11
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/11
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/12
- Re: replacing a function with another one,
Michael Heerdegen <=
- Re: replacing a function with another one, lee, 2014/03/12
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/13
- Re: replacing a function with another one, lee, 2014/03/15
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/17
- Re: replacing a function with another one, lee, 2014/03/12
- Re: replacing a function with another one, Stefan Monnier, 2014/03/12
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/12
- Re: replacing a function with another one, Stefan Monnier, 2014/03/10
- Re: replacing a function with another one, lee, 2014/03/10
- Re: replacing a function with another one, Michael Heerdegen, 2014/03/10