elisp

How can you write multiple statements in elisp 'if' statement?

我是研究僧i 提交于 2019-12-02 15:21:43
In elisp, there is an 'if' case where I would like to perform many different things: (if condition (do-something) (do-something-else) ...) However, (do-something-else) is executed in the else-case only. How can you specify a block of instructions to execute? For example: (if condition (begin (do-something) (do-something-else) ...)) Use progn : (if condition (progn (do-something) (do-something-else))) If there's no else required, it might be more readable to use: (when condition (do-something) (do-something-else)) And, there's the converse (unless (not condition) (do-something) (do-something

Emacs Lisp Function Guide?

非 Y 不嫁゛ 提交于 2019-12-02 15:17:46
I have been using Emacs for more than three years now but it still takes me days to write even small functions in Lisp. I've looked through GNU Emacs Lisp Reference Manual but it's huge and structured completely opposite from JavaDoc, not from functions to descriptions but the other way around. What will make my life much easier is some sort of small JavaDoc like document with most commonly used Emacs internal functions and they quick description. (point) - returns current position in buffer (save-excursion (p)) - saves current position in buffer before executing (p) and restores it afterward.

The difference between setq and setq-default in Emacs Lisp

本小妞迷上赌 提交于 2019-12-02 14:35:09
I have a question about Emacs Lisp. What is the difference between setq and setq-default ? I am very confused about it. Tutorials say setq takes effect in the local buffer while setq-default affects all buffers. For example, if I wrote (setq a-var a-vars-value) in init.el , I found after starting Emacs and opening a new buffer, the a-var is also there and its value is a-vars-value . I thought it was not supposed to be there. It seems there is no difference between setq and setq-default . Is there something wrong with my understanding? Thank you very much. For example: 1) I wrote (setq hello

Useful keyboard shortcuts and tips for ESS/R

让人想犯罪 __ 提交于 2019-12-02 14:10:48
I would like to ask regular ESS/R users what key bindings do they use frequently and tips on using ESS/R. I have set several shortcuts in my .emacs file. The most useful are: C-tab to switch between the R command line and the file (similar to josh answer, but much faster): (global-set-key [C-tab] 'other-window) Control and up/down arrow keys to search history with matching what you've already typed: (define-key comint-mode-map [C-up] 'comint-previous-matching-input-from-input) (define-key comint-mode-map [C-down] 'comint-next-matching-input-from-input) Comment-uncomment a selected region with

How do I byte-compile everything in my .emacs.d directory?

非 Y 不嫁゛ 提交于 2019-12-02 13:47:43
I have decided to check out Emacs, and I liked it very much. Now, I'm using the Emacs Starter Kit , which sort of provides better defaults and some nice customizations to default install of Emacs. I have customized it a little, added some stuff like yasnippet , color-themes , unbound , and other stuff. I've set up a github repository where I keep all of the customizations so I can access them from multiple places or in case something goes bad and I lose my .emacs.d directory. All of this is very nice, but there is a problem: Emacs takes about 1-2 seconds to load. AFAIK I can compile individual

What is the purpose of off-loading definitions with autoload in emacs? Why not autoloading is slow?

佐手、 提交于 2019-12-02 13:41:41
In ELisp, you can skip the evaluation of a definition with the autoload cookie. The definition is evaluated only once it's used. ;; File foo.el ;;;###autoload (defun foo () "Doc" 42) (defun bar () "Doc" 43) So, if I understand correctly the autoload functionnality is a hack to load file faster. But when I load foo.el , in order to skip the definition of foo the interpreter still has to read the whole form. I don't understand why it's faster. The simplest way to load the content of the file foo.el is to do a load . However, this is costly because you have to read the whole file. With autoload

multi-term: Understanding keyboard bindings

与世无争的帅哥 提交于 2019-12-02 09:49:27
问题 I am a bit confused by the difference between these two lists in multi-term (by the way where is the official repository hosted?) term-bind-key-alist term-unbind-key-list In my head, there should be two things: The keystrokes that we want Emacs to capture itself and to interpret in a specific way (by binding them to commands) The strokes that Emacs sends directly to the shell ("as is"). How exactly do term-unbind-key-list and term-bind-key-alist define these lists and bindings? Also, does

face font in c-mode when adding new keyword

不羁岁月 提交于 2019-12-02 09:26:25
I am trying to customize some added words to be colored differently from the default face-font colors. This is what I am doing: (defconst lconfig-font-lock-faces (list '(font-lock-function-name-face ((((class color)) (:foreground "DarkBlue" :bold t)))) '(font-lock-constant-face ((((class color)) (:foreground "Black" :bold t)))) '(font-lock-builtin-face ((((class color)) (:foreground nil)))) '(font-lock-preprocessor-face ((((class color)) (:foreground nil)))) ) ) (autoload 'custom-set-faces "font-lock" "Set the color scheme" t) (autoload 'font-lock-fontify-buffer "font-lock" "Fontify Buffer" t)

Elisp interactive function name

筅森魡賤 提交于 2019-12-02 08:54:34
问题 I'm trying to use the interactive function name feature. On emacs lisp manual it says: ‘a’ A function name (i.e., a symbol satisfying fboundp). Existing, Completion, Prompt. So I tried it with a small test code: (defun testfun1 () (message "hello, world!")) (defun test (abcd) (interactive "aTheme name: ") (abcd)) Emacs gives an error saying, test: Symbol's function definition is void: abcd I tried to test abcd with fboundp, it returns t. So I'm quite confused about how to use the 'a' option

Emacs Key Binding Precedence

ぐ巨炮叔叔 提交于 2019-12-02 07:56:02
I'm frustrated with the default behavior of autocomplete overriding key bindings used by yasnippets . Is there a way to set a precedence so that tab will try to expand a snippet before trying to autocomplete the word? Quick disclosure: I'm using evil-mode. If they're both minor modes, then precedence is determined by the order of elements in minor-mode-map-alist which, unless explicitly manipulated, is simply determined by the order in which the libraries were loaded. Ensure that autocomplete is loaded before yasnippet , and yasnippet's minor mode map would have precedence. You could also use