GNU bug report logs - #21683
25.0.50; `advice-add` doesn't work for compiled primitive functions

Previous Next

Package: emacs;

Reported by: Vitalie Spinu <spinuvit <at> gmail.com>

Date: Wed, 14 Oct 2015 01:55:02 UTC

Severity: minor

Tags: wontfix

Merged with 5863

Found in version 25.0.50

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Vitalie Spinu <spinuvit <at> gmail.com>, 21683 <at> debbugs.gnu.org
Subject: bug#21683: 25.0.50; `advice-add` doesn't work for compiled primitive functions
Date: Sun, 18 Oct 2015 21:16:35 +0000
[Message part 1 (text/plain, inline)]
This is documented behavior:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Named-Functions.html
It is possible to advise a primitive (see What Is a Function
<https://www.gnu.org/software/emacs/manual/html_node/elisp/What-Is-a-Function.html#What-Is-a-Function>),
but one should typically *not* do so, for two reasons. Firstly, some
primitives are used by the advice mechanism, and advising them could cause
an infinite recursion. Secondly, many primitives are called directly from
C, and such calls ignore advice; hence, one ends up in a confusing
situation where some calls (occurring from Lisp code) obey the advice and
other calls (from C code) do not.

Vitalie Spinu <spinuvit <at> gmail.com> schrieb am Mi., 14. Okt. 2015 um
03:55 Uhr:

>
> Hi,
>
> Put this function into a file, compile the file and then load the file:
>
>
>   (defun foobar ()
>    (save-restriction
>      (widen)))
>
>
> then:
>
>
>   (defun restrict-widen (orig-widen)
>     (message "here")
>     (apply orig-widen nil))
>
>   (advice-add 'widen :around #restrict-widen)
>
>   (foobar)
>
>
>
> The advice is not triggered.
>
>
> Eval the `foobar` definition interactively and the advice will start
> working. The problem occurs only for primitive c functions. Elisp
> functions are fine. It doesn't work with 24.4.1 either.
>
>
>   Vitalie
>
>
>
>
> In GNU Emacs 25.0.50.3 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
>  of 2015-09-26
> Repository revision: 139e55a58466058a8c9ae54536cb790ac7b7cc64
> Windowing system distributor 'The X.Org Foundation', version 11.0.11600000
> System Description:     Ubuntu 14.10
>
>
>
>
[Message part 2 (text/html, inline)]

This bug report was last modified 4 years and 227 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.