elisp

How to automatically save files on lose focus in Emacs

百般思念 提交于 2019-11-27 02:35:51
问题 Is it possible to configure Emacs, so that it saves all files when the emacs window loses focus? 回答1: I use this, it will only work if emacs is running under X (like it probably would in something like ubuntu). (when (and (featurep 'x) window-system) (defvar on-blur--saved-window-id 0 "Last known focused window.") (defvar on-blur--timer nil "Timer refreshing known focused window.") (defun on-blur--refresh () "Runs on-blur-hook if emacs has lost focus." (let* ((active-window (x-window-property

Emacs: highlighting TODO *only* in comments

南楼画角 提交于 2019-11-27 01:22:22
问题 This question is related to another one, Emacs :TODO indicator at left side. I recently came across a minor mode I like a lot called FixmeMode. It supports auto highlighting of TODO marks, and navigating between them. However, I think it makes more sense to recognize the "TODO" strings only in comments, rather than polluting the whole file. Is it possible? 回答1: Check out the library fic-mode.el, it has been verified in C++ and Emacs-Lisp. It was written specifically to answer this question.

emacs/elisp: What is the hash (pound, number sign, octothorp) symbol used for?

不问归期 提交于 2019-11-27 00:09:23
问题 What does this do? (add-hook 'compilation-mode-hook #'my-setup-compile-mode) ...and is it different than (add-hook 'compilation-mode-hook 'my-setup-compile-mode) 回答1: There is no difference: (eq 'my-add #'my-add) yields t The # can be used in front of a lambda expression indicating to the byte-compiler that the following expression can be byte compiled, see the docs for Anonymous Functions. But there's nothing to compile in the case of a symbol. In general, it is used in the printed

Alternative to forward-word / backward-word to include symbols — e.g., ***

我是研究僧i 提交于 2019-11-26 21:51:51
问题 My preferred method of indicating a location within a document that requires attention is with three asterisks *** . When it comes time to select the region containing the three asterisks using shift+right-word or shift+left-word , those functions skip over the three asterisks and move along to the next word. When I peeked inside bindings.el , I saw that left-word and right-word are adaptations of forward-word and backward-word , that are traceable to built-in functions in the C source code.

What's in your .emacs?

帅比萌擦擦* 提交于 2019-11-26 21:14:09
I've switched computers a few times recently, and somewhere along the way I lost my .emacs. I'm trying to build it up again, but while I'm at it, I thought I'd pick up other good configurations that other people use. So, if you use Emacs, what's in your .emacs? Mine is pretty barren right now, containing only: Global font-lock-mode! (global-font-lock-mode 1) My personal preferences with respect to indentation, tabs, and spaces. Use cperl-mode instead of perl-mode. A shortcut for compilation. What do you think is useful? Use the ultimate dotfiles site . Add your '.emacs' here. Read the '.emacs'

Emacs Lisp: evaluate variable in alist

不问归期 提交于 2019-11-26 19:36:37
问题 This is probably silly but I don't have enough Elisp knowledge to understand what is going on with respect to quoting and evaluation. Suppose I have this Elisp code: (add-to-list 'default-frame-alist '(width . 100)) (add-to-list 'default-frame-alist '(height . 50)) It will result in the expected default-frame-alist value: ((height 50) (width 100)) But now if I have this: (setq my-frame-width 100) (setq my-frame-height 50) (add-to-list 'default-frame-alist '(width . my-frame-width)) (add-to

Emacs: How to use a major mode for non-standard file extension

心已入冬 提交于 2019-11-26 18:35:55
问题 I'd like to use R major mode for another file extension in emacs (for an unsupported language with syntax similar to R). How do I force emacs to change the major mode for a buffer I'm editing? How do I change my .emacs to permanently associate a major mode with a particular file extension? 回答1: This should work: (add-to-list 'auto-mode-alist '("\\.rr" . R-mode)) 来源: https://stackoverflow.com/questions/21661413/emacs-how-to-use-a-major-mode-for-non-standard-file-extension

Idiomatic batch processing of text in Emacs?

╄→гoц情女王★ 提交于 2019-11-26 18:14:07
问题 In Python, you might do something like fout = open('out','w') fin = open('in') for line in fin: fout.write(process(line)+"\n") fin.close() fout.close() (I think it would be similar in many other languages as well). In Emacs Lisp, would you do something like (find-file 'out') (setq fout (current-buffer) (find-file 'in') (setq fin (current-buffer) (while moreLines (setq begin (point)) (move-end-of-line 1) (setq line (buffer-substring-no-properties begin (point)) ;; maybe (print (process line)

Emacs — How to create a vertical strike-through effect

杀马特。学长 韩版系。学妹 提交于 2019-11-26 16:38:21
问题 I'm looking for some suggestions, please, of how to create the visual effect of a vertical strike-through (with the character on top of the vertical bar ("\u007C") still being visible). If layering is possible, then the vertical bar should be underneath so that the letter is mostly visible. I searched for a method of superimposing characters, layering overlays, and I looked at some xpm images, however, I have not found anything remotely close to what I'm looking for. The goal is to have a

How to keep dir-local variables when switching major modes?

隐身守侯 提交于 2019-11-26 16:37:58
问题 I'm committing to a project where standard indentations and tabs are 3-chars wide, and it's using a mix of HTML, PHP, and JavaScript. Since I use Emacs for everything, and only want the 3-char indentation for this project, I set up a ".dir-locals.el" file at the root of the project to apply to all files/all modes under it: ; Match projets's default indent of 3 spaces per level- and don't add tabs ( (nil . ( (tab-width . 3) (c-basic-offset . 3) (indent-tabs-mode . nil) )) ) Which works fine