Questions tagged [advising-functions]

GNU Emacs functions can be extended by advising them. Use this tag for questions that are directly related to advising Emacs functions.

There are two advice systems for GNU Emacs:

  • The traditional system, which uses Emacs Lisp macro defadvice to advise a function.
  • The new system, which uses macros add-function and remove-function, and which is implemented in library nadvice.el.

The Elisp manual, node Advising Functions, provides the documentation for this topic.

33 questions
43
votes
2 answers

Is it possible to change emacs' regexp syntax?

I love emacs. I love regexs. I hate emacs' regex syntax - the need to escape grouping parens and braces, that you dont escape literal parens, the lack of predefined character classes, etc. Can I replace emacs' regex engine, or tweak some setting,…
Chadwick
  • 12,555
  • 7
  • 49
  • 66
18
votes
4 answers

How to force Emacs not to display buffer in a specific window?

My windows configuration looks like this: +----------+-----------+ | | | | | | | | | | | | | | | | …
polyglot
  • 9,945
  • 10
  • 49
  • 63
7
votes
3 answers

Emacs - Skip whitespace kills

I'm trying to make the kill ring essentially ignore whitespace only entries (tabs, newlines, just spaces, etC), I'm fairly new to elisp and I'm pretty sure the way to do is by doing defadvice but I have a few questions. Would it better to stop…
user652650
  • 648
  • 6
  • 18
6
votes
5 answers

Emacs/Emacs Lisp: can I insert advice before interactive form? or how to intelligently pre-set the compile-command?

What I'd like to do is intelligently pre-set a buffer-local default value for the string argument to the compile function. Right now compile.el defaults to using "make" as the command. I can set this by setting compile-command. I can even make…
Cheeso
  • 189,189
  • 101
  • 473
  • 713
6
votes
2 answers

Override a single function in an Emacs library

I use an Emacs mode to annotate some of my files (the actual mode is not important). It's supplied as a library and comes with compiled lisp code (of course). I want to modify its behavior by overriding a single function in it. Just for my local…
Lajos Nagy
  • 9,075
  • 11
  • 44
  • 55
6
votes
5 answers

Advising an emacs interactive function: before

I want to before-advice some function, which uses interactive arguments, e.g. find-dired: (defadvice find-dired (before eab-find-dired activate) (message "before!") (setq find-args '("-iname '**'" . 10))) But emacs executes this advice only…
artscan
  • 2,340
  • 15
  • 26
6
votes
2 answers

how to change variables for specific fundamental-mode buffers

Goal: I want to have show-trailing-whitespace enabled for all buffers save a few. Exceptions posing a problem are *Shell Command Output* and its cousin *Async Shell Command*. I usually have show-trailing-whitespace customized to t. Therefore it is…
Moritz Bunkus
  • 11,592
  • 3
  • 37
  • 49
6
votes
4 answers

emacs: How to use the mark-ring?

When I do a C-u C-SPC, emacs takes me to "where I was before". Subsequent C-u C-SPC presses go back up previous places. That is damn great, and I use it a lot. But something always bugged me : The only mark missing from the mark-ring is…
yPhil
  • 8,049
  • 4
  • 57
  • 83
5
votes
3 answers

How can I prevent emacs hanging when initial-buffer-choice has auto save data?

I use emacs in daemon mode and I also have an initial-buffer-choice variable set. Sometimes emacs will crash when I am editing the file that I use for initial-buffer-choice. In this case, when I start emacs with --daemon, it will hang with the…
amoe
  • 4,473
  • 4
  • 31
  • 51
5
votes
4 answers

Emacs defadvice on python-mode function

In python-mode, there is a function called py-execute-region which sends a highlighted region of code to the Python buffer for evaluation. After evaluation, the cursor is in the Python buffer, but I would prefer that it remain in the script buffer…
hatmatrix
  • 42,883
  • 45
  • 137
  • 231
5
votes
1 answer

Emacs Lisp, how to mapcar a macro, and evaluate one of the arguments

Bob Glickstein describes in "Writing GNU Emacs Extensions", chapter 3, a way to advise scroll functions. (He suggests to make them reversible, so we have to save the state before scrolling.) E.g. for scroll-up-command this advising is done like…
Falko
  • 1,028
  • 1
  • 12
  • 24
5
votes
1 answer

What does ad-activate do?

In an answer, I noticed: ;; Align with spaces only (defadvice align-regexp (around align-regexp-with-spaces) "Never use tabs for alignment." (let ((indent-tabs-mode nil)) ad-do-it)) (ad-activate 'align-regexp) This sounds promising, but...…
Michel de Ruiter
  • 7,131
  • 5
  • 49
  • 74
4
votes
1 answer

How to advise primitives in Emacs

I was trying to answer another SO question when I hit upon some very odd behavior. Here's my little test case: (make-variable-buffer-local (defvar my-override-mode-on-save nil "Can be set to automatically ignore read-only mode of a file when…
Joe Casadonte
  • 15,888
  • 11
  • 45
  • 57
4
votes
1 answer

Emacs cursor movement advice

I have written a minor mode that highlights various parts of the buffer as the cursor moves around the buffer. I do this by advising the movement functions like this. ... (defadvice next-line (after showcss/advise-main) "Advice around cursor…
Sheldon
  • 43
  • 3
4
votes
1 answer

How can I locate the defadvice for an advised function in Emacs?

When I view documentation for beginning-of-defun, there is a note: This function is advised. Around-advice `senator': Move backward to the beginning of a defun. If semantic tags are available, use them to navigate. However I can't find in which…
Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166
1
2 3