defadvice

Warning when I revert from desktop session. Emacs

廉价感情. 提交于 2020-01-04 05:36:06
问题 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 '("~/.emacs.d/tmp/")) (setq desktop-dirname "~/.emacs.d/tmp/") (setq desktop-base-file-name "desktop.cache") But I got a warning in *Compile-Log* buffer when I restart Emacs: Warning: ad-Orig-kill-region called with 3 arguments, but accepts only 2 Anyone

Emacs defadvice on python-mode function

让人想犯罪 __ 提交于 2019-12-21 05:03:41
问题 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 so I can continue producing more code. I wrote a simple advising function: (defadvice py-execute-region (after py-execute-region-other-window activate) """ After execution, return cursor to script buffer """ (other-window 1) ) But this does not do

How to advise primitives in Emacs

和自甴很熟 提交于 2019-12-13 13:22:19
问题 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 saving.")) (defadvice file-writable-p (around my-overide-file-writeable-p act) "override file-writable-p if `my-override-mode-on-save' is set." (or my-override-mode-on-save ad-do-it)) (defun my-override-toggle-read-only () "Toggle buffer's read-only

defadvice error for isearch-search-fun-default

心已入冬 提交于 2019-12-13 04:29:04
问题 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 just advise the isearch-search-fun-default to include my own functions ( isearch-str-forward and isearch-str-backward , just for the purpose of demo) so that everytime I type "abc", isearch will highlight and search the regexp a[ ]*b[ ]*c[ ]* .

What does ad-activate do?

扶醉桌前 提交于 2019-12-10 15:08:31
问题 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... what does it do?! I tried eval-region on the block of code. But for me, all it does is adding the following to the align-regexp docs: This function is advised. Around-advice `align-regexp-with-spaces': Never use tabs for alignment. I don't seem to be able

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

大兔子大兔子 提交于 2019-12-07 11:05:12
问题 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 .el file the defadvice is called. Is there any way to navigate to the original file, where the advice is defined? Edit: While i marked correct Phils' suggestion to rgrep the .el files, i still hope, that there is some more elegant way to trace back to

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

不羁岁月 提交于 2019-12-07 02:42:39
问题 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 that variable buffer-local. That works if I want the same static value, always. But I'd like to intelligently select the compile-command depending on the contents of the buffer, the name of the buffer, the contents of the containing directory of the

Advising an emacs interactive function: before

牧云@^-^@ 提交于 2019-12-07 02:32:29
问题 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 after find-dired interactive session and I can't setup find-args before. How to resolve the contradiction? Upd. Note that defadvice macro is deprecated. 回答1: artscan answered his own question with a workable answer, but it's a bit incomplete and

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

倖福魔咒の 提交于 2019-12-05 13:36:54
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 .el file the defadvice is called. Is there any way to navigate to the original file, where the advice is defined? Edit: While i marked correct Phils' suggestion to rgrep the .el files, i still hope, that there is some more elegant way to trace back to the defadvice. As far as I know there is no way to navigate to the location of a defadvice expression

Advising an emacs interactive function: before

蓝咒 提交于 2019-12-05 07:44:08
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 after find-dired interactive session and I can't setup find-args before. How to resolve the contradiction? Upd. Note that defadvice macro is deprecated . Trey Jackson artscan answered his own question with a workable answer, but it's a bit incomplete and misleading. This also involves 'interactive , which can be confusing in and of itself - in that it