elisp

Emacs and Long Shell Commands

牧云@^-^@ 提交于 2019-12-07 07:43:33
问题 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. 回答1: As doublep

replace-char in Emacs Lisp ?

对着背影说爱祢 提交于 2019-12-07 06:04: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? 回答1: Why not just use (replace-string "\x53979" "'") or (while (search-forward "\x53979" nil t) (replace-match "'" nil t)) as recommended in the documentation for

Change Emacs Mode-Line color based on major-mode

冷暖自知 提交于 2019-12-07 04:37:58
问题 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

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

FlySpell in Org-Mode recognize latex syntax like auctex

∥☆過路亽.° 提交于 2019-12-07 02:15:25
问题 Original Response: I was trying to figure out how in auctex mode latex doesn't seem to highlight any latex functions with flyspell turned on. Is this a custom dictionary file or how is this implemented? Can this be easily incorporated into an org-mode file so it doesn't highlight inserted latex code that will get exported. Edit: Simple example taken from top of file and in the text. Basically so latex syntax like ref or label inside {} won't be spell checked (this has been fixed by using

Emacs Lisp: getting ascii value of character

让人想犯罪 __ 提交于 2019-12-07 01:27:52
问题 I'd like to translate a character in Emacs to its numeric ascii code, similar to casting char a = 'a'; int i = (int)a in c. I've tried string-to-number and a few other functions, but none seem to make Emacs read the char as a number in the end. What's the easiest way to do this? 回答1: String is an array. (aref "foo" 0) 回答2: To get the ascii-number which represents the character --as Drew said-- put a question mark before the character and evaluate that expression ?a ==> 97 Number appears in

uses for dynamic scope?

最后都变了- 提交于 2019-12-07 00:26:17
问题 I've been getting my hands wet with emacs lisp, and one thing that trips me up sometimes is the dynamic scope. Is there much of a future for it? Most languages I know use static scoping (or have moved to static scoping, like Python), and probably because I know it better I tend to prefer it. Are there specific applications/instances or examples where dynamic scope is more useful? 回答1: There's a good discussion of this issue here. The most useful part that pertains to your question is: Dynamic

How to let Emacs display a different character from that actually stored?

天涯浪子 提交于 2019-12-06 23:48:22
问题 I want to implement dynamical text replacement (only the display is replaced, the actual stored file is not replaced) for Emacs, using Elisp. For example, in LaTeX documents, I want to type \alpha , and let Emacs display it just as α , so it is easier to read. But in the result .tex file, I still want \alpha , instead of α to be saved. (Remark: I could use XeTeX or LuaTeX myself to support UTF-8 directly. But for the reason of collaboration and journal requirements, I don't want the UTF-8

Emacs - Can't get buffer-offer-save working

﹥>﹥吖頭↗ 提交于 2019-12-06 20:05:57
问题 I would like to have Emacs ask me whether I want to save a modified buffer, when that buffer is not associated with a file. To open a new buffer (not visiting a file) I have the following function in my .emacs file: ;; Creates a new empty buffer (defun new-empty-buffer () "Opens a new empty buffer." (interactive) (let ((buf (generate-new-buffer "untitled"))) (switch-to-buffer buf) (funcall (and default-major-mode)) (setq buffer-offer-save t))) I thought setting "buffer-offer-save" to

How to call interactive Emacs Lisp function with a prefix argument, from another Emacs Lisp function?

佐手、 提交于 2019-12-06 19:04:37
问题 I want to write an Emacs Lisp function that will turn on flyspell-mode regardless of the current state of the mode. Function flyspell-mode-on is deprecated. The documentation suggests that a positive prefix argument will turn flyspell-mode , but unfortunately running (flyspell-mode 1) results in an error message: Wrong number of arguments: (lambda (flyspell-mode 1)), 0 If I could figure out how to call flyspell-mode with a prefix argument, I believe I could solve this problem. The most