elisp

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

Making a region-indent-function keep the region marked

馋奶兔 提交于 2019-12-05 13:22:48
I'm having trouble with haml-mode's region-indent-function , which I'm trying to reuse in another major mode. We're supposed to be able to cycle the region indentation by keeping the region marked after the haml-indent-region is being evaled, but it doesn't work as intended. After some hacking around, I've found out that throwing an error at the end of the function makes Emacs keep the region marked, as in this example: (defun haml-indent-region (start end) (save-excursion ...) (error "")) ;; Terrible hack But I really don't like it. Is there a clean way of getting this behavior without such

.emacs.d and site-lisp directory

戏子无情 提交于 2019-12-05 12:13:52
I have the following two questions about emacs In my .emacs.d directory there is an empty directory called auto-save-list. What is that for ? I have create a elisp directory in my home directory on my linux machine where i place .el files. In my .emacs i have (add-to-list 'load-path "~/elisp") Now,I have heard of .emacs.d/site-lisp directory. Im confused about the difference between site-lisp and my own elisp directory. Can someone please explain. Thank You You can read about auto-save-list here: C-h i g (emacs) Recover RET Emacs records information about interrupted sessions for later

How to automatically decompress a custom compressed file when opened in emacs?

微笑、不失礼 提交于 2019-12-05 11:52:01
I know Emacs automatically opens compressed files like .tar.gz . I'm trying to figure how to achieve this with my own compression script rather than the standard ones. Following this link , I added the following to my Emacs init file (if (fboundp 'auto-compression-mode) (auto-compression-mode 0) (require 'jka-compr)) (add-to-list 'jka-compr-compression-info-list ["\\.customcom\\'" "custom compressing" "customcom" (-c) "custom decompressing" "customcom" (-d) nil t]) (auto-compression-mode 1) Ideally, i want to run the command customcom -d foo.customcom when the file is opened but with the above

How can I get a variable's initial value in Elisp?

穿精又带淫゛_ 提交于 2019-12-05 11:47:44
In Emacs Lisp, is there a function to get the initial value of a symbol initilized by defvar ? Like the some-function shown below: (defvar var "initial value") (setq var "changed value") (some-function 'var) => "inital value" Gilles 'SO- stop being evil' Emacs doesn't remember the initial value. If you evaluate (defvar var "initial value") (setq var "changed value") in the *scratch* buffer, "initial value" is no longer available, full stop. If the defvar was performed in a loaded file, Emacs remembers where it's loaded from; (symbol-file var 'defvar) returns the file name, and you can get an

replace-char in Emacs Lisp ?

馋奶兔 提交于 2019-12-05 11:22:22
Emacs Lisp has replace-string but has no replace-char . I want to replace "typographic" curly quotes (Emacs code for this character is hexadecimal 53979) with regular ASCII quotes, and I can do so with: (replace-string (make-string 1 ?\x53979) "'") I think it would be better with replace-char . What is the best way to do this? Why not just use (replace-string "\x53979" "'") or (while (search-forward "\x53979" nil t) (replace-match "'" nil t)) as recommended in the documentation for replace-string? This is the way I replace characters in elisp: (subst-char-in-string ?' ?’ "John's") gives: "John

Emacs and Long Shell Commands

风格不统一 提交于 2019-12-05 10:55:39
Is there a way to run a shell command, have the output show up in a new buffer and have that output show up incrementally? Eshell and other emacs terminal emulators do a find job of this but I see no way to script them. What I'd like to do is write little elisp functions to do stuff like run unit tests, etc. and watch the output trickle into a buffer. The elisp function shell-command is close to what I want but it shows all the output at once when the process finishes. Trey Jackson As doublep mentioned, there is M-x compile , and there's also just the simple M-x shell and in that shell you run

elisp conditional based on hostname

时光毁灭记忆、已成空白 提交于 2019-12-05 09:12:42
问题 I have a shared .emacs file between different Linux systems. I would like to execute an expression based on the hostname of the system I'm running: (color-theme-initialize) ;; required for Ubuntu 10.10 and above. I suppose one way to avoid checking the hostname would be to factor out the system dependencies from .emacs, but it's been convenient having .emacs in version control. Alternative suggestions are welcome. 回答1: The system-name variable might be the simplest way to achieve what you're

Set Emacs to smart auto-line after a parentheses pair?

冷暖自知 提交于 2019-12-05 08:53:40
I have electric-pair-mode on (which isn't really particularly relevant, as this could apply to any auto-pairing mode or even manual parens), but in a nutshell, I'd like it so that in the case I have: function foo() {|} (where | is the mark) If I press enter, I would like to have it automatically go to function foo() { | } It would also mean that function foo(|) {} would become function foo( | ){} I already have things to take care of the indentation, but I'm not sure how to say "if I'm inside any empty pair of matched parenthesis, when I press return, actually insert two new lines and put me

Change Emacs Mode-Line color based on major-mode

旧城冷巷雨未停 提交于 2019-12-05 06:39:35
I like to see if there is a way to change the mode-link foreground and background color base on the major-mode, I was thinking to add the logic in the (add-hook 'after-change-major-mode-hook But, I do not have all the emacs lisp experience to make such change. Here is the logic: switch major-mode: case "emacs-lisp-mode": (set-face-foreground 'mode-line "ivory") (set-face-background 'mode-line "DarkOrange2") case "ruby-mode": (set-face-foreground 'mode-line "white") (set-face-background 'mode-line "red") ... default: (set-face-foreground 'mode-line "black") (set-face-background 'mode-line