elisp

Mapping Caps Lock to Control from within Emacs on Windows

天大地大妈咪最大 提交于 2019-11-30 14:57:07
问题 When reading either of these questions or the EmacsWiki article about mapping Caps Lock to Control in emacs in Windows, the best answers seem to involve the registry. My question is what a user can do when they can't modify the registry of the machine because they don't have admin rights. Is there a way to do the mapping from within emacs? This article comes oh-so-close, even saying, "As people have mentioned, you can of course map Caps-Lock to other keys instead, for example the Control key.

Emacs font lock mode: provide a custom color instead of a face

99封情书 提交于 2019-11-30 13:51:06
On this page discussing font lock mode , an example is provided which highlights a custom pattern: (add-hook 'c-mode-hook (lambda () (font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t))))) Is there a way to provide a custom color instead of font-lock-warning-face and without defining a new custom face. I want to be able to write something like: (font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 "Blue" t))) or an RGB color definition: (font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 "#F0F0F0" t))) Using the double quotes doesn't work. Do you know what will make it

Killing buffers whose names start with a particular string

风格不统一 提交于 2019-11-30 13:48:25
问题 Here's my problem: I use Emacs and get lots of buffers that are pretty useless all the time, like *Messages* or *Completions*. I want to bind \C-y to close all buffers that start with * except for *shell* (and *shell* < k >) buffers. To do that, I'd like to add some Emacs-Lisp in my .emacs file: (defun string-prefix s1 s2 (if (> (string-length s1) (string-length s2)) nil (string=? s1 (substring s2 0 (string-length s1))) )) (defun curry2 (lambda (f) (lambda (x) (lambda (y) (f x y) )))) (defun

In Elisp, how to get path string with slash properly inserted?

*爱你&永不变心* 提交于 2019-11-30 13:08:35
I am manually constructing path strings in Elisp by concatenating partial paths and directory names. Unfortunately sometimes the paths end with slash, sometimes not. Therefore, I need to insert slash before concatenating a directory name when necessary but not otherwise. What's a good way to do this? (file-name-as-directory dir) will return directory path dir with a trailing slash, adding one if necessary, and not otherwise. If you had your sequence of partial paths in a list, you could do something like: (let ((directory-list '("/foo" "bar/" "p/q/" "x/y")) (file-name "some_file.el")) (concat

How to change emacs config in Lisp In A Box

北慕城南 提交于 2019-11-30 13:07:42
I have been a programmer for a decade now, but I believe this is the first time I've ever asked a question on a forum. I just can't figure this out and can't find the answer already online. I am trying to turn on CUA mode so that emacs is more bearable for a windows user (normal copy paste functions). I am running Windows 7 and installed emacs through the Lisp In A Box package. I understand that I need to add a line to my .emacs file or init.el file. I'm not sure which, but I can't find either in my Lip In A Box install directory. The emacs package install also did not come with any tutorials

Mapping Caps Lock to Control from within Emacs on Windows

一个人想着一个人 提交于 2019-11-30 12:57:00
When reading either of these questions or the EmacsWiki article about mapping Caps Lock to Control in emacs in Windows, the best answers seem to involve the registry. My question is what a user can do when they can't modify the registry of the machine because they don't have admin rights. Is there a way to do the mapping from within emacs? This article comes oh-so-close, even saying, "As people have mentioned, you can of course map Caps-Lock to other keys instead, for example the Control key." But I can't figure out how to represent the control key (using various references that look pretty

Maximizing / restoring a window in emacs

时光毁灭记忆、已成空白 提交于 2019-11-30 12:49:30
问题 Ok, so maybe this is more a question for the superuser site but I figured there'd be a hell of a lot more emacs users on stackoverflow. Basically I often have my emacs split into about 4 windows so I can look at a bunch of buffers at the same time.. however I'd like to be able to C-x 1 (make the window the same size as emacs) and then somehow restore back to my nice 4 window layout I was just looking at. Is there an easy way to do this or do I need some elisp / lisp (note: I don't know ANY

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

╄→гoц情女王★ 提交于 2019-11-30 12:36:27
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? Emerick Rogul 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 Reference Manual explains: This works just like write-file-functions, but it is intended for

Assign IDs to every entry in Org-mode

£可爱£侵袭症+ 提交于 2019-11-30 12:17:36
问题 Org-mode has a bundled extension called org-id, that implements global unique IDs for org-mode files. Every entry (a headline with its body) can have an ID property in its :PROPERTIES: drawer. New ID for a single entry can be assigned with a function org-id-get-create . How can I assign an ID to every entry in an org-mode file? I could use an Emacs method of automating this, like a macro that calls org-id-get-create for every string starting with * . But I'd like to know if org-mode already

Let Emacs move the cursor off-screen

巧了我就是萌 提交于 2019-11-30 11:12:11
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 scrolling functions from acting on the secondary cursors). Is it maybe possible to use multiple-cursors to