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

Filter by
Sorted by
Tagged with
1
vote
0answers
122 views

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 ...
0
votes
1answer
54 views

Problem about `evil-visual-state` and advising `read-key-sequence` with `call-process`

In Evil mode, after I enter visual-state, I can use f to expand the selection by jumping to a character. Now if I've pressed f after entering visual-state, Emacs asks me to input a character to jump ...
3
votes
1answer
327 views

Defining advice for cider-interactive-eval for evil compatibility

Cider offers very useful debugger for clojure code. Once you enter the debugger, you can step through it with keys like (n)ext, (o)ut, etc., like so. Using evil, the problem is that if I enter this ...
4
votes
3answers
626 views

Call a function before a specific major mode starts

I have a setup function that I want to run before I use pdb/gud to debug a Python script. I know about gud-mode-hook which runs after the debugger starts (too late) and change-major-mode-hook which, ...
2
votes
2answers
113 views

On monkey-patching a third-party function

The following snippet, featuring the "fantasy function" clone-function, illustrates what I'd like to do: (defvar last-enabled-foo nil) ;; hold on to a "clone"/copy of third-party function enable-foo ...
12
votes
2answers
750 views

How to manipulate argument list in nadvice.el?

Following on from an answer to another question about the new advice system: In old-style advice.el, it was possible to manipulate individual members of an advised function's argument list, without ...
10
votes
3answers
1k views

How to write a transparent “pass-through” function wrapper?

What I mean by a "transparent 'pass-through' function wrapper" is a function, let's call it wrapper, that returns the result from passing all its argument to some other function, let's call it wrappee....
6
votes
3answers
1k views

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 ...
3
votes
0answers
54 views

Passing advice to mode line

I'd like to advise format-mode-line to collapse whitespace across the whole string. The following attempt does not work for me. (advice-add 'format-mode-line :filter-return 'collapse-whitespace) ...
3
votes
2answers
113 views

in org-mode, how to move point to next checkbox when it's marked completed?

I work with org-mode checkboxes, marking them as completed as I go. * TODO clean kitchen - [X] sink - [ ] stove - [ ] floors I want org to move point to the next checkbox when when it gets marked - ...
7
votes
1answer
2k views

Override a function locally, but allow calls to the original function

The advice feature allows modifying the behavior of a function globally. An advice definition can make calls to the original function. (defadvice foo (around foo-bar activate compile) "Always set ...
2
votes
2answers
202 views

advising two `synonyms.el` functions using `defadvice`

What's the best way to simplify this? (defadvice synonyms (after synonyms-jump-to-window) (switch-to-buffer-other-window "*Synonyms*")) (defadvice synonyms-no-read (after synonyms-jump-to-...
14
votes
1answer
630 views

Emacs let-bound advice

I'd like to temporarily override a function in a piece of code. Take, for example, the following: (defun nadvice/load-quiet (args) (cl-destructuring-bind (file &optional noerror ...
3
votes
3answers
160 views

Sort of autoreply for specific messages in minibuffer

Every time when I call M-x projectile-regenate-tags I get bothered with the message Tags file a:/foobar/TAGS has changed, read new contents? (y or n) which is quite cumbersome. Especially when I ...
0
votes
1answer
111 views

restore cursor position iedit mode after narrowing with evil visul line

Iedit-mode can narrow the edit to a region, I am using evil-mode, evil-visual-line select region by whole lines, after narrowing the point is at the end of last line, is it possible to fix this ...
29
votes
1answer
3k views

How do I use nadvice?

My config is full of advice, and I keep hearing about the new shiny minimalist nadvice.el package. I've searched the manuals, and I've read the source, but I'll openly admit: I still have no idea ...
5
votes
1answer
301 views

How can I get VolatileHighlights to work with evil-yank, evil-delete, etc?

With the guide on extending Emacs, I discovered the volatile highlights package. But it only works on Emacs operations like kill and yank. I would like to use it with Evil operations like evil-yank ...
5
votes
2answers
495 views

Getting electric-pair mode to behave more nicely around existing strings

Electric-pair-mode always tries to insert a closing delimiter after the opening one if nothing is selected. However, if you're placing delimiters around an existing something that you don't want to ...
0
votes
1answer
43 views

What's the most effective way to modify this internal mode config?

markdown-mode defines tab-width using a magic number when loaded, overwriting any global settings I have (namely, 2 spaces): ;;;###autoload (define-derived-mode markdown-mode text-mode "Markdown" "...
1
vote
1answer
105 views

Advising evil-forward-char seems to trigger advice twice

I am trying to update annoying-arrows to work with evil-mode. Annoying arrows is this minor-mode that complains when you use the same simple movement-command too many times in a row. (I have also ...
5
votes
2answers
850 views

Change focus to *Help* buffer after running describe-mode

When I type C-h m for describe-mode the frame splits into two windows with the current buffer on top and the *Help* buffer below. But the focus stays in the current buffer, so I usually have to type C-...
5
votes
1answer
137 views

How to get the arguments of an advised function?

After my initial config, ido-read-internal becomes advised by flx: (ido-mode) (require 'flx-ido) (setq ido-enable-flex-matching t) So now I get this: (help-function-arglist 'ido-read-internal t) ;; ...
13
votes
3answers
5k views

before-save-hook for cc-mode

I want to customize cc-mode to execute a function before saving. One solution would be to modify cc-mode keymap to bind C-x C-s to a function which performs the work I need and then saves it. My ...
10
votes
5answers
1k views

How to enter view-only mode when browsing Emacs source code from help?

When I browse Emacs help for functions via C-h f, I often want to peek into the Elisp/C implementation. I want to enter view-mode automatically when I access source code this way to avoid unnecessary ...
2
votes
1answer
378 views

Monkey patching a function

Some context: I'm doing some linux kernel development on a Debian VM so naturally I'm using tramp. I want to use semantic-symref, but the trouble is that: Semantic will eventually call cedet-gnu-...
52
votes
4answers
4k views

Practical benefits of new advice system in Emacs 24.4

Emacs 24.4 comes with a new advice system. The NEWS file says: ** New package nadvice.el offers lighter-weight advice facilities. It is layered as: *** add-function/remove-function, which ...

1
2