Questions tagged [defadvice]

defadvice is a macro defined in ELisp. It provides a mechanism to wrap existing functions and have the wrapper called instead of the original function.

defadvice provides a mechanism for the user to define a function to be called before, after or around an existing function; instead of that existing function. It is analogous to the CLOS method combination system.

Multiple advices can be placed upon a function and they will combine to all be called. First all before methods are called, then all around methods, then all after methods. Methods are called in the order of the defadvice. Around methods can decide to terminate and not call any other methods - thus circumventing the original method and any other advice.

29 questions
2
votes
1 answer

How can I set up two, parallel buffers in emacs to edit Python files in one and execute in an IPython shell in the other?

I'm trying to setup ipython.el in emacs23. I've successfully installed it (after putting python-mode.el in my load-path to supplant python.el which comes pre-installed with emacs). And I can even get it to run via M-x py-shell, etc. The interface…
aresnick
  • 1,635
  • 12
  • 24
2
votes
1 answer

Advising an emacs function; defadvice

I'm trying to advise a function in emacs, but nothing happens. (defadvice save-place-find-file-hook (after recenter activate) "Recenter after getting to saved place." (recenter)) Recentering doesn't happen, that is. If have a (message "foo")…
Daniel
  • 101
  • 4
2
votes
2 answers

Properly handing failed snippet completions

I use TAB to expand snippets from yasnippet, when it doesn't expand a snippet, it usually falls back to indenting (the default command bound to TAB), this is referred to by yasnippets custom variable yas-fallback-behavior which can only be…
Dan LaManna
  • 3,431
  • 4
  • 23
  • 35
2
votes
1 answer

Warning when I revert from desktop session. Emacs

Yesterday I found desktop mode from EmacsWiki, and then I configure it for my Emacs 24: ;; Desktop (require 'desktop) ;; save the desktop file automatically if it already exists (desktop-save-mode 1) ;; use only one desktop (setq desktop-path…
hbin
  • 2,657
  • 1
  • 23
  • 23
1
vote
1 answer

Emacs 26 flymake: customizing the mode line format

I'm considering switching back from flycheck to flymake after the Emacs 26 rewrite. One thing that bothers me about flymake is how much room on the mode line it takes up. It has a string Flymake plus the results. It seems like a silly thing but…
MadScientist
  • 92,819
  • 9
  • 109
  • 136
1
vote
1 answer

Change expression in body of elisp function with advice

How do you match a specific expression in the body on elisp function when adding advice? Specifically, in the following example, I would like to advise the function to use find-file-noselect in place of find-file, ie. the line (find-file path)…
Rorschach
  • 31,301
  • 5
  • 78
  • 129
1
vote
0 answers

Annoying delay when killing a buffer containing an executing process

Every time I kill a buffer containing an executing process in Emacs I get an annoying ~2 second delay before my interaction continues. And when that happens I get the message error in process sentinel: Selecting deleted buffer The tricky problem is…
Nordlöw
  • 11,838
  • 10
  • 52
  • 99
1
vote
1 answer

whether and how to avoid eval in defadvice loop

Should one avoid eval in the following code? If so, how? Or is this one of exceptional cases where using eval is better? (dolist (command '(....)) (eval `(defadvice ,command (around blah activate) ...))) For a real life example of the…
Jisang Yoo
  • 3,670
  • 20
  • 31
1
vote
1 answer

How to have advice not execute the function when conditions are met?

How do you prevent the advised function from running when the advice returns nil? (defadvice beginning-of-line (before test activate) nil) -> Not running beginning-of-line at all. EDIT: Just to take away your worries, I do not intend to use it on…
PascalVKooten
  • 20,643
  • 17
  • 103
  • 160
1
vote
2 answers

can defadvice use variables in the original function?

Let me take the modified example from Emacs Lisp: How to use ad-get-arg and ad-get-args? (defun my-add (a b &optional c) (+ a b) (unless c (setq c 4))) (defadvice my-add (after my-log-on (a b &optional c) activate) (message "my-add a: %s"…
RNA
  • 146,987
  • 15
  • 52
  • 70
0
votes
1 answer

Displaying used formula in excel with Parameter names used in column A

I need your expert advice to provide a VBA script that automatically displays used formula in excel. For example The cell D4 should display the formula used in B4 with the Parameter names used in column A. The script below in VBA provides the…
Techy
  • 1
0
votes
1 answer

Override interactive function with advice

How can I override interactive input with defadvice in elisp? For example, I am trying to stop ansi-term from prompting for input with the following: (defadvice ansi-term (around kill-interactive activate) (let ((explicit-shell-file-name…
Rorschach
  • 31,301
  • 5
  • 78
  • 129
0
votes
1 answer

Advicing message not working

(defun my-message (format-string &rest args) (apply 'message (concat "my-message: " format-string) args)) (my-message "abc %d" 123) ;; ==> "my-message: abc 123" (message "abc %d" 123) ;; ==> "abc 123" (advice-add 'message…
tom
  • 1,302
  • 1
  • 16
  • 30
0
votes
1 answer

defadvice error for isearch-search-fun-default

This is a continue of my previous post (is it possible to preprocess the input string before isearch-forward in Emacs). I am trying to implement jpkotta's answer using the variable isearch-search-fun-function. Instead of writing my own function, I…
RNA
  • 146,987
  • 15
  • 52
  • 70
1
2