From unknown Thu Aug 14 22:23:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14202: 24.3.50; add-function doesn't check properly for existing advices with same name prop Resent-From: Michael Heerdegen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Apr 2013 13:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14202 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 14202@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Reply-To: michael_heerdegen@web.de Received: via spool by submit@debbugs.gnu.org id=B.136594578026886 (code B ref -1); Sun, 14 Apr 2013 13:23:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Apr 2013 13:23:00 +0000 Received: from localhost ([127.0.0.1]:49946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URMtW-0006zP-Br for submit@debbugs.gnu.org; Sun, 14 Apr 2013 09:23:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40037) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URMtB-0006xs-Dm for submit@debbugs.gnu.org; Sun, 14 Apr 2013 09:22:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URMpB-0007CZ-WA for submit@debbugs.gnu.org; Sun, 14 Apr 2013 09:18:31 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-102.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:33722) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URMpB-0007CU-Ss for submit@debbugs.gnu.org; Sun, 14 Apr 2013 09:18:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URMpA-0003ld-Mt for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 09:18:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URMp8-0007Bz-OF for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 09:18:28 -0400 Received: from mout.web.de ([212.227.15.4]:58497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URMp8-0007Bf-Ep for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 09:18:26 -0400 Received: from drachen.dragon ([92.74.136.91]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0LpfC6-1V5OKf3lGI-00euEd for ; Sun, 14 Apr 2013 15:18:24 +0200 From: Michael Heerdegen Date: Sun, 14 Apr 2013 15:18:13 +0200 Message-ID: <878v4ls12i.fsf@web.de> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V02:K0:mA8Ri892GeiLPwQM3v/hNaCO8TeefXZHRRNTRcAPi7Q Kto7Pupn4ItmxWpehQcBpmq183ASU+ShxxVdckESNpYNmrXoTb l0tX/2g0swi4U3+p7a8nSL5VxFD5Tj4wYu3zIUFAeGYfZzb2Tx caCJI0YBtFEGi8QHt7GL0mJoQeYy8JIIvKRWbyg7hHbLFxBckB MEURmmTD/HJiHZL4pF63MO46Xy9+87uzH+/BPSk3Ak= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) Hi, recipe from emacs -Q: Save the following code into a file: --8<---------------cut here---------------start------------->8--- (require 'nadvice) (require 'shell) (eval-when-compile (require 'cl)) (advice-add 'shell-command-sentinel :around (lambda (_f process signal) "Handle output the way I want." (when (memq (process-status process) '(exit signal)) (let ((messg (format "%s: %s" (caddr (process-command process)) (substring signal 0 -1))) (buf (process-buffer process))) (when buf (with-current-buffer buf (if (> (point-max) (point-min)) (if (<= (+ 3 (count-lines (point-min) (point-max))) (if resize-mini-windows (cond ((floatp max-mini-window-height) (* (frame-height) max-mini-window-height)) ((integerp max-mini-window-height) max-mini-window-height) (t 1)) 1)) (message "%s" (concat messg ".\n" (propertize "Output" 'face 'underline) " was:\n" (with-current-buffer buf (buffer-string))) ) (message "%s" (concat messg "\n" (substitute-command-keys "Type \\[my-call-temp-command] to show output")))) (message "%s" (concat messg " with no output")))))))) '((name . handle-output-more-comfortable))) --8<---------------cut here---------------end--------------->8--- (The added function itself presumably doesn't make a difference here). Note the specified `name' property. Now, 1. byte-compile the file 2. load the elc 3. Also load the uncompiled source At the end, the advice was added twice: C-h f shell-command-sentinel RET ==> ,---------------------------------------------------------------------- | shell-command-sentinel is a compiled Lisp function in `simple.el'. | | (shell-command-sentinel PROCESS SIGNAL) | | :around advice: handle-output-more-comfortable | Handle output the way I want. | :around advice: handle-output-more-comfortable | Handle output the way I want. `---------------------------------------------------------------------- Looks like `advice--member-p' is not DTRT: When adding the advice the second time, this test (equal function (cdr (assq 'name (advice--props definition)))) seems to be "responsible". But it returns nil, because `function' is bound to a byte code function, while (cdr (assq 'name (advice--props definition))) evals to the advice name (a symbol). Thanks, Michael. In GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2) of 2013-04-10 on dex, modified by Debian (emacs-snapshot package, version 2:20130410-1) Windowing system distributor `The X.Org Foundation', version 11.0.11204000 System Description: Debian GNU/Linux 7.0 (wheezy) Configured using: `configure --build x86_64-linux-gnu --host x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes --enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.3.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3.50/site-lisp:/usr/share/emacs/site-lisp --without-compress-info --with-crt-dir=/usr/lib/x86_64-linux-gnu/ --with-x=yes --with-x-toolkit=gtk3 --with-imagemagick=yes CFLAGS='-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' CPPFLAGS='-D_FORTIFY_SOURCE=2' LDFLAGS='-g -Wl,--as-needed -znocombreloc'' From unknown Thu Aug 14 22:23:11 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: michael_heerdegen@web.de Subject: bug#14202: closed (Re: bug#14202: 24.3.50; add-function doesn't check properly for existing advices with same name prop) Message-ID: References: <878v4ls12i.fsf@web.de> X-Gnu-PR-Message: they-closed 14202 X-Gnu-PR-Package: emacs Reply-To: 14202@debbugs.gnu.org Date: Mon, 15 Apr 2013 15:12:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1366038722-21143-1" This is a multi-part message in MIME format... ------------=_1366038722-21143-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14202: 24.3.50; add-function doesn't check properly for existing advices w= ith same name prop which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 14202@debbugs.gnu.org. --=20 14202: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14202 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1366038722-21143-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 14202-done) by debbugs.gnu.org; 15 Apr 2013 15:11:42 +0000 Received: from localhost ([127.0.0.1]:52515 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URl4H-0005UH-Fw for submit@debbugs.gnu.org; Mon, 15 Apr 2013 11:11:41 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:64971) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URl4G-0005UA-3g for 14202-done@debbugs.gnu.org; Mon, 15 Apr 2013 11:11:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFxIEd/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0BwsUGA0kiB4GwS2RCgOkeoFegxM X-IPAS-Result: Av8EABK/CFFFxIEd/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0BwsUGA0kiB4GwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="7441650" Received: from 69-196-129-29.dsl.teksavvy.com (HELO pastel.home) ([69.196.129.29]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 15 Apr 2013 11:07:23 -0400 Received: by pastel.home (Postfix, from userid 20848) id D962C67912; Mon, 15 Apr 2013 11:07:26 -0400 (EDT) From: Stefan Monnier To: Michael Heerdegen Subject: Re: bug#14202: 24.3.50; add-function doesn't check properly for existing advices with same name prop Message-ID: References: <878v4ls12i.fsf@web.de> Date: Mon, 15 Apr 2013 11:07:26 -0400 In-Reply-To: <878v4ls12i.fsf@web.de> (Michael Heerdegen's message of "Sun, 14 Apr 2013 15:18:13 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 14202-done Cc: 14202-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > Looks like `advice--member-p' is not DTRT: > When adding the advice the second time, this test > (equal function (cdr (assq 'name (advice--props definition)))) > seems to be "responsible". But it returns nil, because `function' is > bound to a byte code function, while Duh! Indeed that code was confused. Should be fixed now. Thank you, Stefan ------------=_1366038722-21143-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 14 Apr 2013 13:23:00 +0000 Received: from localhost ([127.0.0.1]:49946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URMtW-0006zP-Br for submit@debbugs.gnu.org; Sun, 14 Apr 2013 09:23:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40037) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URMtB-0006xs-Dm for submit@debbugs.gnu.org; Sun, 14 Apr 2013 09:22:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URMpB-0007CZ-WA for submit@debbugs.gnu.org; Sun, 14 Apr 2013 09:18:31 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-102.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:33722) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URMpB-0007CU-Ss for submit@debbugs.gnu.org; Sun, 14 Apr 2013 09:18:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URMpA-0003ld-Mt for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 09:18:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URMp8-0007Bz-OF for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 09:18:28 -0400 Received: from mout.web.de ([212.227.15.4]:58497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URMp8-0007Bf-Ep for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 09:18:26 -0400 Received: from drachen.dragon ([92.74.136.91]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0LpfC6-1V5OKf3lGI-00euEd for ; Sun, 14 Apr 2013 15:18:24 +0200 From: Michael Heerdegen To: bug-gnu-emacs@gnu.org Subject: 24.3.50; add-function doesn't check properly for existing advices with same name prop Date: Sun, 14 Apr 2013 15:18:13 +0200 Message-ID: <878v4ls12i.fsf@web.de> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V02:K0:mA8Ri892GeiLPwQM3v/hNaCO8TeefXZHRRNTRcAPi7Q Kto7Pupn4ItmxWpehQcBpmq183ASU+ShxxVdckESNpYNmrXoTb l0tX/2g0swi4U3+p7a8nSL5VxFD5Tj4wYu3zIUFAeGYfZzb2Tx caCJI0YBtFEGi8QHt7GL0mJoQeYy8JIIvKRWbyg7hHbLFxBckB MEURmmTD/HJiHZL4pF63MO46Xy9+87uzH+/BPSk3Ak= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: michael_heerdegen@web.de List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) Hi, recipe from emacs -Q: Save the following code into a file: --8<---------------cut here---------------start------------->8--- (require 'nadvice) (require 'shell) (eval-when-compile (require 'cl)) (advice-add 'shell-command-sentinel :around (lambda (_f process signal) "Handle output the way I want." (when (memq (process-status process) '(exit signal)) (let ((messg (format "%s: %s" (caddr (process-command process)) (substring signal 0 -1))) (buf (process-buffer process))) (when buf (with-current-buffer buf (if (> (point-max) (point-min)) (if (<= (+ 3 (count-lines (point-min) (point-max))) (if resize-mini-windows (cond ((floatp max-mini-window-height) (* (frame-height) max-mini-window-height)) ((integerp max-mini-window-height) max-mini-window-height) (t 1)) 1)) (message "%s" (concat messg ".\n" (propertize "Output" 'face 'underline) " was:\n" (with-current-buffer buf (buffer-string))) ) (message "%s" (concat messg "\n" (substitute-command-keys "Type \\[my-call-temp-command] to show output")))) (message "%s" (concat messg " with no output")))))))) '((name . handle-output-more-comfortable))) --8<---------------cut here---------------end--------------->8--- (The added function itself presumably doesn't make a difference here). Note the specified `name' property. Now, 1. byte-compile the file 2. load the elc 3. Also load the uncompiled source At the end, the advice was added twice: C-h f shell-command-sentinel RET ==> ,---------------------------------------------------------------------- | shell-command-sentinel is a compiled Lisp function in `simple.el'. | | (shell-command-sentinel PROCESS SIGNAL) | | :around advice: handle-output-more-comfortable | Handle output the way I want. | :around advice: handle-output-more-comfortable | Handle output the way I want. `---------------------------------------------------------------------- Looks like `advice--member-p' is not DTRT: When adding the advice the second time, this test (equal function (cdr (assq 'name (advice--props definition)))) seems to be "responsible". But it returns nil, because `function' is bound to a byte code function, while (cdr (assq 'name (advice--props definition))) evals to the advice name (a symbol). Thanks, Michael. In GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2) of 2013-04-10 on dex, modified by Debian (emacs-snapshot package, version 2:20130410-1) Windowing system distributor `The X.Org Foundation', version 11.0.11204000 System Description: Debian GNU/Linux 7.0 (wheezy) Configured using: `configure --build x86_64-linux-gnu --host x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes --enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.3.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3.50/site-lisp:/usr/share/emacs/site-lisp --without-compress-info --with-crt-dir=/usr/lib/x86_64-linux-gnu/ --with-x=yes --with-x-toolkit=gtk3 --with-imagemagick=yes CFLAGS='-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' CPPFLAGS='-D_FORTIFY_SOURCE=2' LDFLAGS='-g -Wl,--as-needed -znocombreloc'' ------------=_1366038722-21143-1--