unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Question at Emacs.SE: Practical benefits of new advice system in Emacs 24.4
@ 2014-11-04 18:19 Artur Malabarba
  2014-11-06  3:23 ` Michael Heerdegen
  0 siblings, 1 reply; 2+ messages in thread
From: Artur Malabarba @ 2014-11-04 18:19 UTC (permalink / raw)
  To: help-gnu-emacs

http://emacs.stackexchange.com/q/3079/50

This sounds like a question someone in here might know.
In summary (for those who don't want to follow the link), here's what's
being asked:

--------------------------------------
 What are the practical benefits and implications of this new package?

   -

   If I am only using advice to customize Emacs (as opposed to writing
   add-on packages), do I need to switch to the new system? Will it replace
   the old system at some point?
   -

   What *exactly* can I do with the new system that I can't accomplish with
   defadvice?
   -

   What is the significance of being able to "add/remove code on any
   function-carrying place"?

--------------------------------------

Cheers
Artur


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question at Emacs.SE: Practical benefits of new advice system in Emacs 24.4
  2014-11-04 18:19 Question at Emacs.SE: Practical benefits of new advice system in Emacs 24.4 Artur Malabarba
@ 2014-11-06  3:23 ` Michael Heerdegen
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen @ 2014-11-06  3:23 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Artur,

I can't speak for the author (Stefan), but I'll try to give my best to
give an answer.

>  What are the practical benefits and implications of this new package?

Generally, it's a new implementation of the functionality of advice.el.
It is shorter, has a much simpler and clearer semantic, and some new
features.

>    If I am only using advice to customize Emacs (as opposed to writing
>    add-on packages), do I need to switch to the new system? Will it replace
>    the old system at some point?

In general there's no strong need to switch to the new system soon.
Note that advice.el has been completely rewritten based on nadvice, so,
strictly speaking, you're probably already using nadvice (indirectly).

Since tons of third party packages still depend on advice.el, it will
probably be part of Emacs for a very long time.

A disadvantage of still using advice is that there are some few issues
with it now. For example, AFAICT the generated documentation of
functions adviced with advice.el in *Help*states all advices as being of
type :around now, since advices in the rewritten advice.el are all
implemented as :around advices in terms of nadvice.el.

And there are some rarely used features of the old advice.el that the
rewritten version doesn't reimplement, features I never heard of.

>    What *exactly* can I do with the new system that I can't accomplish with
>    defadvice?

When you only use nadvice for customization reasons, there are not many
new things you can do with it, apart from the fact that your new advices
will look "lispier".  There are much more advice types now as in the old
package which are more handy in several situations.

>    What is the significance of being able to "add/remove code on any
>    function-carrying place"?

For your Emacs init file, there is not so much relevance.

With the old system, you could only advice named functions (defuns).
With nadvice, this has been generalized.  It's best to read the manual,
and to grep for "add-function" in the Emacs sources to see some real
life examples.

One example are the numerous function valued variables in Emacs named
"...-function" that you can now advice.  That had not been possible with
advice.el.

Or, have a look at this example from the manual:

,----------------------------------------------------------------------
| 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)
| 
|    This will cause the process’s output to be passed to
| ‘my-tracing-function’ before being passed to the original process
| filter.
`----------------------------------------------------------------------

This would not be possible with advice.el, since the process filter is
an anonymous function - there is not even a variable bound to this
function.


HTH, and that I didn't tell something wrong,

Michael.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-06  3:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04 18:19 Question at Emacs.SE: Practical benefits of new advice system in Emacs 24.4 Artur Malabarba
2014-11-06  3:23 ` Michael Heerdegen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).