elisp

Emacs: Make custom scrolling function follow mouse but not change keyboard focus

无人久伴 提交于 2019-12-06 05:43:51
I have some custom scrolling functions in Emacs, which help me get around a bug where a single scroll event sends two <mouse-4> or <mouse-5> actions. I have: (setq scroll-down-this-time t) (defun my-scroll-down-line () (interactive "@") (if scroll-down-this-time (progn (scroll-down-line) (setq scroll-down-this-time nil)) (setq scroll-down-this-time t))) (setq scroll-up-this-time t) (defun my-scroll-up-line () (interactive "@") (if scroll-up-this-time (progn (scroll-up-line) (setq scroll-up-this-time nil)) (setq scroll-up-this-time t))) (global-set-key (kbd "<mouse-4>") 'my-scroll-down-line)

Emacs complaining with invalid function?

依然范特西╮ 提交于 2019-12-06 05:41:20
问题 When I press C-c c with the following code on a buffer, Emacs complains with Invalid function: (select-current-line) . Why? (defun select-current-line () "Select the current line" (interactive) (end-of-line) ; move to end of line (set-mark (line-beginning-position))) (defun my-isend () (interactive) (if (and transient-mark-mode mark-active) (isend-send) ((select-current-line) (isend-send))) ) (global-set-key (kbd "C-c c") 'my-isend) Not that it matters, but for those interested isend-send is

How to perform operations on changed lines in Emacs before-save?

依然范特西╮ 提交于 2019-12-06 05:11:25
问题 I'd like to add a before-save-hook where I can do some operations for just the lines that have changed since the last save. For e.g., remove trailing whitespace, check indentation, etc.. I don't want to do this for an entire file, and I am aware that there are individual options for each of these(just to remove trailing whitespace for all changed lines, etc..), but I'd like something generic so that I can add more stuff to it. I imagine there is something where I can either get the list of

Buffer menu to select a set of filenames in Emacs

﹥>﹥吖頭↗ 提交于 2019-12-06 05:08:21
I have a directory "a" with a set of templates, for instance $ ls a b bcc cc ccdd I would like to implement a keyboard shortcut in Emacs that will show a buffer with the template names, similar to dired or buffer-menu and then be able to select a template name by using arrow keys or mouse. Then insert the selected template into the current buffer at point. How can this be done? insert-file , bound to C-x i by default, can insert a file into your buffer at point, but it doesn't give you a nice menu. Both helm and ido enhance this behaviour. helm does not come with Emacs, but it can be installed

C Comment in Emacs - Linux Kernel Style

北慕城南 提交于 2019-12-06 04:38:47
问题 I'm using (setq-default comment-style 'multi-line) and my region comments, when doing M-; , are: /* void main() * { * int i; * int b; * printf("format string"); * } */ But I want them to look like this: /* * void main() * { * int i; * int b; * printf("format string"); * } */ What do I have to change? 回答1: Try with: (setq comment-style 'extra-line) 回答2: Complementing the anler answer and answering my own question. To use the Linux Kernel commenting Style [1] in emacs, just set this variable in

Model/View-like editing in Emacs

旧城冷巷雨未停 提交于 2019-12-06 04:32:11
问题 I have some JSON files and I'm writing a mode that allows editing a single property of the JSON object independently from the rest. For example: foo.json: { "creation_timestamp": "1411210038.000000", "description": "lorem ipsum.\ndolor sit amet.", "version": 4 } Opening foo.json results in this buffer: lorem ipsum. dolor sit amet. Changing the first line to "foo bar" and saving the file results in a foo.json with only the description field updated: { "creation_timestamp": "1411210038.000000",

How to create temporary files `.#filename` in `/tmp`, not working directory

旧城冷巷雨未停 提交于 2019-12-06 04:01:11
问题 When files are being modified in Emacs, a temporary file is created in the working directory that looks like this: .#filename . The file is deleted when the buffer is saved. I found a few of these types of temporary files in my Git remote repositories, and I thought it might be better to nip the bud at the source instead of configuring Git to ignore them for every project. How can we configure Emacs to create those files in the /tmp directory instead of the working directory? 回答1: The file at

How to distinguish between different overlays at point

為{幸葍}努か 提交于 2019-12-06 03:45:53
ORIGINAL QUESTION : I'm looking for some assistance, please, to distinguish between overlays that may exist at point. If the overlays-at point is made with the lawlist-red-face then do X . If the overlays-at point is made with calendar-holiday-marker , then do Y . The overlays are made with these two functions. (calendar-mark-visible-date (car holiday) lawlist-red-face) (calendar-mark-visible-date (car holiday) calendar-holiday-marker) EDIT (January 1, 2014): @Drew wrote a nice test for this in calendar+.el ( http://www.emacswiki.org/emacs/calendar%2B.el ): (when (memq lawlist-red-face (mapcar

Emacs: Stop popup window for gpg passphrase [closed]

情到浓时终转凉″ 提交于 2019-12-06 03:33:07
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . emacs is annoyingly popping up window and asking for pass phrase whenever I open a encrypted file (somefile.gpg, .authinfo.gpg). I would like it instead ask me for password in minibuffer. is there any configuration option for that.? Edit: Important to note, if I press escape on popup window, emacs will ask for

emacs isearch lazy highlight for whole buffer

大城市里の小女人 提交于 2019-12-06 03:18:29
the default behavior of isearch was highlighting the world that matched in current windows. how can i change that behavior, let it highlighting the world that matched in the whole current buffer. Perhaps you are looking for the highlight-* commands, to keep things highlighted throughout the buffer whilst you perform other actions? M-s h C-h lists: Global Bindings Starting With M-s h: key binding --- ------- M-s h l highlight-lines-matching-regexp M-s h p highlight-phrase M-s h r highlight-regexp M-s h u unhighlight-regexp You can also use M-s h r during an isearch to invoke highlighting for