emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple defadvice's stopped working (commit daa84a03, Thu Nov 8 23:10


From: Stefan Monnier
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]