Questions tagged [advice]

is for the Elisp advice feature that changes an existing definition of a function in a way that lets you undo the change easily. This tag applies to both old and new advice features. The old advice feature uses defadvice. The new advice feature uses functions and macros such as advice-add and add-function.

While the tag is properly spelled as the noun , the Emacs manuals and Stack Exchange questions also use advise(the verb form) and advising. Try these alternate spellings when searching.

Useful Link:

105 questions
11
votes
3 answers

How can I remove an unnamed advice?

I was having fun adding some advice to a function: (advice-add 'executable-find :around (lambda (f &rest args) (apply g args))) ;;; ^ Ouch, a typo. Fixed it and evaluated above code again. But now I have…
Daniel Jour
  • 435
  • 2
  • 10
11
votes
1 answer

Unadvise a function (remove all advice from it)

I cannot find a predefined command in nadvice to easily unadvise a function in Emacs 24.5.1. Something like: (defun advice-unadvice (sym) "Remove all advices from symbol SYM." (interactive "aFunction symbol:") (advice-mapc `(lambda (fun props)…
Tobias
  • 33,167
  • 1
  • 37
  • 77
9
votes
2 answers

List advice for functions

I had a look over the weekend, and I cannot see an easy way to check whether a function is advised. I must be missing something. HELP! :)
Realraptor
  • 1,283
  • 7
  • 17
7
votes
3 answers

How to bypass (or disable) a command's "advice"?

In my .emacs I have an expression of the form (defadvice find-file ...) ...which modifies the behavior of the standard find-file command. There are times, however, when I want to bypass this customized behavior altogether, and run the original,…
kjo
  • 3,247
  • 17
  • 48
4
votes
2 answers

How do I use an advice to change the definition of goto-char within a function?

Suppose a third-party plugin contains the following function: (defun example-function () (interactive) ;; ... do many things ... (goto-char (point-max)) ;; ... do many things ... (goto-char (point-max)) ;; ... do many things ... …
Flux
  • 603
  • 3
  • 17
2
votes
1 answer

How to override a function in a function only in that function?

I used (advice-add 'yas-new-snippet :override 'my/yas-new-snippet ) but I was wondering if there was something like this which would allow me to override a function in a function only in that function: (override-func 'yas-new-snippet…
ritchie
  • 159
  • 6
2
votes
0 answers

How to find out what advice has been defined for a function?

I accidentally added a lambda function that wasn't done being written to the advice of a function, and the function doesn't work. I don't know the exact text of the lambda function. Obviously, I could fix the problem by restarting emacs, but I don't…
Zorgoth
  • 840
  • 6
  • 14
1
vote
1 answer

Argument Access in Advice

In the documentation, two ways are suggested for accessing arguments in an advice: by the name of the argument in the original function and by using special functions. I cannot get the second way to work. Here is my attempt: (defun…
AlwaysLearning
  • 779
  • 4
  • 15
1
vote
0 answers

How to eliminate all advice from function?

Is there a way to remove all advice added to a function with advice-add? advice-remove requires the original function to be passed in. Sometimes, when experimenting w/ advice, I'll add several lambdas as advice to an fn, and would like a way to…
Tianxiang Xiong
  • 3,878
  • 18
  • 28
1
vote
0 answers

Find where advice is defined (defadvice)

When a function documentation page tells me that a function has advice, is there any way to find out where that piece of advice is defined? This is advice that was created using the defadvice facility. I was eventually able to find it by grepping…
nispio
  • 8,225
  • 2
  • 36
  • 74
0
votes
0 answers

Updating advice in function

I've noticed that if function f is used to advise function g through advice-add, and function f is then redefined, function g's advice is not updated. After digging into advice-add a bit, it is clear that advice-add uses add-function behind the…
Tianxiang Xiong
  • 3,878
  • 18
  • 28