From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Simple defadvice's stopped working (commit daa84a03, Thu Nov 8 23:10:16 2012 -0500) Date: Fri, 16 Nov 2012 12:25:15 -0500 Message-ID: References: <87haoyl4on.fsf@topper.koldfront.dk> <87625bw1jx.fsf@visionobjects.com> <87pq3fxmta.fsf@googlemail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1353086728 15355 80.91.229.3 (16 Nov 2012 17:25:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 Nov 2012 17:25:28 +0000 (UTC) Cc: Katsumi Yamaoka , ivan.kanis@googlemail.com, asjo@koldfront.dk, emacs-devel@gnu.org To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 16 18:25:38 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TZPfa-0005Gc-Hg for ged-emacs-devel@m.gmane.org; Fri, 16 Nov 2012 18:25:34 +0100 Original-Received: from localhost ([::1]:45046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZPfQ-00009s-Jm for ged-emacs-devel@m.gmane.org; Fri, 16 Nov 2012 12:25:24 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZPfL-00008O-MI for emacs-devel@gnu.org; Fri, 16 Nov 2012 12:25:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TZPfI-0004NA-Kk for emacs-devel@gnu.org; Fri, 16 Nov 2012 12:25:19 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:20946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZPfI-0004N2-GC for emacs-devel@gnu.org; Fri, 16 Nov 2012 12:25:16 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09sr+ZY/2dsb2JhbABEsEiDSYEIghUBAQQBViMQCw4mEhQYDSSIHAW6CYsIhTwDiEKacYFYgwc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="207789300" Original-Received: from 108-175-230-88.dsl.teksavvy.com (HELO pastel.home) ([108.175.230.88]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 16 Nov 2012 12:25:15 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 39DEB59346; Fri, 16 Nov 2012 12:25:15 -0500 (EST) In-Reply-To: (Juanma Barranquero's message of "Fri, 16 Nov 2012 17:33:00 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:154883 Archived-At: >> But if you can point me to concrete examples that need to work (and/or >> that used to work), it would be very helpful. > As an example of an advice from my .emacs that used to work: > (defadvice delete-indentation (before my-delete-indentation activate compile) > (when (called-interactively-p 'any) > (ad-set-arg 0 (not (ad-get-arg 0))))) OK, that's a good start. My current code can handle uses of called-interactively-p in after/before advice but not in around advice. Problem is: all advices defined with `defadvice' are implemented as (advice-add foo :around ...) and indeed your "before" advice cannot be implemented as a (advice-add foo :before ...) because it modifies arguments. Hmm... maybe advice-add's before and after advices should be different. Instead of before being like (lambda (&rest r) (apply FUNCTION r) (apply OLDFUN r)) it should maybe be like (lambda (&rest r) (apply OLDFUN (apply FUNCTION r))) Or maybe this should be a new WHERE, which we could call `:filter-args', and we could have a corresponding `:filter-return'. In that case my code would handle: (advice-add 'delete-indentation :filter-args (lambda (arg &rest args) (cons (or (called-interactively-p 'any) arg) args))) -- Stefan