How do I do closures in Emacs Lisp?
Found another solution with lexical-let (defun foo (n) (lexical-let ((n n)) #'(lambda() n))) (funcall (foo 10)) ;; => 10
Found another solution with lexical-let (defun foo (n) (lexical-let ((n n)) #'(lambda() n))) (funcall (foo 10)) ;; => 10
I found this solution on the EmacsWiki: The problem is the ownership of the directory ~/.emacs.d/server when you also have “Administrators” rights on your account. Create the directory ~/.emacs.d/server and set the owner of this directory to your login name and the problem is gone. As I have a “Dutch” version of Windows 7 I … Read more
If you actually want batch processing of stdin and sending the result to stdout, you can use the –script command line option to Emacs, which will enable you to write code that reads from stdin and writes to stdout and stderr. Here is an example program which is like cat, except that it reverses each … Read more
As per comments to Aaron Miller’s answer, here is an overview of what happens when a mode function is called (with an explanation of derived modes); how calling a mode manually differs from Emacs calling it automatically; and where after-change-major-mode-hook and hack-local-variables fit into this, in the context of the following suggested code: (add-hook ‘after-change-major-mode-hook … Read more
Many unix variants only allow a single argument to the program on the shebang line. Sad, but true. If you use #!/usr/bin/env emacs so as not to depend on the location of the emacs executable, you can’t pass an argument at all. Chaining scripts is a possibility on some systems, but that too is not … Read more
function (aka #’) is used to quote functions, whereas quote (aka ‘) is used to quote data. Now, in Emacs-Lisp a symbol whose function cell is a function is itself a function, so #’symbol is just the same as ‘symbol in practice (tho the intention is different, the first making it clear that one is … Read more
Folding is generally unnecessary with emacs, as it has tools that explicitly implement the actions people do manually when folding code. Most people have good success with simple incremental searches. See “foo” mentioned somewhere? Type C-sfoo, find the definition, press enter, read it, and then press C-x C-x to go back to where you were. … Read more
Use the ultimate dotfiles site. Add your ‘.emacs’ here. Read the ‘.emacs’ of others.
Take note of the cygwin-related information on the emacs wiki: http://www.emacswiki.org/emacs/TrampMode I don’t use EmacsW32, but I do successfully use TRAMP over ssh with Cygwin and NT Emacs. I never got TRAMP working without an ssh agent (i.e. prompting for credentials) — as you noticed, it just hangs — but it works fine with one, … Read more
Code wrapped in eval-after-load will be executed only once, so it is typically used to perform one-time setup such as setting default global values and behaviour. An example might be setting up a default keymap for a particular mode. In eval-after-load code, there’s no notion of the “current buffer”. Mode hooks execute once for every … Read more