elisp

What does “s-[keyname]” refer to in Emacs, and how do I tell Emacs to ignore it?

随声附和 提交于 2019-12-03 01:22:23
Background information: I'm on a Mac, and I've just upgraded to Emacs 23.1 via http://emacsformacosx.com/ . There are a few issues, notably the lack of full screen ability. I've attempted to get around this last issue by installing Megazoomer , which adds a global input manager bound to Cmd-return . This causes the currently forward application to maximise. However, Emacs reports that <s-return> is undefined . I've never seen an s-[key] mentioned before, and Google isn't forthcoming with an answer. So, two parts: What does s-[key] mean? This is purely for my satisfaction; and Can I tell Emacs

Emacs Per File Customization

冷暖自知 提交于 2019-12-03 00:42:13
I have an Emacs Lisp file with custom macros I want fontified and indented differently. The code looks like: (defmacro* when-let ((var value) &rest body) `(let ((,var ,value)) (when ,var ,@body))) (defun func () (when-let (a 1) a)) I want when-let fontified as a font-lock-keyword and indented as above. I know I can do this in my .emacs file but I'd prefer to make it a directory local or file local customization. The problem is that directory local and file local customizations seem to be limited to setting variables. In my .emacs file I have the following. (add-hook 'emacs-lisp-mode-hook

Create aliases in emacs?

本秂侑毒 提交于 2019-12-03 00:18:59
I have a copy of emacs that I use on a couple of different (windows) computers from a thumb drive, and I am wondering if it is possible to create something that is sort of the equivalent of a bash alias or symlink within emacs? Something that I could use within find-file is the main thing that i'm looking for, so for example: C-f <some link> would take me somewhere. Currently I have to add a new defun every time i get to a new computer, which is just kind of a pain and I would swear i've seen this somewhere, but months of googling have turned up nothing. What i've got right now is something

Emacs lisp “shell-command-on-region”

感情迁移 提交于 2019-12-03 00:10:19
In GNU Emacs, I want to run a program, figlet, on the currently selected text. I then want to comment the region which is produced. I have figured out how to do it using the standard Emacs commands: set mark with C-<space> at the start of the word move cursor to the end of the word C-u M-x shell-command-on-region RET figlet RET M-x comment-region RET However, I have failed to work out how to write an Emacs lisp program to do all this. Here is my attempt: (defun figlet-region () (interactive) (push-mark) (shell-command-on-region "figlet") (comment-region (mark) (point)) (pop-mark) ) (global-set

Is it possible to tell emacs on Windows to use the IE http proxy settings?

家住魔仙堡 提交于 2019-12-02 23:37:47
See also: Emacs behind HTTP proxy Is it possible to tell emacs to automatically use whatever proxy settings are in use by IE? The url.el package says I can explicitly specify a proxy like this: (setq url-using-proxy t) (setq url-proxy-services '(("http" . "proxyserver:3128"))) Is it possible for this to happen sort of auto-magically, when I change the IE proxy settings? Yes, it's possible. The basic idea is to define before-advice for the URL functions, and set those variables to appropriate values. This requires being able to retrieve the IE proxy settings from Windows, from within elisp. The

Elisp: How to save data in a file?

一笑奈何 提交于 2019-12-02 23:07:27
I want to save data to a file in my elisp program. I have a multi-dimensional list that I want to save to a file, so I can restore it the next time my program runs. What's the easiest / best way to do this? I realise, of course, that I can simply write my data to a buffer in a custom format and then save the buffer, but then I'd have to write a function to parse that data format when I want to restore it. I'd rather not have to do that. In Python, there's the Pickle module that lets you "dump" objects to disk and restore them, very easily. Is there something similar for elisp? This ' dump-vars

Walk up the directory tree

余生长醉 提交于 2019-12-02 22:27:08
The file tree is as follwing: - foo - lorem - ipsum <- - baz <- - bar - baz The currently visited file is ipsum . Now I want to find the first baz and the directory it is in. How do I walk up the tree from ipsum in elisp? You want locate-dominating-file . (defun parent-directory (dir) (unless (equal "/" dir) (file-name-directory (directory-file-name dir)))) (defun find-file-in-heirarchy (current-dir fname) "Search for a file named FNAME upwards through the directory hierarchy, starting from CURRENT-DIR" (let ((file (concat current-dir fname)) (parent (parent-directory (expand-file-name current

Difference between symbol and variable name in emacs lisp

孤者浪人 提交于 2019-12-02 21:04:30
I'm wondering what the difference is between (add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init)) and (add-to-list flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init)) What is the clear meaning of the apostrophe here? The apostrophe is a quote, which tells the interpreter to not parse the following expression (the symbol name). Thus, 'add-to-list gets the symbol which contains the list value that is intended to be evaluated. To learn more about symbols, read the Symbol documentation (specifically, Symbol Components symbols have names, values, function

Elisp List Contains a Value

谁说胖子不能爱 提交于 2019-12-02 20:09:23
How do you check, in elisp, if a list contains a value? so the following would return t: (contains 3 '(1 2 3)) but (contains 5 '(1 2 3)) would return nil. freiksenet The function you need is member For example: (member 3 '(1 2 3)) It will return the tail of list whose car is element . While this is not strictly t , any non-nil value is equivalent to true for a boolean operation . Also, member uses equal to test for equality, use memq for stricter equality (using eq ). Mirzhan Irkegulov freiksenet's answer is good and idiomatic. If you are using dash.el , you could also call function -contains?

emacs list-buffers behavior

微笑、不失礼 提交于 2019-12-02 19:59:41
In GNU emacs, every time I hit Ctrl-x Ctrl-b to see all of my buffers, the window is split to show the buffer list, or if I have my window already split in 2 (for instance, I will have a shell running in the lower window), the buffer list appears in the other window. My desired behavior is for the buffer list to appear in my active window so that I can select the buffer I want and continue to working in the same window, rather than having to Ctrl-x Ctrl-o to the other buffer, selecting the buffer (with enter ) and editing that buffer in the other window... I've googled for it but it doesn't