Category:Emacs Lisp
This programming language may be used to instruct a computer to perform a task.
Execution method: | Compiled (bytecode) |
---|---|
See Also: |
|
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> 6
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
Subcategories
This category has the following 3 subcategories, out of 3 total.
@
- Emacs Lisp Implementations (empty)
- Emacs Lisp User (31 P)
Pages in category "Emacs Lisp"
The following 198 pages are in this category, out of 198 total.
A
B
C
- Calculating the value of e
- Chaos game
- Character codes
- Check that file exists
- Closures/Value capture
- Combinations
- Command-line arguments
- Comments
- Compare length of two strings
- Compiler/lexical analyzer
- Conway's Game of Life
- Copy a string
- Count in octal
- Count occurrences of a substring
- Create a file
- Cumulative standard deviation
D
E
F
- Factorial
- Fibonacci sequence
- File input/output
- File modification time
- File size
- Filter
- Find limit of recursion
- Find palindromic numbers in both binary and ternary bases
- Find the intersection of two lines
- Find the last Sunday of each month
- FizzBuzz
- Flatten a list
- Forest fire
- Formatted numeric output
- Function composition
- Function definition
G
H
I
L
M
P
R
S
- Search a list
- Secure temporary file
- Send email
- SHA-1
- SHA-256
- Shell one-liner
- Sieve of Eratosthenes
- Simple database
- Sine wave
- Sleep
- Snake
- Sockets
- Sorting algorithms/Insertion sort
- Sorting algorithms/Quicksort
- Sorting algorithms/Sleep sort
- Soundex
- Spinning rod animation/Text
- String append
- String concatenation
- String interpolation (included)
- String length
- String matching
- String prepend
- Strip a set of characters from a string
- Strip whitespace from a string/Top and tail
- Substitution cipher
- Substring/Top and tail
- Sum and product of an array
- Sum digits of an integer
- Sum multiples of 3 and 5
- Sum of a series
- Sum of squares
- System time