- 1976
- TECMAC and TMACS, a pair of “TECO-macro realtime editors.” by Guy Steele, Dave Moon, Richard Greenblatt, Charles Frankston, et al.
- 1978
- Multics Emacs by Bernie Greenberg. Written in MacLisp; also used Lisp as its extension language.
- 1981
- Gosling Emacs : by James Gosling : written in C; with “Mocklisp” as its extension language.
- 1985
- GNU Emacs 13.0? (20-mar-85) written in Spice Lisp (CMU Common Lisp) by Richard Stallman. initial public release?
- 1986
- GNU Emacs 18.24 beta (02-oct-86).
- 1992
- MULE 0.9.0b (4-mar-92) “Multilingual Enhancements to Emacs”: support for input methods and various languages including Japanese, Chinese, Korean, Greek, Hebrew, and Cyrillic.
- 1992
- Lucid Emacs 19.0 (??-apr-92) by Jamie Zawinski et al.
- 1994
- XEmacs 19.11 (13-sep-94) Lucid Emacs -> XEmacs renaming. now maintained by Chuck Thompson and Ben Wing.
- 1998
- XEmacs 20.4 (28-feb-98) first reasonably stable release with MULE support. XEmacs “core” and “packages” now packaged separately.
- 2001
- XEmacs 21.4.0 (16-apr-01) (stable / maintenance branch) Maintained by Stephen Turnbull. Shipped by Red Hat, Debian, Mandrake, etc.
- 2002
- 2002 GNU Emacs 21.2 (16-mar-02).
- 2008
- Stefan Monnier and Chong Yidong take over maintenance.
- 2014
- On November 11, 2014, development was moved to Git by ESR.
- 2015
- John Wiegley takes over maintainance.
As of early 2014, GNU Emacs has had 579 individual commiters throughout its history.
Source: https://www.jwz.org/doc/emacs-timeline.html
- `src’
- holds the C code for Emacs (the Emacs Lisp interpreter and its primitives, the redisplay code, and some basic editing functions).
- `lisp’
- holds the Emacs Lisp code for Emacs (almost everything else).
- `leim’
- holds the library of Emacs input methods, Lisp code and auxiliary data files required to type international characters which can’t be directly produced by your keyboard.
- `lib-src’
- holds the source code for some utility programs for use by or with Emacs, like movemail and etags.
- `etc’
- holds miscellaneous architecture-independent data files Emacs uses, like the tutorial text and the Zippy, the Pinhead quote database. The contents of the `lisp’, `leim’, `info’, `man’, `lispref’, and `lispintro’ subdirectories are architecture-independent too.
- `info’
- holds the Info documentation tree for Emacs.
- `doc/emacs’
- holds the source code for the Emacs Manual. If you modify the manual sources, you will need the `makeinfo’ program to produce an updated manual. `makeinfo’ is part of the GNU Texinfo package; you need version 4.6 or later of Texinfo.
- `doc/lispref’
- holds the source code for the Emacs Lisp reference manual.
- `doc/lispintro’
- holds the source code for the Introduction to Programming in Emacs Lisp manual.
- `msdos’
- holds configuration files for compiling Emacs under MS-DOS.
- `nt’
- holds various command files and documentation files that pertain to building and running Emacs on Windows 9X/ME/NT/2000/XP.
- `test’
- holds tests for various aspects of Emacs’s functionality.
- active region
- buffer
- case folding
- character
- cursor
- docstring
- echo area
- face
- filling
- fontification
- frame
- fringe
- function/command
- headline
- indent
- init file
- inserting
- kill
- kill ring
- line wrap
- local/global
- mark
- menu-bar
- minibuffer
- modeline
- narrow
- overlay properties
- point
- prefix argument
- region
- scroll-bar
- text properties
- tool-bar
- transient mark
- variable/option
- window
- yank
C-
: hold theControl
keyM-
: hold theMeta/Alt
keyDEL
: hold theBackspace
keyRET
: hold theReturn
keySPC
: hold theSpace
keyESC
: hold theEscape
keyTAB
: hold theTab
key
- C-x [character]
- mode-independent keybindings.
- C-c …
- mode-dependent keybindings.
- C-c [character]
- user-reserved keybindings.
C-y
: yankM-y
: yank-popC-w
: kill-regionM-w
: kill-ring-saveC-x C-b
: list buffersC-x b
: switch to bufferC-x f
: set fill columnC-l
: recenter-top-bottomC-o
: open-lineC-h k
: describe-keyC-h v
: describe-variableC-h f
: describe-functionM-=
: count-words-regionM-c
: capitalize-wordC-x l
: count-lines-pageC-x r m
: bookmark-setC-x r s
: copy-to-registerC-x r SPC
: point-to-registerC-x r w
: window-configuration-to-registerC-x r l
: bookmark-bmenu-listC-x r i
: insert-registerC-x r j
: jump-toC-u C-x =
: what-cursor-positionC-x 2
: split-window-belowC-h i
: info
C-x C-f
: find file in the current bufferC-x C-s
: save current buffer, possibly in a fileC-x s
: save all buffersC-x C-b
: list buffersC-x b
: find a buffer or create a new oneC-x d
: dired
C-a/e
: move to the beginning/end of lineC-f/b
: move one character forward/backwardM-a/e
: move to the beginning/end of sentenceM-f/b
: move one word forward/backwardC-a
: beginning-of-lineC-e
: end-of-lineM-<
: beginning-of-bufferM->
: end-of-bufferM-{
: backward-paragraphM-}
: forward-paragraphC-<up/down>
: move one paragraph up/downC-<left/right>
: move one character left/right
See sentence end definition: C-h v sentence-end TAB
- bookmark
- calendar
- calc
- dired (and dired-x)
- doc-view
- electric-indent-mode
- electric-pair-mode
- global-font-lock-mode
- epa-mode
- erc
- gnus
- linum-mode
- org-mode
- register
- info
C-x (
: start defining a macroC-x )
: stop defining a macroC-x e
: call the last defined macroC-x C-k C-i
: to create a counter and insert its valueC-x C-k b
: bind the macro to a keyC-x C-k RET
: edit last macro in a bufferC-x C-k n
: name the last macro
Example : C-x ( aaa C-x C-k C-i C-x )
C-d
: delete-charM-d
: kill-word (notice kill != delete)C-k
: kill-line (see kill-whole-line)M-k
: kill-sentence
See also:
- kill-whole-line (option)
- kill-read-only-ok (option)
- copy-region-as-kill (command)
- copy-rectangle-as-kill (command)
- copy-line (command)
- open-line (command)
Go to the main Info buffer with C-h i
. Hit d
to make sure you are
at the top-level of the Info documentation, and go at the beginning of
the buffer with M-<
.
Perform an incremental search for “lisp” with C-s lisp
.
Hit RET
to deactivate the search and the highlighting of search
matches.
Hit C-s C-s
to search for the last search string again.
Hit M-e
to edit the search string (change it to “mode”) and RET
to
go back to the search mode.
Hit M-p
to browse the search history and RET to search the selected
string again.
Go back to the beginning of buffer with M-<
.
Hit C-s
to start the search.
Hit C-q C-j
to search for the newline character.
Hit C-g
to abort the search.
Hit C-s
and search for Mail
: notice only Mail
will be matched,
not mail
.
Hit C-s
and M-c
to toggle case folding.
Hit C-s
and M-s SPC
to toggle “match spaces loosely” : when
matching spaces loosely, you can search for a string like “mail
client” and still match the “mail client” string.
Try searching for maii
instead of mail
and then hit DEL
to edit
the search string by deleting the last character.
Hit C-s
and search for mail
. Hit RET on the first occurrence and
go one word backward with M-b
. Now hit C-s C-w
to search for the
word at point. Try again with C-s C-w C-w
to search for several
words at point.
Hit C-s C-M-y
to search for the character at point. Hit C-M-y
C-M-y
to add the next two characters to the search. Hit C-M-w
to
remove the last character from the search string.
Hit C-s
to start the search. Hit M-b
directly, without hitting
RET
. Hit C-SPC M-f M-w
to copy the word at point. Go back to the
beginning of the word and hit M-d
to do the same: since the buffer
is read-only, you can copy the word at point directly like this.
Now hit C-s
again, they C-y
to “yank” the text in the search area.
Hit C-s C-M-i
to complete over previous searches.
In a folded org-mode buffer, search for some invisible text: the matched string is automatically unfolded when the point moves to it.
Now go back to the folded mode and hit C-s M-s i
to search for
visible text only. Invisible text won’t be matched.
Hit M-<
and C-s
search for mail
. Now hit M-s o
to list lines
where “mail” occurs.
Hit C-s
and M-s r
to switch to regular expression search.
Hit C-s C-h b
to browse the search options.
M-TAB
to run M-x completion-at-point RET- abbrev-mode :
C-x a g
andC-x a i g
(see alsoC-x a l
) - dabbrev-expand :
M-/
(see also hippie-expand) - yasnippet : template expansion
- pcomplete : custom completion when programming a mode
http://emacs-doctor.com/learn-emacs-lisp-in-15-minutes.html explores some of the basic functions of Emacs lisp.
List of concepts seen in this tutorial:
- symbolic expressions (
sexps
) - nesting parentheses to combine
sexps
- evaluating
sexps
C-j
andC-x C-e
- variables and
setq
- inserting text
- insert with more than one argument
- combining
sexps
into functions - evaluating functions
- switching to a new buffer
- combining
sexps
withprogn
- erasing buffer’s content
- switching to the other window
- using
format
- using
let
- reading strings from the minibuffer
- introducing lists
car
andcdr
- list mutability: using
push
map
over a list withmapcar
- moving to a point:
goto-char
- searching with
search-forward
- replacing with
replace-match
- using regular expressions in search with
re-search-forward
- adding text properties with
add-text-properties
C-h v
andC-h f
to explore variables and functionsC-h i m elisp
to explore the Elisp manual
- integer
- floating-point
- character
- symbol
- sequence (lists and arrays)
- cons cell
- array
- string
- vector
- char-table
- hash-table
- function
- primitive function
- byte-code
- autoload
- macro
- boolean
defvar
: define (“initialize”) a variabledefconst
: define a constantsetq
:(setq [SYM VAL]...)
setq-local
: (setq-local VAR VAL)defvar-local
:(defvar-local VAR VAL &optional DOCSTRING)
setf
:(setf (cadr x) y)
<=>(setcar (cdr x) y)
setcar
:(setcar CELL NEWCAR)
setcdr
:(setcdr CELL NEWCDR)
defun
: define a functiondefstruct
: define an “inline” functiondefmacro
: define a macrodefcustom
: define an option (customizable variable)boundp
: check if a variable is setfboundp
: check if a function is set
See Manipulating lists and their elements.
- cons cell
- consp, atom, listp, nlistp, null
- car (or first), car-safe
- cdr, cdr-safe
- pop
- caar, cadr, cddr, cdar
- nth, nthcdr
- last
- safe-length
- list
- make-list
- append
- add-to-list
- push
- memq
- delq
- remq
- member
- remove
- remove-if
- alist
- plist
- map
- mapc
- mapcar
- mapconcat
A function is the name of a sexp, possibly accepting arguments, returning the value of evaluating the sexp.
A command is an interactive function, using (interactive)
.
A lambda is an anonymous function.
(defun my-function () ; no argument
"A docstring." ; optional
(+ 1 1))
;; Check whether the symbol is bound to a function
(fboundp 'my-function)
;; Calling the function
(my-function)
(defun my-function-with-argument (first-argument) ; no argument
"A docstring." ; still optional
(message "Hello %s!" first-argument)) ; assuming a string
(my-function-with-argument "Bastien")
(defun my-command (name)
"A docstring"
(interactive "sYour name: ")
(message "Hello %s!" name))
(call-interactively 'my-function)
;; => error, as the function is not a command
(call-interactively 'my-command)
;; => return the name
;; M-x my TAB does not show the function
;; A useless lambda
(lambda () (message "A simple lambda"))
;; A useless lambda command
(lambda () (interactive) (message "A simple lambda"))
;; A useless lambda command with one interactive arg
(lambda (n) (interactive "s") (message "Hello %s " n))
;; Call a lambda-command interactively
(call-interactively (lambda (n) (interactive "sName? ") (message "Hello %s " n)))
;; Bind a key to a lambda-command
(define-key global-map (kbd "C-M-?")
(lambda (n) (interactive "sName? ") (message "Hello %s " n)))
(setq f 'list)
;; => list
(funcall f 'x 'y 'z)
;; => (x y z)
(funcall f 'x 'y '(z))
;; => (x y (z))
(setq f 'list)
;; => list
(apply f 'x 'y 'z)
;; => error→ Wrong type argument: listp, z
(apply '+ 1 2 '(3 4))
;; => 10
(apply '+ '(1 2 3 4))
;; => 10
(apply 'append '((a b c) nil (x y z) nil))
;; => (a b c x y z)
See also funcall-interactively
.
See Use a recursive function to implement “flatten”.
(defvar x -99)
;; => x
(defun getx () x)
(getx)
;; => -99
(let ((x 1)) (getx))
;; => 1
See the info manual:
When we call ‘getx’ from within a ‘let’ form in which ‘x’ is (dynamically) bound, it retrieves the local value (i.e., 1). But when we call ‘getx’ outside the ‘let’ form, it retrieves the global value (i.e., −99).
See also this info page on how to not abuse dynamic binding.
- set-mark
- goto-char
- point
- point-at-bol
- point-at-eol
- beginning-of-line
- end-of-line
- move-beginning-of-line
- move-end-of-line
- insert
- buffer-string
- buffer-substring
- buffer-substring-no-properties
‘.’ (Period) is a special character that matches any single character except a newline.
‘*’ is a postfix operator that means to match the preceding regular expression repetitively as many times as possible.
‘+’ is a postfix operator, similar to ‘*’ except that it must match the preceding expression at least once.
‘?’ is a postfix operator, similar to ‘*’ except that it must match the preceding expression either once or not at all.
‘*?’, ‘+?’, ‘??’ These are “non-greedy” variants of the operators ‘*’, ‘+’ and ‘?’.
‘[ … ]’ is a “character alternative”
‘[^ … ]’ This matches any character except the ones specified.
‘^’ When matching a buffer, ‘^’ matches the empty string, but only at the beginning of a line in the text being matched (or the beginning of the accessible portion of the buffer).
‘$’ is similar to ‘^’ but matches only at the end of a line.
‘\’ has two functions: it quotes the special characters (including ‘\’), and it introduces additional special constructs.
(defun my-find-letters-numbers ()
(interactive)
(when (re-search-forward "\\([a-zA-Z]+\\)\\([0-9]+\\)" nil t)
(message "String matched: %s -- Letters: %s -- Numbers: %s"
(match-string 0)
(match-string 1)
(match-string 2))))
(defun my-boldify ()
(interactive)
(while (re-search-forward "mail" nil t)
(add-text-properties (match-beginning 0)
(match-end 0)
(list 'face 'bold))))
(defun my-new-search-function ()
"My new search function."
(interactive)
(if ;; (re-search-forward "" nil t)
(re-search-forward "\\([a-z]\\{1,2\\}\\)\\([0-9]+\\)" nil t)
(message
"Found two groups: \"%s\" and \"%s\""
(match-string 1)
(match-string 2))
(user-error "Nothing found")))
(my-new-search-function)
;; abcde1
- re-search-forward
- match-beginning
- match-end
- case-fold-search
(setq x 3)
(setq x 3 y 4)
(inc x)
;; => 4
(macroexpand '(inc x))
;; => (setq x (1+ x))
;; (inc x) <=> (setq x (1+ x))
(defmacro inc (var)
(list 'setq var (list '1+ var)))
;; (inc2 x) <=> (inc x)
(defmacro inc2 (var)
`(setq ,var (1+ ,var)))
;; (inc2 x) <=> (inc x)
(defmacro let-a-3 (&rest body)
`(let ((msg "hello"))
,@body))
(let-a-3 ;; msg est toujours défini
(message "blabla")
(sit-for 2)
(message msg))
(inc2 x)
(macroexpand '(inc2 x))
;; => 5
See org-preserve-lc
in org-mode on how to use ,@body.
- Major and minor mode
- derived-mode
- syntax highlighting
kill-all-local-variables
- modeline (
global-mode-string
) - keybindings (
define-key
) - menu (
easy-menu-define
) defcustom
provide
require
- examining text properties with
C-u C-x =
set-text-properties
- headline
- subtree
- paragraph / list / table / block
- initial folding state
#+STARTUP: showall
- options
- blocks
- publishing projects
- predefined agenda views
- custom agenda views
- agenda blocks
! ! Swap Caps_Lock and Control_L ! remove Lock = Caps_Lock remove Control = Control_L keysym Control_L = Caps_Lock keysym Caps_Lock = Control_L add Lock = Caps_Lock add Control = Control_L
- one vs multiple .el configuration files
- “tangling” a .el configuration file from a .org file
- use-package