elisp

Inconsistent M-x align-regexp vs. C-u M-x align-regexp behaviour

半世苍凉 提交于 2019-12-18 17:06:43
问题 I've tried to write some new align rules for emacs and found this strange and inconsistent behaviour. Current buffer contents: "some thing" like => this hello => world and => again After typing M-x align-regexp RET [[:lower:]]+\(\s-+\)=> RET result looks as desired: "some thing" like => this hello => world and => again But after C-u M-x align-regexp RET [[:lower:]]+\(\s-+\)=> RET 1 RET 1 RET y RET I get this instead: "some thing" like => this hello => world and => again The same (wrong) thing

emacs: is before-save-hook a local variable?

半腔热情 提交于 2019-12-18 15:35:39
问题 how would I figure this out? I added delete-trailing-whitespace to the before-save-hook in my c-mode-common-hook , but it looks like delete-trailing-whitespace is getting called for every file, not just buffers using c-mode and derivatives. Can I make the before-save-hook buffer local? 回答1: Add it to write-contents-functions instead: (add-hook 'c-mode-common-hook (lambda() (add-hook 'write-contents-functions (lambda() (save-excursion (delete-trailing-whitespace))) nil t))) As the Emacs Lisp

Let Emacs move the cursor off-screen

荒凉一梦 提交于 2019-12-18 14:17:21
问题 Is it possible to let Emacs have the cursor be moved off-screen, like most GUI text editors work? This is one of the biggest things that bothers me when I use Emacs over any GUI editor. When I scroll down, the cursor is "pushed forward" by the top of the buffer. I had previously thought that this was completely impossible, because this is hard-wired into the architecture of Emacs, but then I saw multiple-cursors, which does exactly this for the secondary cursors (assuming you prevent the

Code folding for LaTeX in Emacs

≡放荡痞女 提交于 2019-12-18 12:57:10
问题 Is there an Emacs minor-mode (or piece of elisp code) that lets you selectively hide/show environments while in LaTeX mode? For instance, I would like to move to the beginning of a long \begin{figure} block, hit a keystroke, and have the contents of that figure environment hidden from view. Similarly with \begin{proof} and so on, and ideally even with \subsection s. Is this possible? I just tried hs-minor-mode , allout-mode , and outline-minor-mode , but most of them don't recognize LaTeX's

Relationship between Emacs functions and commands

半腔热情 提交于 2019-12-18 12:56:14
问题 From what I understand, in Emacs I can run commands such as M-x (which by the way I believe stands for execute-extended-command ). This command M-x itself is used to run things like customize_face e.g. by typing M-x customize-face in the minibuffer. My questions are: Q.1. Is customize-face a command ? or is it a function ? And do we say that customize-face is passed to the command M-x as an argument ? Q.2 Do all Emacs commands have an associated Emacs function ? (i.e. when I enter M-x

In Lisp (Clojure, Emacs Lisp), what is the difference between list and quote?

烈酒焚心 提交于 2019-12-18 12:07:32
问题 From reading introductory material on Lisp, I now consider the following to be identical: (list 1 2 3) '(1 2 3) However, judging from problems I face when using the quoted form in both Clojure and Emacs Lisp, they are not the same. Can you tell me what the difference is? 回答1: The primary difference is that quote prevents evaluation of the elements, whereas list does not: user=> '(1 2 (+ 1 2)) (1 2 (+ 1 2)) user=> (list 1 2 (+ 1 2)) (1 2 3) For this reason (among others), it is idiomatic

Emacs: same buffer, two windows, one narrowed, one not

旧城冷巷雨未停 提交于 2019-12-18 11:41:22
问题 I find the narrow-to-region command useful, however it applies to the buffer and not to the current window. I'd like to have one window display a narrowed version of the buffer, while the buffer is displayed widened if it occurs in any other window. Is this possible? 回答1: Try M-x clone-indirect-buffer or C-x 4 c . For details, see Indirect Buffers. 来源: https://stackoverflow.com/questions/2387287/emacs-same-buffer-two-windows-one-narrowed-one-not

How to periodically run a task within emacs?

无人久伴 提交于 2019-12-18 11:20:32
问题 Is there a way to periodically run an elisp function in a long-running emacs, similar to cron, but within the emacs process? For example I want to "automatically run (recentf-save-list) every half hour" because it otherwise only runs on exit, which sucks when emacs occasionally crashes. (There are other examples as well so looking for a general solution rather than one in particular for recentf). 回答1: Check out run-with-timer. (run-with-timer 0 (* 30 60) 'recentf-save-list) 回答2: You might

Show Keys In Emacs Keymap Value

雨燕双飞 提交于 2019-12-18 10:35:06
问题 When I query the current value of the keymap, eg with M-: (current-local-map) , it shows me something along these lines: Value: (keymap (S-mouse-2 . muse-follow-name-at-mouse-other-window) (mouse-2 . muse-follow-name-at-mouse) (33554445 . muse-follow-name-at-point-other-window) (S-return . muse-follow-name-at-point-other-window) (13 . muse-follow-name-at-point) (return . muse-follow-name-at-point) keymap (67108924 . muse-decrease-list-item-indentation) (67108926 . muse-increase-list-item

wrong type argument: stringp, nil

人盡茶涼 提交于 2019-12-18 10:33:58
问题 Before now I've just been cutting and pasting code into my .emacs file, but then I decided to add some maven functionality to emacs. Now, I don't see how I was able to mess this up, but last night I kept getting the error I put in the title when I run M-x jarl-mvn-exec. I slept on it, and came back the next day but I'm still not getting anywhere. (defun jarl-get-pom () (concat (locate-dominating-file (buffer-file-name (current-buffer)) "pom.xml") "pom.xml")) (defun jarl-visit-pom ()