GNU bug report logs -
#35250
Add simplest Advice example possible first
Previous Next
Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Date: Fri, 12 Apr 2019 22:49:03 UTC
Severity: wishlist
Tags: fixed
Fixed in version 27.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35250 in the body.
You can then email your comments to 35250 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35250
; Package
emacs
.
(Fri, 12 Apr 2019 22:49:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 12 Apr 2019 22:49:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
(info "(elisp) Advising Functions") starts out with a complicated
example.
For example, in order to trace the calls to the process filter of a
process PROC, you could use:
(defun my-tracing-function (proc string)
(message "Proc %S received %S" proc string))
(add-function :before (process-filter PROC) #'my-tracing-function)
Please first add the simplest example possible:
Function A prints "a".
Make it print "ab" from now on.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#35250
; Package
emacs
.
(Tue, 09 Jul 2019 15:07:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 35250 <at> debbugs.gnu.org (full text, mbox):
積丹尼 Dan Jacobson <jidanni <at> jidanni.org> writes:
> (info "(elisp) Advising Functions") starts out with a complicated
> example.
>
> For example, in order to trace the calls to the process filter of a
> process PROC, you could use:
>
> (defun my-tracing-function (proc string)
> (message "Proc %S received %S" proc string))
>
> (add-function :before (process-filter PROC) #'my-tracing-function)
>
> Please first add the simplest example possible:
>
> Function A prints "a".
>
> Make it print "ab" from now on.
I've never used nadvice before, and I have to say that I found that
section a bit confusing, too, because my immediate response was (like
Dan's) to say "well, it should be trivial to make an advice that just
modifies the output", so I thought "well, :around has to be it".
But it isn't, :around is the super-flexible one:
(defun my-foo (x)
(* x 2))
(defun my-advice (old-fun x)
(+ (funcall old-fun x) 1))
(advice-add 'my-foo :around #'my-advice)
(my-foo 3)
=> 7
Instead :filter-return is it, and it's the one mentioned last. So I'm
adding this to the manual as an example first:
(defun my-double (x)
(* x 2))
(defun my-increase (x)
(+ x 1))
(advice-add 'my-double :filter-return #'my-increase)
(my-double 3)
7
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) fixed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Tue, 09 Jul 2019 15:14:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 27.1, send any further explanations to
35250 <at> debbugs.gnu.org and 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Tue, 09 Jul 2019 15:14:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 07 Aug 2019 11:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 263 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.