Category:Emacs Lisp

From Rosetta Code
(Redirected from Elisp)
Emacs Lisp
This programming language may be used to instruct a computer to perform a task.
Execution method: Compiled (bytecode)
See Also:

Listed below are all of the tasks on Rosetta Code which have been solved using Emacs Lisp.
Emacs Lisp is an implementation of Lisp. Other implementations of Lisp.

Emacs Lisp (often abbreviated to elisp) is the Lisp implementation used by the Emacs text editor. It doesn't provide all features of Common Lisp (e.g. its optional arguments always default to nil), but it contains special types which are specific for the use in the editor, like buffers (which is where you actually edit the text), windows, events etc.

Lisp expressions can be executed directly from within Emacs editor buffers, or loaded from files which optionally can be compiled into bytecode.

Emacs configuration files actually are Emacs Lisp source files.

Emacs Lisp can be used as a general programming language with the emacs "-batch" or "--script" command line arguments. [1]

How to run Emacs Lisp code

A simple way to run Emacs code is to switch to the scratch buffer (Buffers -> *scratch*), type in or paste some Lisp code, e.g.:

(+ 1 2 3)

Then (with the cursor behind the closing parenthesis of the Lisp form) press Control-J to evaluate it.[2] The result appears directly below the evaluated code:

(+ 1 2 3)<Ctrl-J>

Of course you can also change your code and evaluate it again. To evaluate all code in the current buffer, use "M-x eval-buffer".

Emacs will highlight matching parentheses.

If your code has an error and the debugger window appears, it can be dismissed by placing the cursor in it and then File -> Close like any other buffer.

Customizing Emacs

Lisp code can be added to the user's ~/.emacs file, which is evaluated at startup.

"M-x (=Alt-x) customize" will bring up a menu for customizing default Emacs settings, which will be added to the ~/.emacs file in its Custom section: "Faces -> Basic Faces -> Region" in that menu for example sets the background color of selections. It is a good idea to change this, e.g. to "LightSteelBlue1", because the default setting is a very light gray that is hard to see.

Another useful setting is enabling "Emacs -> Convenience -> Cua -> Cua mode" for the standard Ctrl-X/C/V/Z key bindings that are known from most other applications.

There are also color themes for Emacs, e.g. if you prefer dark mode.

You can also set a different font for Emacs:[3] Evaluate "(font-family-list)" in the scratch buffer. (This may cause some slowness of the editor if you have many fonts installed.) Then search backwards (Ctrl-r) for the font you want, to see its exact name. And finally put the font name and size into your ~/.emacs and restart Emacs, e.g.:

(set-frame-font "Courier Prime-20" nil t)

And finally, if you would like to suppress the welcome screen, put this in your .emacs:

(setq inhibit-startup-screen t)

External links


This category has the following 3 subcategories, out of 3 total.

Pages in category "Emacs Lisp"

The following 189 pages are in this category, out of 189 total.