Category:Emacs Lisp: Difference between revisions

(Added provided capabilities (hopefully complete))
 
(9 intermediate revisions by 3 users not shown)
Line 1:
{{language
{{language}}{{implementation|Lisp}}[[provides::Capability:Windowing UI| ]][[provides::Capability:First class functions| ]][[provides::Capability:File access| ]][[provides::Capability:File system access| ]][[provides::Capability:Database access| ]]
|exec=bytecode
{{language}}{{implementation|Lisp}}[[{{provides::Capability:|Windowing UI| ]][[}}{{provides::Capability:|First class functions| ]][[}}{{provides::Capability:|File access| ]][[}}{{provides::Capability:|File system access| ]][[}}{{provides::Capability:|Database access| ]]}}
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.
 
Line 6 ⟶ 8:
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. [http://www.emacswiki.org/emacs/CategoryBatchModeBatchMode]
 
==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.:
<pre>(+ 1 2 3)</pre>
Then (with the cursor behind the closing parenthesis of the Lisp form) press Control-J to evaluate it.[https://www.gnu.org/software/emacs/manual/html_node/efaq/Evaluating-Emacs-Lisp-code.html] The result appears directly below the evaluated code:
<pre>(+ 1 2 3)<Ctrl-J>
6</pre>
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:[https://www.reddit.com/r/emacs/comments/93htxs/setting_a_font_in_emacs/] 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.:
<pre>(set-frame-font "Courier Prime-20" nil t)</pre>
 
And finally, if you would like to suppress the welcome screen, put this in your .emacs:
<pre>(setq inhibit-startup-screen t)</pre>
 
==External links==
 
* [https://www.gnu.org/software/emacs/ GNU Emacs homepage]
Anonymous user