Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Emacs Lisp
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Source code== Emacs Lisp code is stored in [[filesystem]]s as [[plain text]] files, by convention with the filename suffix "<code>.el</code>". The user's init file is an exception, often appearing as "<code>.emacs</code>" despite being evaluated as any Emacs Lisp code. Since the mid-1990s, Emacs also loads <code>~/.emacs.el</code> and <code>~/.emacs.d/init.el</code>. Additionally, users may specify any file to load as a config file on the command line, or explicitly state that no config file is to be loaded. When the files are loaded, an [[interpreter (computer software)|interpreter]] component of the Emacs program reads and parses the functions and variables, storing them in memory. They are then available to other editing functions, and to user commands. Functions and variables can be freely modified and redefined without restarting the editor or reloading the config file. In order to save time and memory space, much of the functionality of Emacs loads only when required. Each set of optional features shipped with Emacs is implemented by a collection of Emacs code called a [[package (package management system)|package]] or [[Library (computing)|library]]. For example, there is a library for highlighting keywords in program source code, and a library for playing the game of [[Tetris]]. Each library is implemented using one or more Emacs Lisp source files. Libraries can define one or more ''major modes'' to activate and control their function. Emacs developers write certain functions in C. These are ''primitives'', also termed ''built-in functions'' or ''subrs''. Although primitives can be called from Lisp code, they can only be modified by editing the C source files and recompiling. In [[GNU Emacs]], primitives are not available as external libraries; they are part of the Emacs executable. In [[XEmacs]], runtime loading of such primitives is possible, using the operating system's support for [[dynamic linking]]. Functions may be written as primitives because they need access to external data and libraries not otherwise available from Emacs Lisp, or because they are called often enough that the comparative speed of C versus Emacs Lisp makes a worthwhile difference. However, because errors in C code can easily lead to [[segmentation violation]]s or to more subtle bugs, which crash the editor, and because writing C code that interacts correctly with the Emacs Lisp [[Garbage collection (computer science)|garbage collector]] is error-prone, the number of functions implemented as primitives is kept to a necessary minimum. ===Byte code=== ''Byte-compiling'' can make Emacs Lisp code execute faster. Emacs contains a [[compiler]] which can translate Emacs Lisp source files into a special representation termed [[bytecode]]. Emacs Lisp bytecode files have the [[filename suffix]] "<code>.elc</code>". Compared to source files, bytecode files load and run faster, occupy less disk space, and use less memory when loaded. Bytecode still runs more slowly than primitives, but functions loaded as bytecode can be easily modified and re-loaded. In addition, bytecode files are platform-independent. The standard Emacs Lisp code distributed with Emacs is loaded as bytecode, although the matching source files are usually provided for the user's reference as well. User-supplied extensions are typically not byte-compiled, as they are neither as large nor as computationally intensive.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)