GNU Emacs
Table of Contents
- 1. Keybindings
- 2. Commands
- 3. Modes
- 4. Applications
- 4.1. Calc builtin
- 4.1.1. Global Keybidings
- 4.1.2. Local Keybindings
- 4.1.2.1. Help
- 4.1.2.2. Input
- 4.1.2.3. Basic Operations
- 4.1.2.4. Array Operations
v - 4.1.2.5. Algebra
a - 4.1.2.6. Functions
- 4.1.2.7. Random
- 4.1.2.8. Units
u - 4.1.2.9. Store
s - 4.1.2.10. Select
j - 4.1.2.11. Convert
c - 4.1.2.12. Display
d - 4.1.2.13. Mode
m - 4.1.2.14. Trail
t - 4.1.2.15. Time
t - 4.1.2.16. Graphing
g - 4.1.2.17. Macro
z
- 4.1.3. Configurations
- 4.2. Org Mode builtin
- 4.2.1. Metadata
- 4.2.2. Markup
- 4.2.3. Macro
- 4.2.4. Commands
- 4.2.5. LaTeX Support
- 4.2.6. Source Code
- 4.2.7. Org Table
- 4.2.8. Task Management
- 4.2.9. Dot
- 4.2.10. Org Agenda
- 4.2.11. Org Roam
- 4.2.12. Org Drill
- 4.2.13. Org Cliplink
- 4.2.14.
org-special-block-extras - 4.2.15. Export and Publish
- 4.2.16. Configuration
- 4.3.
eshellbuiltin - 4.4.
ewwbuiltin - 4.5.
calendaranddiarybuiltin - 4.6.
mpc - 4.7.
sesbuiltin - 4.8.
ispellbuiltin - 4.9. Amusements
- 4.1. Calc builtin
- 5. Configuration
- 6. Packages
- 6.1. LaTeX
- 6.2.
elpy - 6.3.
lsp-mode - 6.4. Eglot builtin
- 6.5.
ein - 6.6.
eimp - 6.7.
pdf-tools - 6.8.
corfu - 6.9. Evil
- 6.10. Magit
- 6.11. Autotype
- 6.12. Completion
- 6.13. Interface
- 6.14. Project
- 6.15. Music
- 6.16. Window
- 6.17.
undo-tree - 6.18.
multiple-cursors - 6.19. Iedit
- 6.20.
keycast - 6.21.
diminish - 6.22. TRAMP builtin
- 6.23.
gtag - 6.24. Anki
- 6.25. Mail
- 6.26.
shrbuiltin
- 7. CLI
- 8. Distributions
- 9. Help
- 10. Emacs Lisp
- 11. History
- 12. External Links
- 13. Reference
Emacs is a keyboard-centric text editor.
Figure 1: Screenshot of Personal Emacs Setup
1. Keybindings
1.1. Basic
| macro | description |
|---|---|
C-(n,p) |
next/previous line |
(C,M)-(f,b) |
forward/backward, a character/word |
(C,M)-v |
next/previous screen |
C-M-v |
next the other window |
(C,M)-(a,e) |
beginning/end of a line/sentence |
C-l |
center the cursor and move screen up half a screen |
M-(<,>) |
beginning/end of a file |
C-u <number> <macro> |
to feed <number> to <macro> |
(C,M)-(d,DEL) |
delete/kill a character after/before the cursor |
(C,M)-k |
kill to the end of line/sentence |
C-SPC MOTION C-w |
select and kill |
C-y |
yank (paste) |
M-y |
flip through the kill ring, <C-h> v kill-ring list them |
C-j |
newline, evaluate lisp expression in *scratch* |
C-/ |
undo |
(C,M)-x |
simple/complex execute |
C-g |
escape |
C-(s,r) |
isearch (backward) |
C-M-(s,r) |
regexp isearch (backward) the groups are colored different |
M-s o |
occur, even during isearch |
M-% |
query replace, even during isearch |
C-M-% |
regexp query replace, that supports grouping |
C-z |
suspends Emacs |
C-x ESC ESC |
repeat last command |
M-TAB |
dab completion based on the text in the open buffers |
M-T |
transpose-word: drag a word forward |
M-\ |
remove all spaces between words |
M-SPC |
contract the spaces between words into one space |
M-; |
insert a comment line |
1.2. Extended
Prefix C-x (X as in eXtend)
1.2.1. Text
| macro | description |
|---|---|
C-; |
comment out a line |
C-TAB |
indent interactively |
1.2.2. Buffer
| macro | description |
|---|---|
C-s s |
save current buffer/selected buffers |
C-w |
write current buffer to a file |
C-f |
find a file |
d |
open a directory |
C-b b |
buffer menu/type buffer name to move to |
k |
kill a buffer |
C-c |
quit |
<right> <left> |
next or previous buffer |
i |
insert a file |
1.2.3. Window
| macro | description |
|---|---|
0 |
remove window |
1 |
remove every other windows |
2 |
duplicate window below |
3 |
duplicate window to the right |
4 0 |
kill-buffer-and-window |
5 (0,1,2,o) |
do the same but to a frame |
o |
move to other window |
C-+ C-- |
zoom |
^ - + |
enlarge, shrink if larger than buffer, balance windows |
{ } |
shrink, enlarge horizontally |
1.2.4. Frame
| macro | description |
|---|---|
<f11> |
fullscreen |
M-<f10> |
maximize frame |
1.2.5. Register r
| macro | description |
|---|---|
s R |
copy region into the register R |
i R |
insert text form R |
w R |
save workspace to R |
j R |
load workspace form R |
1.2.6. Rectangle r
| macro | description |
|---|---|
o |
open rectangle filled with space |
t |
string rectangle |
d |
delete rectangle |
y |
yank rectangle |
c |
clear rectangle and fill with space |
k |
kill rectangle |
r |
copy rectangle to register |
1.2.7. Bookmark r
| macro | description |
|---|---|
m |
set bookmark at point |
b |
jump to bookmark |
1.2.8. Tab t
| macro | description |
|---|---|
0 |
tab-close |
1 |
tab-close-other |
2 |
tab-new |
RET |
tab-switch |
m |
tab-move |
1.2.9. Project p
A project is recognized if it's either tracked by a version control system, or EDE(Emacs Development Environment) has created the project.
1.2.10. Special Characters 8
- It is the compose key equivalent.
| macro | description |
|---|---|
RET |
(insert-char) insert unicode by its name or codepoint |
Superscript letters in Unicode | Rupert Shepherd
eemoji
| macro | description |
|---|---|
e, i |
emoji-insert |
l |
emoji-list |
1.2.11. Narrow n
| macro | description |
|---|---|
d |
to function |
n |
to region |
p |
to page |
w |
widen |
1.3. Mode Bindings
C-c may used
1.3.1. Buffer Menu
| macro | description |
|---|---|
m |
mark |
s |
mark for save |
d, C-k |
mark for delete |
x |
execute markings |
u, U |
unmark (all) |
b |
bury to the end of the list |
RET, e, f |
open buffer menu window |
o |
open on other window |
V, O |
view (in other window) |
T |
toggle show files only |
% |
toggle read-only |
g |
revert buffer |
C-o |
close buffer |
q |
close window |
1.3.2. dired builtin
Directory Editing
C-x d, M-x dired Open a directory with Dired
- Dired Guess
dired-xprovides the dired guess functionality.dired-guess-shell-alist-usercontains the list of suggestions based on the filename
nerd-icons-dired,all-the-icons-dired,treemacs-icons-diredadd icons
1.3.2.1. Local Keybindings
vview- Open with
ViewMajor mode if no other major mode for view is available. qto exit
- Open with
Cdo copy,Ddo delete,Rdo rename/movedmark to deletexexecute flagged deleteiadd subdirectory into current buffer$,M-$toggle hidden (of all)C-M-u,C-M-dTree up or downC-M-n,C-M-pNext or previous subdirectory
m,umark and unmarkTdotouch,Odochown,Mdochmod,Gdochgrp,Ndoman,Idoinfo,Sdosymlink,Hdohardlink,ZdocompressXdo shell commandC-x C-fto create a new file,make-directoryto create a new directory.grevert(reload) bufferC-x C-qimmediate edit^><Parent directory, Sibling directorywcopy filename to kill ringWbrowse url of dired file- It opens a new server editing buffer for text files, which is like a externally opened file but in the same frame.
C-x #to mark it done and switch to next server editing buffer.
Jgoto file&async shell command on the file at point,Xshell command on the fileC-tthumbnail.display thumbnail in other windowC-ttoggle inline thumbnailaappend thumbnail to the thumbnail bufferddisplay thumbnails of file at the cursor, or marked filesidisplay image in other windowjjump to thumbnail bufferxdisplay image externally
C-ttag- The tags are stored in
~/.emacs.d/image-dired/.image-dired_dbttag filesrdelete tagfmark tagged file
- The tags are stored in
*markmmark,uunmark,!?unmark all*executable,/directory,@symlink,ssubdir files%mark with regexp* C-n,* C-porM-{,M-}previous or next marked file
%regexpCcopyR,rrenameSsymlinkYresymlinkHhardlinkdflag,gflag files containing regexp&flag garbage filesmmarkl,udowncase, upcase
1.3.2.2. Configuration
ls-lisp-use-insert-directory-programuse externallsinstead ofls-lisp, the builtinlsemulation written in Lisp, if this ist- This does not apply to
dired-sidebarfor some reason. insert-directory-programthe external program to be useddired-listing-switchescontrols the options passed to the program, includingls-lisp
- This does not apply to
ls-lisp-dirs-first- list directory first when using
ls-lisp
- list directory first when using
dired-use-ls-diredappend--diredoption
1.3.2.3. dired-sidebar
dired-sidebar-toggle-sidebarTAB(dired-sidebar-subtree-toggle)RET(dired-sidebar-find-file) open the file in the last windowC-o(dired-sidebar-find-file-alt) opens the file in the window selected by ace-window-(dired-sidebar-up-directory)
1.3.3. proced builtin
list running processes, similar to top.
1.3.4. Dumb Shell
C-<up>,C-<down>previous or next input
1.3.5. Outline Mode
It is minor mode for markup files. It changes its behavior based on the major mode
- Help mode:
<,>beginning or end of buffer
Prefix C-c @, or sometimes C-c
| macro | description |
|---|---|
C-e, C-s, C-b, C-a |
show entry, subtree, branches, all |
C-c, C-d, C-l, C-t, C-o, C-q |
hide entry, subtree, leave, body, other, all |
C-p, C-n |
previous or next visible heading |
C-b, C-f |
backward or forward same level |
C-<, C-> |
promote or demote |
C-^, C-v |
move subtree up or down |
RET |
insert heading (it copies the previous heading) |
2. Commands
M-xexecute command- Every keybindings are a lisp command that can be executed in here.
M-!run shell command and output to the minibuffer- It can run
sudowith the help of-Soption that read from standard input, or with the askpass helper which isksshaskpasson KDE. C-uprefix makes the output go to the current buffer.- Use
M-|instead to accept a region as an argument.
- It can run
M-:execute a Lisp expression.view-registercompilerun compile command and format the output.greprun greprgrepsearch thoroughly
describe-modedescribe the enabled modesindent-rigidlyundo-onlyundo the region selected. It only works for the edits done natively by emacsopen-dribble-filerecord every input events into a file,recent-keysreturns last 300 input events.recover-fileselect file to recover from the auto-save filerecover-this-filealso exists.
2.1. Text Manipulation
align-regexpalign a region with ad hoc rules.C-x RET r(revert-buffer-with-coding-system) try a new encoding.recode-region,recode-file-nametranslate from one encoding to another.fill-regionbreak a long line into smaller ones.
2.2. Shell Functionalities
M-!(shell-command) run shell command in the minibuffer and echo the result.eshell-commandrun eshell command in the minibuffer
2.3. File Manipulation
delete-file,rename-filemake-directorymake-dload-file: Load Lisp file, especially the.emacs.
2.4. External Functionalities
run-pythoncompile- It displays the result in a special buffer.
shell- Run the shell in
dumbstate
- Run the shell in
3. Modes
Major mode can be enabled on at a time, while minor modes can be used alongside any other modes.
3.1. Major Modes
Major mode is determined by
- Local variables
modewithin-*- var:VAL; ... -*-in the first line - Compare file extension against
auto-mode-alist - Infer from the interpreter in the
#! - Infer from the start of the buffer using
magic-mode-alist - Compare file name against
auto-mode-alist - Compare the start of the buffer against
magic-mode-fallback-mode-alist- It checks for image files, markup files, PostScript files, Unix Conf files.
- The major mode is remapped using
major-mode-remap-alist
The default major mode can be accessed by M-x normal-mode
3.1.1. Language
python-modeein
hexl-modehexedit.emacs-lisp-modeC-c C-b(elisp-byte-compile-buffer)C-c C-e(elisp-eval-region-or-buffer)C-c C-f(elisp-byte-compile-file)C-M-x(eval-defun)eval-buffer
3.1.2. Special Text
picture-mode: draw a diagram, with cursor moving in any direction
3.1.3. View
- View
- DocView
3.2. Minor Modes
When a minor mode is enabled globally, it does not show on the mode line.
- Minor mode can be set by
-*- eval: (MINOR-mode) -*-in the - File
read-only-modedesktop-save-mode- It is not saved when
emacsclientis closed - The frame position, search history, file history, registers, buffers are saved
- It is not saved when
auto-save-modesave buffers in#<file>#periodically, whenauto-save-defaultis non-nil- It is deleted on save, when
delete-auto-save-filesis non-nil .#<file> -> bufferis temporarily created when the buffer is hot- Backup files named
<file>~are made on save whenmake-backup-filesis non-nil
- It is deleted on save, when
auto-revert-mode,global-auto-revert-modeglobal-ede-mode- Emacs Development Environment
- It is a built-in package that manages projects
recentf-moderemember recent files
- GUI
tool-bar-modemenu-bar-mode- the menu bar can be accessed with F10
scroll-bar-modeandhorizontal-scroll-bar-modetab-bar-modedisplay-line-numbers-modedisplay-line-numbers-major-tick- The line numbers are not aligned correctly in
variable-pitch-mode.
- Mode Line
- The file status
<encoding><newline>@<modifiable><modified><file location>- Encoding:
Uutf-8-unix, - Newline:
:Unix LF,<DOS>CRLF
- Encoding:
line-number-modedisplay line number in the mode line
- The file status
windmove-modemove and swap windows with keybindingsuse-dialog-boxlet the mouse operation open a separate dialog boxdisplay-time-modedisplay time in the minibuffer- Text
abbrev-modesimple snippet mode that triggered byRET- Prefix
C-x a C-aor+orl:add-mode-abbrevg:add-global-abbrev'ore:expand-abbrev
- Prefix
auto-fill-modeautomatically insert line breakM-q(fill-paragraph) automatically insert line breaks and fill the line at the current paragraphC-x f(set-fill-column) set the column numbers for the paragraphfill-regionfill the paragraphs in the region,fill-region-as-paragraphconsider region as one paragraphcenter-linecenter a linevisual-line-modewrap the long line visually
savehist-modesave the history of the minibuffersave-place-modesave the point position- Unibyte Editing Mode
3.3. Keymaps
keymap-setanddefine-keycan be used to modify the keymap of the mode.MODE-mode-mapcontains the keymap of the mode.
4. Applications
4.1. Calc builtin
GNU Emacs Calculator
There's also calculator which is a dumbed down version of the calc with single stack and infix notation.
4.1.1. Global Keybidings
<C-x> * c,<C-x> * *,<M-x> calcto open<C-x> * oopen another window<C-x> * qquick calc. open in the minibuffer
<C-x> * eembedded calc on a block of continuous formula as a line, after evaluating it.- The separation of a block is detected by a two newlines.
<C-x> * jembed but on appropriate side of the=>or:=.a :10= becomes. .. 10<C-x> * wembed on a single word if the expression is not parsable, otherwise same as just embedding.- The embed can be exited with any of the commands
<C-x> * btoggle full screen for the Calc<C-x> * yyyank the top element to the most recent edit buffer<C-x> * ggrab, parse a line into the top element as vector- The number of line can be given as numeric prefix,
and if only
C-uis given the line is interpreted as a single entry.
- The number of line can be given as numeric prefix,
and if only
<C-x> * rrectangle, parse a region as matrix- The column length can be given as numeric prefix
<C-x> * :sum the columns<C-x> * _sum the rows
<C-x> * 0reset<C-x> * xturn calc off<C-x> * mread in as a macro<C-x> * zuser invocation- start Calc with user defined macro by
Z I
- start Calc with user defined macro by
4.1.2. Local Keybindings
The key in the heading is the common prefix.
4.1.2.1. Help
imanualhhelphall keybindingsssummary appendiximanual
?rotate through the brief help
4.1.2.2. Input
<,>scroll to the right/left{,}scroll up/down
Edit
Uundo,Dredo<TAB>rotate the top two- rotate the top
Nelements downward while wrapping if positive - move the entire stack
Nstep downward if negative. <M-...>rotate upwards
- rotate the top
<DEL>remove the top- remove the top
Nelements if positive - Delete the entire stack if
0 Nth element form the top is removed if negative<M-...>remove from the bottom
- remove the top
Input
<RET>duplicate the top element<M-RET>push the last arguments- recover the deleted elements by a function
[2-32]#NNinput number in a given radixNNeNNscientific notation_negative sign:enters the fraction[ .. , .. ; .. ]vector and matrix,[ .. ][ .. )interval, representing all number between the bounds[(pushes the incomplete object and complete it later.{ .. , .. }can also be used. comma is required
( .. , .. )( .. ; .. )complex number (in polar),.. @ .. ' .. "hms time"string- Operation can be put right after number
$can be used in place of the top stack element, the output will be replace the top$$,$$$repeatedly using dollar sign accessNth element from the top
'algebraic input- Insert an expression containing symbols, equations, and various others
<RET>evaluate and the expression and insert<M-RET>evaluate with the variables resolved, and insert<C-j>or<LFD>(Line Feed) does not evaluate it,=to evaluate it later.
/has lower precedence than*.a mod bmodulo arithmetic+/-to include the uncertainty
< , : >inline function- The arguments are given in a vector.
- It cannot be used on its own. It needs to be evaluated by
another function, such as,
call(f, a, b),v A,apply(f, v)
4.1.2.3. Basic Operations
- They take the elements from the stack and perform certain operations
- Number prefix can be given
- The binary operation is going to be reduce the top
Nelements if positive, or operate on eachNnext-to-top element by the top element if negative.
- The binary operation is going to be reduce the top
+,-,*,/,^\integer division,%modulo:fraction~can be used to use the top element as the prefix numberKkeep the arguments in the stack by prefixing this- Evaluation
=evaluate and substitute the stored variablesNexpand the irrational valuesa vevaluate algebra
- Simplification
a salgebraic simplificationu sunit simplification- Automatically applied when in
UnitSympmode
- Automatically applied when in
4.1.2.4. Array Operations v
p,pack(a, ...)pack first few top element into another object depending on the mode specified by numeric prefixN, or the value of the top element.- Vector of length
NifNis nonnegative -1complex number-2polar complex number-3HMS form-4error form-5modulo form-6closed interval,-7upper half-open interval,-8lower half-open interval,-9open interval-10fraction-11mantissa and exponent into floating point number
- Vector of length
u,unpack(a, ...)unpack the top element- negative number specifies the mode
- It can unpack any formula as well, including equations
- It unpack the structure given by the underlying lisp representation.
- (Without the prefix)
|,vconcat(a,b)concatenate top two element into a vector,I |in reverse order,H |not recursively. Econvert an interval into a vector of integers:vector into an intervalipush an identity matrixddiagonal matrix out of the topxpush the index vectorr,c,mrow(m, i),mcol(m, i)extract the row/column of a matrix at the index of the top element or numeric prefix.s,subvec(m, i1, i2)extract a subvector from the first index up to the second index excluding it.- The index is counted from 1
- A row/column is removed if negative number
m_i,subscrcan be used for the algebraic case.
- The index is counted from 1
fsearch for an element in a vectoraarrange a vector or a matrix into a matrix of a given number of columnvreverse the vectorh,head(v)take the head, the first element of a vector.
4.1.2.4.1. Linear Algebra
- The regular multiplication
*does the matrix multiplication. ttransposeJconjugate transposeCcross productAEuclidean norm or Frobenius normnInfinity normNone-norm&inverse of a square matrixDdeterminantTtraceLLU decompositionKKronecker product
4.1.2.4.2. Element-wise Operations
AApply- provide each element as each argument to a function.
Mmap,Rreduce,Uaccumulate(scan)- Map can take multiple vectors as the inputs
:,_map or reduce each column/row of matricesNspecify the number of arguments.- The element-wise operation can be any Calc binding
such as
+,v M,a ]. xselect a lisp function'specify a custom function- Write the expression inline, for example,
sin(x) + y.- The arguments of the function will be selected manually after
you press
RET.
- The arguments of the function will be selected manually after
you press
- The inline expression can contain
$,$$in which case you don't need to specify the arguments.$for the top,$$for the second to top, and so on.
- The anonymous function can contain
#1or#(one variable) in which case the arguments does not need to be specified. - A lambda expression can be passed as well, for example,
lambda(a, b, a+b).
- Write the expression inline, for example,
O,Igeneralized outer/inner product- Inner product requires specifying two operator
4.1.2.4.3. Set Operations
+remove duplicates,#set cardinality,Vunion,^intersection,-set difference,Xset XOR,~set complement with respect to real number
4.1.2.5. Algebra a
vevaluate the algebra,"expand into the definitionssimplifyxexpand: divide fractions, distribute multiplicationffactor a polynomialH a freturn the list of factors with its multiplicity.
c,collectexpress the polynomial in a given variable.n,nrat(a)normalize rational (symbolic fractions into a one rational expression),apartial fraction\polynomial division,%polynomial remainder,gpolynomial gcdI a strigonometric function simplificationH a shyperbolic function simplificationa eextended (unsafe) simplification
dderivative,i(integ(f),integ(f(x), x, a, b)) integrateI(ninteg) numerical integration
Mmap equation- Map both side of the equation
Pfind the root of polynomialSsolve the equations- It can also take a vector of equations and a vector of variables.
Rroot finding- A formula or an equation is solved numerically, starting from the top element
- It can also take a vector of equations, and a vector of initial values, a vector of variables.
- Assigned variable can be used,
_dose not constitute a variable. - The formulas have to be differentiable
Fcurve fitting- It act on a list of list containing each variables consecutively.
- The number specify the detail
1linear,2-9multilineare,x,E,Xpolynomial,l,LlogarithmicqquadraticgGaussian functionsLogistic- …
+sum over a given range*product over a given range
4.1.2.6. Functions
- Inverse modifier
I, and hyperbolic modifierHare often used Q,sqrt(a)F,floor(a),I F,ceil(a)R,round(a),I R,trunc(a)J,conj(a)complex conjugate,G,arg(z)argumentL,ln(z),E,exp(z),H L,log10(z),B,log(b x)S,sin(z),C,cos(z),T,tan(z),H ...!factorialfh,hypot(a,b)hypotenuseQ,isqrt(a)integer square root, square root rounded downn,min(m, n)x,max(m, n)r,re(z)real part,i,im(z)imaginary partg,gamma(z)Gamma functionb,beta(a,b)Beta functione,erf(z)Error functionj,besJ(n,x),y,besY(n,x)Bessel function
kCombinatorial/Statisticalg,gcd(a,x)Greatest common divisorl,lcm(a,x)Least Common Multiplec,choose(n,m)Binomial coefficient,H ...permutationb,bern(n)Bernoulli numberse,euler(n)Euler numbers,H ...Euler polynomials,stir1(n)Stirling numbers of the first kind,H ...stir2(n)of second kindptest if prime- For a large integer, probabilistic method in The Art of Computer Programming-volume 2-section 4.5.4-algorithm P is used.
f,prfac(n)prime factorizationn,nextprime(n),I ...,prevprime(n)t,totient(n)Euler's totient functionm,mobius(n)Möbius function- Probability Distributions
- The nomenclature is
Xutpx,H ...ltpxfor cumulative - The random variable is the top element
B,utpb(x,n,p)Binomial distributionC,utpc(x,v)Chi-squared distributionF,utpf(F,v1,v2)F-distributionN,utpn(x,m,s)Normal distributionT,utpt(t,v)t-distribution
- The nomenclature is
4.1.2.7. Random
rrandom()- It generate a random integer between 0 and the numeric
prefix, or the top element
agenerate a number reusing the recent valuehshuffle
- It shuffles the top vector, may be truncated to a desired length
- It generate a random integer between 0 and the numeric
prefix, or the top element
4.1.2.8. Units u
- Units are just unassigned variables that are in the unit table
- Number with unit can be entered as a algebraic expression.
Most common units and constants are predefined
eps0ɛ0,mu0μ0,c,G,h,hbar,eech,k, …
ssimplify for the unit expression,aautorange unit prefix the unit with appropriate one.cunit convert,nconvert if exact,bconvert to base unit, equivalent tos based,udefine/undefine unit,rremove unit,u pmake it permanent in thecalc.elgget unit definition,vshow unit tablesStoreinf,e,pi,phi,gamma,uinf,nanare preassigned variables- These are only evaluated by
N, not=
- These are only evaluated by
4.1.2.9. Store s
- If the variable name is a number
Nit is stored in special variableqN. The quick variables can be directly specified withouts - If the top element is an assign statement:
=,:=, it will perform it rrecall, push the valueuunstoretstore into, store the top elementxexchange with the top of the stackccopy to another variable+,-, … perform the operation and assign, equivalent to+==evaluate to, enter the evaluation statement of the top element=>The expression on the left is untact, the value on the right is recomputed by=(evaluate) whenever something changes.
ddeclare the type of a variable or a functionllet
4.1.2.10. Select j
- Select within a entry and perform operation on them
s,uselect/unselectaadd,bbreak selection,mlselect more/less,1, …,9select =N=th partn,pselect next/previousdhighlight selected part within the whole formulacclear all selectioneenable/disable selection. the*marker disappears and the operation works on the entire formula anyway. It is enables by default.'replace selection through minibuffer input`edit selection through a temporary bufferR,Lcommute right/left,Ccommute within a selectionD,Mdistribute/merge a levelJjump equals, move a term on the other side of the equation+,-,*,/, … Operate on both side of a equation, or numerator and denominator of a fraction.
4.1.2.11. Convert c
fconvert fraction to float,Ffloat to fractionpbetween polar and rectangular complex numbersd,r,hdegree, radian, hms
4.1.2.12. Display d
tTruncate. It cuts the stack at the cursor, and stashes the ones "above" it.rchange the radixc,i,j, complex number format- Language
Nnormal,Bbig (pretty print),Uunformatted(raw Lisp),C,LLaTeX,TTeX- The complex number format does not apply in
BandC
4.1.2.13. Mode m
- The current mode is displayed in the mode line
apartly algebraic mode,(and[also starts algebraic input.tfull algebraic mode,<ESC>to not use algebraic input.
Signore cases, the prefix key becomes case insensitive.ddegree,rradian- The default unit of the output of functions that produce angles
ppolar mode, prefer complex numberffraction mode, prefer fractionc fcan be used to evaluate the fractions
iinfinite mode,1/0produceinfssymbolic mode, the irrational result will be left symbolicNcan be used evaluate into numeric result
vmatrix mode, every object is assumed to be matrices unless it cannot beCtoggle automatic recomputation,=>- Simplification
Ibasic simplificationUunit simplificationAalgebraic simplification (Default)Nnumber simplification, only number operations are simplifiedEextended simplificationOno simplification
msave modes, including display/language/precision/definition/calculationgget modes, push the mode numbersRrecord mode change directly into the file
4.1.2.14. Trail t
dtoggle traili,ofocus into/outof trailn,p,[,]move the trail marker>(to the start/end),ypush trail marker to the stacks,rsearch (in reverse)
4.1.2.15. Time t
Npush current datetimeDdate into a number measured since Jan 1, 1 ADJconvert date into Julian day countUconvert date into unix time valueCconvert time zone of date
4.1.2.16. Graphing g
- It stores the values in a temporary buffer and let the Gnuplot plot it.
fFast plot. graph the top two element using Gnuplot. top element is the \(y\).- \(x\), \(y\) can be a vector of same length
- \(x\) can be an interval, then \(y\) needs to be an algebraic expression in one unassigned variable
- The top element can be a formula of the form
xy(x(t), y(t)).
pplota,d,cadd/delete/clear the plotg,b,k… grid, border, keyNselect the number of datapointsqquit the plot
4.1.2.17. Macro z
Z Dbind the function to a key<C-x> (<C-x> )the globalkmacrocan include the followingcalcspecific functionalities.- Branch
CONDZ [start if,Z |else if,Z :else,Z ]end if
Loop
REPEATZ < BODY Z >repeats a command in between, the top value times.REPEATis the top elementINIT FINALZ ( BODY STEP Z )for loop, repeat with
counter
INIT,FINALare the top two elements of the stackSTEPis a numberCONDZ /break out of macro loop
- Breaks the top element
CONDevaluates to true.Z {,Z }loop forever
- Scope
Z `Z '
Z Kset macro name for the last recorded macro, which can
be executed by
zZ Eedit macro<C-x> eorXexecute macro<C-x> ecreate a undo history for each command,Xcreate a single undo history
- Branch
Z Idefine user invocationm msaves this
Z Fdefine a formula- The formula at the top element is stored as key, command and function.
- The anonymous function can also be used.
Z Gpush the formula to the stack
Z Pdefine a command permanently in thecalc.elZ Uundefinezis prefixed to use the user defined keys and functions- Lisp
defmathcan be used(interactive NUM TAG)- Takes
NUMarguments from the stack.
- Takes
(calc-eval "expr")is available
- Configuration
pset precision- The floating point precision default to 12
xrun calc command<M-x> calc-qquit
4.1.3. Configurations
Configurations can be stored in:
.emacs: Configure manually or viaCustom- the file set by
calc-settings-file(.emacs.d/calc.elby default).- This file is loaded on the first launch of Calc.
The global variables can be accessed directly, but the internal
functions and variables needs to be imported via (require 'calc-*).
- The variables that controls the initialization can be set.
- The detail can be directly found in the repo
4.2. Org Mode builtin
It is a mode for .org file, but it's large enough to be called an application.
4.2.1. Metadata
#+TITLE:#+AUTHOR:#+STARTUP:numorg-num-mode
4.2.2. Markup
Heading (Topics)
******, …- Promoting without heading is not allowed due to the need for simplicity
and compatibility with LaTeX, DocBook and traditional book/article structures.(??, ????)
M-<right>,M-<left>demote and promote current heading or list itemC-M-<right>,C-M-<left>demote and promote current subtreeM-<up>,M-<down>swap up and downM-RETnew item,M-S-RETnew checklist item
- Tags
C-c C-q(org-set-tags-command) add tag to a topic.C-c C-cdoes the same thing in a headline@and_can be used within tag names.#+TAGS: <tag>(<fast access key>) ...is used to set tags for a fileorg-tag-alistdefines the tags, with the second argument?<fast access key>.
*bold*,/italic/,_underline_,+strikethrough+,~code~,=verbatim=,:at the start of a line+-*=(nested) unordered list, =1.1)A.A)ordered list,[ ][-][X]checkbox,:: tag- Todo
C-c C-torS-<right>,S-<left>org-todo, change the todo state
- Link
C-c C-lorg-insert-link,C-c C-oorg-open-at-point[[target]]or[[target][desc]]type:targetif no type is provided, org looks for the headings.httpfile- it can be nested such as
file:...::#idorfile:...::*heading - The
idis set by theCUSTOM_IDproperty.
- it can be nested such as
<<target>>dedicated target. Link to it with[[target]]#+name: targetmatch the exact name of an element.- See External Links (The Org Manual), Internal Links (The Org Manual)
org-link-set-parameterscreate custom link type:follow <func>on open:export <func>:store <func>:image-data-fun <func>
- Footnote
[fn:Name],[fn:: inline],[fn:NAME: inline definition]C-c C-x ffootnote action. jump to the definition, or create a new footnote, and moreC-c C-cjump to the definition or jump back to the referenceC-c C-oor<mouse-1>,<mouse-2>follow the link, same asC-c C-c
- Citation
- It is referenced with
[cite/<style>/<variant>:<prefix> @<key> <suffix>; ...] - The bib source file can be added locally with
#+bibliography: <BibTeX file>or globally withorg-cite-global-bibliographyvariable. C-c C-x @(org-cite-insert) select withRETand finish withM-RET(orC-M-jin some cases).
- It is referenced with
- Image
- Image is inserted as a link to the image file.
C-c C-x C-vto render images inline.- Image can only be rendered inline when there is no description in the link.
- Instead of manually rendering inline images for every buffer,
the variable
org-startup-with-inline-imagescan be set totglobally, or the directive#+STARTUP: inlineimagescan be used per file. #+caption: TEXT,#+name: NAMEcan be preceded to the image.#+attr_org,#+attr_latex,#+attr_html: :TAG VALUEare used to set the display format.- Images (The Org Manual)
#+begin_TYPE#+end_TYPEblockcenter,comment,dynamic,example,export,quote,special,verse,src
|table
#comment,@@comment: comment@@inline comment,#+BEGIN_COMMENT #+END_COMMENT block comment, =* COMMENTsection comment
4.2.3. Macro
#+macro: f ...$1...define macro{{{f(1,...)}}}use macro
4.2.4. Commands
C-c C-j(org-goto) show outline in a new buffer and select from itC-c C-qadd tag to a topicC-c C-x C-v(org-toggle-inline-images)C-c C-x- Properties
p(org-set-property)P(org-set-property-and-value)
- Timer
;(org-timer-set-timer) countdown timer,0(org-timer-start) countup timer,(org-timer-pause-or-continue),_(org-timer-stop).(org-timer) start a timer if there's none, and insert current elapsed time
- Text
C-f(org-emphasize) choose bold, italic, and others.
!reload all lisp files related to org.- LaTeX support
- Properties
4.2.5. LaTeX Support
org-cdlatex-modeenables the cdlatex bindings
4.2.5.1. LaTeX Preview
org-latex-previewis now being worked on to include live preview and support in other major modes.- See Emacs 💜 LaTeX - YouTube and the documentation.
org-latex-preview-auto-mode
- The
divpngdid not work sometimes with the error.dviwas not found. Changing the relative path%fto absolute path%Ffixed the issue.- It is not supported on the Karthink's branch
#+startup: latexpreviewrenders the LaTeX expressions on startup.org-startup-with-latex-previewcan be also be set tot
<C-c> <C-x> <C-l>preview the LaTeX fragment at the cursor, if no fragment for every fragment in the current entry.
4.2.6. Source Code
#+begin_src#+end_srcsource code block- The source code is only executable if the language is properly installed on the system and the language is loaded by Babel
- Babel: Code block evaluation and management.
- The language listed by
org-babel-load-languagesis loaded. <C-c> <C-c>evaluate
- The language listed by
4.2.6.1. Header
#+HEADER: can be used to specify the headers
:varVARIABLE=VALUEGive parameter to the script
:results- Collection
valuereturn value,outputstandard output
- Type: Result Type
table,vector,list,scalar,verbatim,file
- Format: Result Format
raw,code,drawerhtmlUseBEGIN_EXPORT htmllatexUseBEGIN_EXPORT latexlink,graphicsLink to the file specified in:fileheader argument The code block output is not written to the diskorgUseBEGIN_SRC orgblockppPretty-Print Source Code
- Handling
replacesilentecho in the minibuffernonecompute the result without displaying them, but it can be used by other code blocksdiscardThe result is ignored. The value of the code block will benilappendappend to the buffer at the bottomprependPrepend to the buffer at the top
- Collection
4.2.7. Org Table
C-c C-calign tableM-a,M-ebeginning and end of a field.M-<arrow>move a row or columnM-S-<right>insert column left (at point),M-S-<down>insert row above (at point)M-S-<left>delete column at point,M-S-<up>delete row at point.S-<arrow>move a cellC-c -insert hline belowC-c RETinsert hline below and move below the hlineS-RETfirst non-empty field above and insert copy of it below.- integer, time stamp, whole number prefixed/suffixed is incremented when
org-table-copy-incrementis set.
- integer, time stamp, whole number prefixed/suffixed is incremented when
C-c TABshrink or show specified columns.- Tables (The Org Manual)
4.2.7.1. Table Formula
- Advanced features: Advanced features (The Org Manual)
- The Spreadsheet (The Org Manual)
- It can be directly entered into a cell by prefixing
:=.
4.2.7.1.1. Execution
C-c *(org-table-recalculate) apply column formulas left to right, and field/range formulas in the current row.C-u C-c *orC-u C-c C-crecomputer the entire table, line by line, with the lines before the first hline is ignored.C-u C-u C-c *orC-u C-u C-c C-citeratatively recompute the entire table until no changes occur.org-table-recalculate-buffer-tablesC-c <=>edit or create formula at the current cell.
4.2.7.1.2. Field Reference
- Row
@0Current Row@1Absolute,@+1Relative,@<@>@>>>Relative to the top/bottom@IIAbsolute hline,@+I@-IIRelative hline,@II+2Relative dataline relative to the absolute hline
- Column
$0Current Column$1Absolute,$-1Relative,$>Relative to the left/right
- Range
$1..$3@-1$-2..@-1@I..II(@I..@II)
- Coordinate
@#,$#row or column number of the field for
4.2.7.1.3. Syntax
- The calc expression is directly allowed.
if(COND, IF_TRUE, IF_FALSE)string(STR)vsum(RANGE)vmean(RANGE)
- The Emacs lisp can be used. The expression needs to be quoted.
;Nat the end of an expression let emacs treats the result as a numerical value.
remote(TBL_NAME, REF)
4.2.7.2. Features
- The content in the first column can create a special row
!name definition of columns^,_name definition of fields in the row above (or below)#make the row recalculate automatically*make the row selected for global recalculation/the row is not exported
- Any one of the fields in a column can be used to specify the width
and alignment of the column.
<N>fixed width ofN,with the ability to be expanded withC-c TAB.<r>,<c>,<l>to align the contents<rN>is also allowed
4.2.8. Task Management
S-<rightarrow>,S-<leftarrow>to change the TODO status of a heading.C-c ,set or remove priorityC-c C-sschedule a heading,C-c C-dset a deadline- The datetime is delimited with
<>or[]. S-<arrow>within the brackets alters the time.
- The datetime is delimited with
[/]at the end of the parent heading indicate the number of completed tasks- Clock
C-c C-x TAB(org-clock-in) log a starting time of a headingC-c C-x C-o(org-clock-out) the ending timeorg-clock-reportsummerizes and accuulate the clocks- Analyze Your Time with Org Mode — Org Mode Clocktables — Straightforward Emac…
4.2.9. Dot
- The Graphviz language
- It generates graphs
title:type:(2d|3d|radar|grid)org-plot/preset-plot-typescustomize
with:min:max:labels:set:
Plot the table with <C-c> " g or <M-x> org-plot/gnuplot
4.2.10. Org Agenda
C-c [(org-agenda-file-to-front) adds current file toorg-agenda-files,C-c ]removes current file.
4.2.10.1. Todo
C-c C-t(org-todo), orS-<left>,S-<right>rotate the state of TODOC-u C-c C-trecord timestamp and a noteC-u N C-c C-tchanges toNth state.org-todo-keywordscan be configured. See Tracking TODO state changes (The Org Manual)- Format:
(<fast access key><entering log>[/<leaving log>]) - The fast access key becomes available after
C-c C-t !log timestamp,@log note and timestamp- the leaving log only works when the target keywords does not have logging enabled.
|within the sequence indicates that the keywords after it are DONE state.- The logging is enabled when the destination is set by the
org-log-into-drawervariable.
- Format:
[ / ]can be added at the end of a TODO heading to count the task done.C-c C-c(org-toggle-checkbox)C-c ,(org-priority),S-<up>,S-<down>to change priorit
S-M-RET(org-insert-todo-heading)- Schedule and Deadline
C-c C-sto schedule a heading.C-c C-dto set a deadline<DATETIME REPEATER WARNING>date can be repeated with+N[ymwdh], and warned with-N[ymwdh].+is for repeat after done,++for repeat periodically.
habitmodule has to be enabled inorg-modulesto use:STYLE: habit.
4.2.10.2. Agenda View
g D(org-agenda-view-mode-dispatch) select the view formatAadd agendas to viewDtoggle diaryg j,g knext, previous itemg dgoto date*mark allU,M, unmark alluundo,rredoQquitaadd note to an agendamtoggle markxbulk action
S-<left>,S-<right>,H,Lshift the scheduled datepchange date with prompt
S-<up>,S-<down>,J,Kshift the priority
4.2.11. Org Roam
4.2.11.1. Template
- The templates are defined in the variable
org-roam-capture-templates.- A template looks like
(KEY NAME TYPE TEMPLATE SCRIPT OPTION)- Template:
%?within the template indicate the position of the point. It can also be(file FILEPATH)to externally load the content.%^NAMEcan be used to prompt the user.
- Script:
:if-newand(file+head FILENAME HEADER)specify the first time header creation${slug},${title}can be used as a placeholder.
- Template:
- A template looks like
- The files are hashed into SQL database, stored in
~/.emacs.d/org-roam.db.org-roam-db-syncandorg-roam-db-autosync-mode
4.2.11.2. Keybindings
C-c n ddaily note for todayC-c n ccapture nodeC-c n iinsert node
4.2.12. Org Drill
- The org topic with
:drill:tag will be used as a drill item. - See org-drill.el - flashcards and spaced repetition for org-mode
4.2.13. Org Cliplink
Automatic insertion of title of the hyperlink
It provides org-cliplink and org-cliplink-capture, which is recommended to be bound to <C-x> p i.
See GitHub - rexim/org-cliplink: Insert org-mode links from clipboard
4.2.14. org-special-block-extras
Enable the definition of custom blocks and links
4.2.15. Export and Publish
C-c C-eto export.- Use
org-publish-project-alistto publish project-wise.
4.3. eshell builtin
Eamcs Shell
- There is
shellandeshell.shellis the terminal calleddumbthat runs standard shells, andeshellis the shell and a terminal on its own. eshellcan run both commands and Elisp functions.>>> #<buffer BUFFER>to pipe the output into a buffer.C-c C-n,C-c C-pmove to next or previous prompt- It has two different parser: one for Elisp and one for shell script.
$(...)for Elisp parser, and${...}for shell script parser.- Some of the keywords has different syntax than the usual shell script.
- The precedence is: alias,
eshell/function, lisp function, executable.
- Runs the commands in
eshell-visual-commands, in a special buffer.
4.3.1. Globbing Filter
*(...)
.file,/directory^not:modifiers:Uuppercase
4.4. eww builtin
Web Browser
It does not run javascript, and only shows the text from the HTML file.
4.5. calendar and diary builtin
Diary is a simple way of remembering a data. Calendar integrates diary.
- The diary is stored in
~/.emacs.d/diaryfile. which contains list of date-description pairs.i dto create new diary entry
4.6. mpc
mpd client
The player is controlled by commands.
mpc-play,mpc-pause,mpc-toggle-play,mpc-stop,mpc-play-at-pointmpc-playlist, …
4.7. ses builtin
Simple Emacs Spreadsheet
It is enabled in .ses files.
4.8. ispell builtin
Spellchecking.
- It uses
ispellby default. Change it tohunspellby settingispell-program-name rreplace,aaccept for this session,iinsert to dictionary,uuncapitalize and inser to dictionary,SPCskipispell-chage-dictionaryfor other language.flyspell-modehighlights the misspelled words.M-$check the spelling at pointC-;to correct word in placeC-c $to correct word interactively
ispell-bufferwill check the buffer for spelling.
4.8.1. Configuration
- personal dictionary is stored in
~/.hunspell_DICT.- noun:
/10(with final consonant),/25(without final)
- noun:
4.9. Amusements
dunnettext-based adventuresnake,tetris,pong,solitaire,gomoku,hanoideciphersolve the monoalphabetic substitution ciphermorse-region,unmorse-regionnato-region,denato-regionzonedoodles with buffer when idle.dissociated-pressscramble the text in the current buffer and puts them in*Dissociation*butterflyfrom the internet joke.doctortherapist Eliza
5. Configuration
- Uses Lisp for the config file.
~/.emacs,~/.emacs.d/init.el,~/.config/emacs/init.el
5.1. Compilation
- The compilation options and available features for Emacs are given in
system-configuration-optionsandsystem-configuration-features
5.2. Custom builtin
- 'Easy Customization Interface' within the editor.
- Variables and setting can be customized through this interface,
and saved to the
~/.emacs - They are mostly accessible via
M-x customize-* - Basic motions are possible:
n,p,q
5.3. use-package
- Init files are run before any of the package loads?, therefore
add-hookis used to run commands after the packages load, with(add-hook 'HOOK_TIME #'HOOK_COMMAND).after_init_hookprog-mode-hook
image-mode-hook
- Use package simply overrides the Customization, without modifying it.
use-packagemacro can configure the package.:ensureinstall the package form the repository if not installed.:prefacerun before anything else. This is for defining functions and variables.:ifconditional statement:load-pathcustom load path for the package. Not usually used.:afterload after.:all,:anycan be used alongside.:defer t:ensure t:hook (((MODE*) . HOOK)*):bind ((KEY . FUN)*)
:bind-keymapthe prefix for the keymap:mode (REGEXP . MODE):initrun now:configrun when the package loads:custom (CUSTOM_VAR VAL "optional documentation")*customize package custom variables:requiresdoes not load the package unless the requirement is fulfilled.- Keywords — use-package for more
use-package-autoload-keymapbind a keymap
5.4. Initialization
5.4.1. Early Init
- By default
~/.emacs.d/early-init.elis the early init file, and it runs before any of the packages load and the window is set up. (setenv "VAR" "VALUE")set the environment variable(setq native-comp-deferred-compilation nil)prevent native compilation
5.4.2. Init
~/.emacsis used traditionally, but~/.config/emacs/init.eland~/.emacs.d/init.elcan be used.initial-scratch-messageinhibit-startup-screeninitial-buffer-choicesets the file as a startup bufferemacs-startup-hookorwindow-setup-hookcan also be hooked to any function- There's package called
dashboardthat modifies the startup screen into displaying recent files, org agendas, bookmarks and more. default-frame-alistsets the properties for any frames.- The implicit default might not be applied to
initial-buffer-choice. This option can be used in that case to set the properties explicitly.
- The implicit default might not be applied to
- See Startup Summary (GNU Emacs Lisp Reference Manual)
5.5. Theme
- the emacs default themes are stored in
/usr/share/emacs/NN.N/etc/themes/ - The default directory for user themes is
~/.emacs.d/ - Theme can be selected from
customize-themes, orload-themeusing lisp. - Emacs Themes Lookup
5.6. Input Method
Emacs has its own multilingual support. It translates the Latin characters into specified language.
default-input-methodit specify the input method used whenC-\(toggle-input-method) is called.korean-hangul,japaneselatin-prefixgerman-postfix- It allows sz ß, ae ä, ue ü, oe ö.
compose- X like compose functionality!
C-x 8works similarly, though much more limited
See Input Methods (GNU Emacs Manual)
set-input-methodselect a new input methodC-x \(activate-transient-input-method) insert a single characterC-h C-\(describe-input-method)
5.7. Keybinding
define-keythe low level functionglobal-set-key,local-set-keylegacy interactive key definition- It expects the KEY to be a key description
(kbd "...")or[...]
- It expects the KEY to be a key description
keymap-set,keymap-global-set,keymap-local-setkeymap definition- It expects the KEY to pass
key-valid-ptest
- It expects the KEY to pass
bind-keythe external function abind-keypackage
5.8. Font
(set-fontset-font FONTSET CHARACTERS FONT-SPEC &optional FRAME ADD)- It does not work on server startup. It should be hooks to a
server-after-make-frame-hook - Manipulate a fontset, with
FONTSETbeingtmeaning thefontset-default. CHARACTERSspecify on which set of characters the fonts is applied.script-representative-charsandchar-script-tablecontains the symbols for known scripts.
FONT-SPECspecifies which font to use for the given set of characters.ADDcan be eithernil,'prependor'appendin terms of the precedence list
- It does not work on server startup. It should be hooks to a
set-frame-fontandset-face-attributecan also be used.(font-spec SPECS):name,:family,:size, and others can be specified
(font . FONTNAME)is also seenC-x =show the character at point in the minibuffer.C-u C-x =show details about the character and font being used at point.
See Font Selection (GNU Emacs Lisp Reference Manual), Fonts (GNU Emacs Manual), Modifying Fontsets (GNU Emacs Manual)
6. Packages
- Packages are managed by the built-in package
package.(package-initialize)needs to run first to be able to userequire. It is run automatically before.emacssince Eamcs 27.- But it doesn't seems like it runs
package-refresh-contentsalso.
- Add MELPA repository by modifying
package-archiveswithM-x customize-option package-vc-install REPO-DESCcan be used to install from the source.REPO-DESCcan be the repository url, or a list that describe the package:'(org :url URL).
(package-delete PKG-DESC FORCE NOSAVE)PKG-DESCis stored in thepkg-alist, which then can be extracted withcdrofassoc.
6.1. LaTeX
6.1.1. AUCTeX
auctex,auctex-latexmk,auctex-lua- Set
TeX-enginetoXeTeXorLuaTeXfor ttf fonts. <C-c> <C-c>run command<C-c> <C-v>view pdf<C-c> <C-p> <C-b>preview bufferprettify-symbols-modedisplay symbols inlinecdlatex-modequick input of LaTeXoutline-modethe contraction of sections
6.1.2. CDLaTeX
LaTeX input method
TABali,ali*,equ,fg,fr,sq,beg, …M-x cdlatex-command-helpshows the full list
`symbols'styling^,_superscript and subscript
cdlatex-command-alistcdlatex-env-alistcdlatex-math-symbol-alistcdlatex-tabis used to hook other commands toTABwhen cdlatex is enabled.- GitHub - cdominik/cdlatex: Fast input methods to enter LaTeX environments and…
6.1.3. RefTeX
It is Emacs builtin, that recognizes the multi-file bibliography. It is used by CDLaTeX when inserting citation.
reftex-parse-all- It is run when a file is first opened.
- It needs to be manually run for the changes to be recognized.
C-c [, (reftex-citation) insert citation from the bib database file specified in\addbibresource{}and the default bib database.C-c ), (reftex-reference) add reference among the current file.
6.2. elpy
- No longer an active project. Replace with language servers.
Emacs Python development environment
It sets up a virtual environment for each projects in the background and communicate through RPC.
The virtual environment is installed in .emacs.d/elpy/rpc-venv/ by default.
It completes using company.
elpy-rpc-reinstall-virtualenvsolved the sentinel error.
6.2.1. Features
- Run
(elpy-enable)to enable all the modules. <M-TAB>elpy-company-backendprovide completion suggestions at point
6.2.2. Related
python: python interpreterjedi: It autocompletes the python script. It also uses virtual environment and communicate through RPC viaepc.company-jediandjediare the frontends ofjedi-coreforcompanyandauto-completionrespectively.jedi:install-serverto first set the virtual environment up.jedi:get-in-function-calldisplays the function signature at the minibuffer.jedi:show-docis also there.
flymakeandflycheckis available for Python.- Python - WikEmacs
6.3. lsp-mode
LSP Mode - Language Server Protocol support for Emacs - LSP Mode - LSP suppor…
It supports all kinds of languages and their servers. The servers are external programs that needs to be installed separately.
lsp-uiprovides the sideline, childframe, and others.
6.3.1. Language Servers
cclsC/C++/Objective C- Additional
cclspackage required - Disable it with
(setq lsp-disabled-clients '(ccls)).
- Additional
clangdC++- Builtin
.clangdorcompile_commands.jsonfrom the build system is required to figure out the compiler options.
python-lsp-server- Builtin
pyright- Additional
lsp-pyrightrequired - The successor of Microsoft Python server
- Additional
(lsp-register-client CLIENT)is used to register a language server for a certain mode or file extension.- Many are registered by default. But an obscure one has to be registered manually.
(make-lsp-client ...)is used to create theCLIENTobject of the typelsp--client.:new-connection CONNECTIONrun and connect to the language server.:major-modes MODEset the major mode in which language server starts.:server-id IDID can be anything of the form'id.
6.3.2. dap-mode
Debug Adapter Protocol
6.3.3. Configuration
6.4. Eglot builtin
- Builtin language server protocol client
- It is more barebone compared to LSP mode.
6.5. ein
Emacs IPython Notebook
ein:runein:stopto start and stop the jupyter notebook server.C-c C-cEvaluate current cell.C-c C-b,C-c C-aAdd a cell below or above
6.5.1. Related
jupyterIt controls the Jupyter server.
6.6. eimp
Emacs Image Manipulation Package
It enables simple image processing within Emacs.
6.7. pdf-tools
It replaces the builtin doc-view for the case of PDF files, with almost the same keybidings.
pdf-tools-installon startup to enable it on startup.n,pnext, previous page,C-n,C-pnext, previous line or page,SPCscroll+,-,0enlarge, shrink, reset scale,H,W,Pfit height, width, pagemmark to a register,'jump to registeroshow outlineTABtoggle children,RETfollow link,C-o,SPCdisplay linkashow all sublevel,Qhide all sublevels,dshow, hide subtreef,bforward, backward same level,uup headingoreturn to the pdf,qquit- Outline mode also works
Flink action performlorB,rorNhistory backward, forward- GitHub - vedang/pdf-tools: Emacs support library for PDF files.
6.8. corfu
Newer and lighter completion system.
It utilizes the emacs completion system, compared to company's own system.
6.9. Evil
Vi emulation
- It is customizable under Editing > Emulations > Evil
- Viper is the default Vi emulation, but it is more primitive with
less keybindings and less commands.
- No
qmacro, no:registerand:jumps,ciorca.
- No
- It is required to
(require 'evil)from the.emacsto properly set it up.Customdoes not properly enableevil-mode - The initial evil mode for a major mode can be customized by the state mode variables
or
evil-set-initial-statefunction in the init file.
6.9.1. Keybindings
?in the middle of key sequence to show helps
6.9.1.1. <N> Normal Mode
W,Bmove a WORD, which means space separated words.- WORD, word, line, paragraph and others are collectively known as text objects.
Lbottom of the screen,Htop of the screenuundo,C-rredog ffind file at point,g xopen immediatelyg qfill region (automatically add line breaks)g q qfill line
Jjoin the next line at the end of the current line.=auto indent,>,<indent and outdent,Sstart a line with auto indent~toggle case of a characterg ~toggle case of a region given by the motion,g ~ ~toggle case of a line.
iselect in,aselect around:b,(,)parenthesisB,{,}bracettagpparagraph
/regexp can be used in the query\< \>match exact word*search word at pointc g nchange next match- This requires the
evil-search-moduleto beevil-search.
- This requires the
mmark current position,'goto the marked line,`goto the marked position- The marks are added to the jumplist.
- Jumplist
- Show with
:jumps C-SPCcreates the jump point as well
- Show with
[ ',]'previous and next mark line,[`,]`previous and next mark[(,])previous open and next close paranthesis,[{,]}previous open and next close brace[[,]]backward section begin and forward section end,[],][backward section end and forward section begin[s,]sprevious and next flyspell error!shell command,!!shell command again on the same region (:.!)zscrollbthis line to the bottom,tthis line to the top,zthis line to the center,+bottom line to top,^top line to bottomlscroll right,hscroll left.
zfoldcclose one,mclose all,oopen one,ropen all,Oopen subtree,atoggle
C-yscroll down a line,C-escroll up a line.g dgo to definitionQ(Vim only) enterex(ed extended) modeZQquit without savingZsave and quit
6.9.1.2. <V> Visual Mode
vvisual mode,Vvisual line mode<Vl>,C-vvisual block mode<Vb>- Line based commands such as
I,Acan be entered after a region is selected. g vselect the previous selected region in visual modeoto select in the other direction'<,'>indicates a line in a selected region.!can be called on the region, using it as the standard input.
6.9.1.3. <O> command argument
- most of the motion keys still words
z,Zthe two characterevil-sniper
6.9.1.4. <I> Insert Mode
C-rinsert from a register=put the result of simple calculator
C-wdelete a word backward,C-hdelete a characterC-orun a normal mode commandC-p,C-ncomplete from previous or next textC-xCompletion mode (only in Vim)C-]tag completion from the ctagsC-ffile completionC-p,C-ncontext-aware local completion from previous or next textC-lcontext-aware line completioncompletevariable is used to determine where to look for completion
C-vinsert special characters, such as control characters.
6.9.1.5. <M> motion mode
- It allows the other program to temporarily override the keybindings.
- But some are reserved
hjkltfwb<C-f><C-b><C-u><C-d><RET>{}()=movement, =/?nNsearch,123...numbers,vvisual mode<C-]>visit the tag under the cursor[]?
6.9.1.6. <E> Emacs Mode
- Every keybindings are removed except
<C-z>which toggles the Emacs mode. - It can be escaped from the other modes by using the escape
character
\.\is one-time,<C-z>is persistent. - Numbers are bound to simply
<C-u> [123...]- Emacs provide
<ESC> 1and<M-1>to function the same.
- Emacs provide
6.9.1.7. Registers "
"the last deleted, yanked, or secondary system copied.the last manual insert+secondary system clipboard*primary system clipboard (highlighted text)-last deleted text- it is also stored in
"
- it is also stored in
:the last vim command%current filename=simple calculator0last yanked text1…9stores the last nine (non-unique) entires that was stored in", with the latest unique one being1.
6.9.2. Commands :
- Address insert
/REGEX/select a line containing the regex.
e[dit] FILEopen filer[ead] FILEinsert the content of the filenorm[al]escape to normal mode programmaticallym[ove]±Nab[brev]create an auto-expanding abbreviation.!COMMexecute shell command
6.9.2.1. Window Commands :, C-w
Creation
new,nnew windowsp[lit],ssplit horizontallyvs[plit],vsplit vertically
Modification
- ,
[rR]rotate down or right / up or left - ,
xexchange with the next - ,
=equal width and height res[ize] ±N,[+-]change heightvert[ical] res[ize],[<>]change width
Deletion
clo[se][!],cclose the file if it is not modified, or hide the windowq[uit][!],qclose the fileon[ly][!]close windows except only the current one- ,
[jkhl<arrows>]move or create
6.9.3. External Keybindings
- Info Page
pnprevious/next nodeuupdthe directory nodesregexp searchmmenu in current nodeisearch in the index of current node. Leave empty to show all
- Buffer Menu
- Entered by
<M-x> buffer-menuor<C-x> <C-b> <RET>fselect the buffer in placeoopen in another window,<C-o>and not focus1select in full-frame window2select it as one window of the two-window frame
dsuflag for deletion/saving, remove flags(unmark)xperform the deletion and saving as flaggedUremove all flags from all linesmmark to be displayed in another window,vopens them at once with the current.the flag is for the previous buffer that opened buffer menu
~mark as unmodified%toggle read-onlyqquit
- Entered by
(add-hook 'evil-local-mode-hook 'turn-on-undo-tree-mode)
6.9.4. Plugins
6.9.4.1. evil-numbers
- it enables the
C-aC-xinline number manipulation in Vim. evil-numbers/inc-at-pt,evil-numbers/dec-at-ptis provided.
6.9.4.2. evil-surround
cs<old delimiter><new delimiter>,ds<old delimiter>,ys<motion><new delimiter>to surround.S<new delimiter>in visual mode.tcan represent a HTML tag as a delimiter.- Open delimiters for spaced delimiter, and close delimiter for tight delimiter.
evil-embrace for custom surrounding pairs.
6.9.4.3. evil-leader
evil-leader/set-leader,evil-leader/set-keyto customize- The
global-evil-leader-modeneeds to be enabled beforeevil-mode.
6.9.4.4. evil-snipe
evil-snipe-override-modeoverridef,tso that it highlightsevil-snipe-modeadd 2-character searchsandx- It is
zandx(exclusive) in the operator state, the small cursor state that waits for the motion.
- It is
6.9.4.5. evil-tex
- it provides additional textobjects for TeX
ccommandeenvironmentmmath,Mdisplay mathdmath delimiterssection;CDLaTeX accent,^superscript,_subscriptTtable cellqsingle quote,Qdouble quote
mttoggle things[[,]]section jumping- GitHub - iyefrat/evil-tex: Some evil oriented additions to latex document edi…
6.9.4.6. evil-org
gh,gj,gk,glnavigate between elementsvaeselect and element,vaRselect a subtreeM-RETinsert heading,TAB,g TABfold/unfoldM-h,<<promote a headingM-l,>>demote a headingM-S-h,M-S-l,<aR,>aR,M-k,M-jmove subtree(,), previous, next table cell,{,}beginning, end of tablevaeselect a cell,vaEselect row,varselect table- GitHub - Somelauw/evil-org-mode: Supplemental evil-mode keybindings to emacs …
6.9.4.7. evil-fringe-mode
Display the markers in the fringe.
6.10. Magit
Git user interface
6.10.1. Commands
ccommitsstagePpush
6.10.2. Authentication
The user field is filled by the git itself.
Add username = <username> in the [credential] section of your git config.
magit-process-find-password-functionsfill password automatically with these functions. -magit-process-password-auth-sourceis provided out of the box.
Git can manage password by itself. In that case you do not need magit authentication.
6.11. Autotype
- abbrev.el: Abbreviation expansion, builtin
- expand.el: Abbreviation expansion, builtin
- skeleton.el: Lisp syntax for templates, builtin
- tempo.el: Lisp syntax for templates, builtin
- skempo.el:
- srecode.el: CEDET template manager and code generator, builtin
- aas.el: Auto activating snippets
- cdlatex.el: Fast LaTeX insertion
- laas.el: Latex auto activating snippets
- muban.el: Lightweight template expansion
- placeholder.el: Treat buffers as templates
- tempo-abbrev.el: Abbrev integration for Tempo
- snippet.el: Original snippet mode, with inline expansion (from EmacsWiki?)
- tempo-snippets.el: Interface like snippet.el for Tempo
- yasnippet.el: Template system inspired by Textmate snippets
- templatel.el: Jinja2 subset
- amno1/lite:
- tempel: Template package which uses the syntax of the Emacs Tempo library.
6.11.1. Abbrev builtin
Eamcs builtin
6.11.2. Skeleton
Emacs builtin
6.11.3. Yasnippet
Yet Another Snippet
yas-snippet-dirspecifies the location of the snippets, with~/.emacs.d/snippets/being the user snippets.- Snippets in a directory named with a specific mode is only activated in that mode.
- The directories are shadowed by others.
C-c & C-nto define a new snippetC-c & C-sto insert snippet- LaTeX snippets with Yasnippet & Auto Activating Snippets - YouTube useful?
6.11.3.1. Snippet Format
$0the final point position.$1, …,$9the tab-stoppable fields{$n:DEFAULT_VALUE}set default$nmirror: Use the same number again to mirror the field.{$n:$(LISP(yas-text))}mirror with transformation: the value of the fieldnwhich is represented byyas-textis transformed with Lisp expression.
{$n:DEFAULT_VALUE$(LISP(yas-text))}field with transformation: the inserted value is automatically transformed with given Lisp expression.{$n:$$(LISP(yas-text))}is used when there's no default value.
`LISP`is run as soon as the snippet is expanded, and the result is inserted.- Yet another snippet extension
6.11.3.2. yasnippet-snippets
yasnippet-snippets and other packages contain the snippets in yasnippet-snippets-dir for yasnippet to use.
6.12. Completion
6.12.1. Frontend
They provide the completion candidates through completing-read-function
6.12.1.1. Icomplete builtin
Suggest the completion inline within minibuffer.
6.12.1.2. Ido builtin
Interactive do
Suggest the completion inline within minibuffer.
6.12.1.3. Ivy
It shows the completion candidates in the minibuffer vertically, similar to Vertico.
6.12.2. company
It is newer compared to auto-completion.
- Modular architecture
<C-g>to stop suggestion.
6.12.2.1. Modules
company-jedi,company-auctex,company-bibtex,company-lua
6.12.2.2. Configuration
company-minimum-prefix-length=(Option): The length of string to activate the completion. default to =3.company-idle-delay=(Option): The reaction time. default to =0.3?company-frontends(Option): The UI part- Default to
(company-pseudo-tooltip-unless-just-one-frontend company-echo-metadata-frontend company-preview-if-just-one-frontend)(List of Functions)- Use
(setq VAR '(LIST))to set it
- Use
- tooltip: inline popup
(setq company-format-margin-function #'{company-dot-icons-margin|company-text-icons-margin|company-vscode-{light|dark}-margin})#'is used to quote a function.company-vscode-{light|dark}-margin(Function) uses the VSCode icons in the graphical interface only, showing nothing in the terminal interface.
- preview: The inline suggestion
- echo: Mini buffer suggestion
- Default to
company-backends(Option): The completion part(company-bbdb company-semantic company-cmake company-capf company-clang company-files (company-dabbrev-code company-gtags company-etags company-keywords) company-oddmuse company-dabbrev)
company-global-modes(Option): Major modes in which company modes is enabled byglobal-company-mode(Command).
6.13. Interface
6.13.1. Consult
Simple navigation system, that integrates the native functionalities.
consult-bufferit is multi-sourced searchconsult-outlinesearch through the headingsconsult-org-heading
consult-linenarrowing linesconsult-imenusearch through flattenedimenu. It lists the identifiers inprog-mode.consult-grep#TEXT#FILTER TEXTtheTEXTis searched if the file includesFILTER TEXT.
6.13.2. Embark
The minibuffer action within Consult
C-.in minibufferkkill buffer
6.13.3. Orderless
Additional completion-style
- The default completion starts looking from the start, or from the middle if it starts with a special characters. But this style allows find in the middle
6.13.4. helm
Incremental narrowing for basically everything.
Prefix C-x c
M-x(helm-M-x) the fancyM-x. It is rebound toM-x/(helm-find) find the entire file system withfindf(helm-multi-files) search files and buffers at the same timea(helm-apropos) find any command, function, variable, or facei(helm-imenu) menu: search outlines inorgl(helm-locate) use locate command to find files.m(helm-man-woman) search through man pages.o(helm-outline) show the outlineC-x C-f(helm-find-files)C-x C-b(helm-buffers-list)C-c f(helm-recentf) therecentf-openis remapped tohelm-mode-recentf-openinhelm-modeC-c g(helm-google-suggest) search on Google
See Helm | Emacs incremental completion and selection narrowing framework
Navigation system
6.13.7. Vertico
It displays the completion under the minibuffer vertically.
- PGTK might not work with Vertico, where the input events drops and vertico does not update.
vertico-indexed-mode- Enable the
C-u N RETto select theNth entry.
- Enable the
6.13.8. Marginalia
It displays description or type of the item beside the minibuffer entry.
6.13.9. Casual
It uses transient to show the menu(tmenu).
casual-calc is opened with <C-o>
6.13.10. which-key
Show the list of available keybindings
6.13.11. Treemacs
treemacs-modeadded toaw-ignored-buffersby default.- Set
aw-ignore-ontonilto disable this behavior.
- Set
- Set
treemacs-hide-dot-git-directortonilin order to see.git. Ppeek mode that previews the documents.ddelete a file,ccopy a file,mmove a file,Rrename a file,Qkill bufferoopencand close treemacs,ono split,h, =vin splitted window,xexternal applicationaawith ace window selection,a h,a vwith ace windoe split
ccreateddirectory,ffile
M-hmove up or collapse,M-lsame asRETM-mbulk operation
Treemacs has workspaces which can contain multiple projects. Project can be a plain directory or a version controlled directory.
M-L,M-Hchange the project root directory.C-c C-wWorkspace Prefixacreate,dremove,sswitch,eedit the~/.emacs.d/.cache/treemacs-persistdirectly.fset fallback workspace (the default)
C-c C-pProject Prefixaadd,dremove,rrename
- Related:
dired-subtreeanddired-sidebar,dirtree,neotree,sidebar. Among which dired-sidebar seems promising.
6.13.12. Hydra
(defhydra NAME (KEYMAP KEY [PROPERTIES]) DESC BODY...)- The body contains:
(KEY FUNCTION [PROPERTIES])- Function is not quoted
- If the
FUNCTIONis set tonil, it exits the hydra.
- The
KEYMAPandKEYcan benilor omitted. - GitHub - abo-abo/hydra: make Emacs bindings that stick around
- The body contains:
6.14. Project
6.14.1. project builtin
Emacs builtin It recognizes version controlled folders and EDE projects.
6.14.2. Projectile
Project is a folder containing specific file.
- VCS marker
pom.xml,Gemfile- It can be extended
6.15. Music
6.15.1. emms
Emacs Multimedia System
The add function and browser window is for Emacs exclusively. It tells the player through various backends within emms-player-list,
one of which is emms-player-mpd.
emms-player-mpd-connectneeds to be called first.- For the case of
mpdthe songs has to be within the mpd database, making new songs unable to play, unless the database is updated separately, either throughmpc updateoremms-player-mpd-update. emms-player-spotifycan be installed separately, which controls the local spotify app.emms-allenables various features.
See The Emms Manual, mpd
6.15.1.1. Related
scdlsoundcloud download- Uses the OAuth cookie stored within the browser
spotify-dlspotify download- Use the Client ID and Client Secret issued from the Spotify for Developers.
6.15.2. spotify
It controls the local Spotify app through D-Bus
6.15.3. smudge
Control Spotify using App API. It provides more complete functionalities.
Prefix C-c .
M-pplay/pauseM-b,M-fprevious and next trackM-s,M-rshuffle and repeat controlpplaylistffeatured,mmy,ssearch,ccreate
ttrackrrecent,ssearch
vvolumeu,d,mup and down and mute
ddevice- Buffer
M-RETplay nowkadd to the queuegreload
global-smudge-remote-modeenables the mode line
See GitHub - danielfm/smudge: Control the Spotify app from within Emacs.
6.16. Window
6.16.1. windmove builtin
S-<arrow>change focus to different window
6.16.2. ace-window
M-o(ace-window)mswap,Mmove (the buffer is rotated),xdelete,jselect new buffer for,nprevious windowvvertical split,bhorizontal split,omaximize?help
aw-dispatch-when-more-thanvariable prevents the ace window when less than 2 windows by default.ace-window-display-modedisplay the window number in the mode line.
6.16.3. popper
- Manage window by classifying them into regular, popup windows
6.16.4. transpose-frame
;; `transpose-frame' ... Swap x-direction and y-direction ;; ;; +------------+------------+ +----------------+--------+ ;; | | B | | A | | ;; | A +------------+ | | | ;; | | C | => +--------+-------+ D | ;; +------------+------------+ | B | C | | ;; | D | | | | | ;; +-------------------------+ +--------+-------+--------+ ;; ;; `flip-frame' ... Flip vertically ;; ;; +------------+------------+ +------------+------------+ ;; | | B | | D | ;; | A +------------+ +------------+------------+ ;; | | C | => | | C | ;; +------------+------------+ | A +------------+ ;; | D | | | B | ;; +-------------------------+ +------------+------------+ ;; ;; `flop-frame' ... Flop horizontally ;; ;; +------------+------------+ +------------+------------+ ;; | | B | | B | | ;; | A +------------+ +------------+ A | ;; | | C | => | C | | ;; +------------+------------+ +------------+------------+ ;; | D | | D | ;; +-------------------------+ +-------------------------+ ;; ;; `rotate-frame' ... Rotate 180 degrees ;; ;; +------------+------------+ +-------------------------+ ;; | | B | | D | ;; | A +------------+ +------------+------------+ ;; | | C | => | C | | ;; +------------+------------+ +------------+ A | ;; | D | | B | | ;; +-------------------------+ +------------+------------+ ;; ;; `rotate-frame-clockwise' ... Rotate 90 degrees clockwise ;; ;; +------------+------------+ +-------+-----------------+ ;; | | B | | | A | ;; | A +------------+ | | | ;; | | C | => | D +--------+--------+ ;; +------------+------------+ | | B | C | ;; | D | | | | | ;; +-------------------------+ +-------+--------+--------+ ;; ;; `rotate-frame-anticlockwise' ... Rotate 90 degrees anti-clockwise ;; ;; +------------+------------+ +--------+--------+-------+ ;; | | B | | B | C | | ;; | A +------------+ | | | | ;; | | C | => +--------+--------+ D | ;; +------------+------------+ | A | | ;; | D | | | | ;; +-------------------------+ +-----------------+-------+ ;;
6.17. undo-tree
<C-/><C-_>: undo<C-?><M-_>: redoundo-tree-switch-branch<C-x> uundo-tree-visualizer
6.18. multiple-cursors
6.19. Iedit
C-;duringisearchenters the Iedit mode in which all the occurences are modified simultaneously.M-Ito restrict to current lineM-{andM-}to expand the region
6.20. keycast
Provide keycast-mode-line-mode, keycast-tab-bar-mode, keycast-header-line-mode which shows the keypresses.
6.21. diminish
Hide the mode indicator for a minor mode
6.22. TRAMP builtin
Transparent Remote Access, Multiple Protocol
Edit remote files transparently.
- Use
/ssh:SPEC:PATHin thefind-file(C-x C-f). - These filepaths can be used within the shell as well.
- See TRAMP 2.7.1 User Manual
6.23. gtag
Use GNU global for indexing.
Other tag system includes ctags, etags
6.24. Anki
6.24.1. anki-editor
anki-editor-modethe commands are available when this mode is enabled.anki-editor-push-notesto sync all the notes
6.24.2. org-anki
org-ankiit is does almost the same thing asanki-editor
6.25. Mail
6.25.1. smtpmail
The builtin package for sending SMTP request. SSL and TLS are both supported.
6.25.2. org-mime
org-mime-htmlizeformats the Org mail into HTML.
6.25.3. gnus
Feature rich email, Unet, and RSS client
The method to generate the feed is specified in gnus-select-method.
Additional sources can be added in gnus-secondary-select-methods.
The articles (mails) are displayed in a specified format.
The default is %U%R%z%I%(%[%4L: %-23,23f%]%) %s\n, where
%U- r marked as read
- R actually read,
%R- A anserwed (replied or made a followup)
- F forwarded
- * cached
- S saved
%zRetrieval Score Value (RSV)%Iindentation based on thread level%Lnumber of lines in the article%fthe name (header)- Top (Gnus Manual)
- Emacs: introduction to GNUS - YouTube
- Practical guide to use Gnus with Gmail · GitHub
6.25.3.1. Keybindings
DELorS-SPCprevious page,<beginning,>endSPCnext page,NandPnext/previous article,nandpnext/previous unread articlegshow article,hgo to article buffer,ssearch within the articleTABopen a maild,Dmark as read and move forward/backwardosave article,C-osave article mail!tick forward,@mark articlekkill,C-kkill same subjectccatchup and exitrreply,ffollowup,mmail in new buffer|shell command on article bufferttoggle the full mail header- Group Mode
ccatchup currentgget new news
- Article Mode
C-dnext keyword,TABnext linksorhgo to summary buffer
6.25.4. Others
rmailmu4eeasy to use email clientmuttdated clientnotmuchminimal client- Either
offlineimapormbsyncis required to fetch emails.
- Either
ebdbstores and provides the contact information through autocompletion.
6.26. shr builtin
Simple builtin HTML renderer
shr-render-buffer,shr-render-region
7. CLI
emacs--debug-initrun debug on init files-t,--terminaluse TUI-f,--funcallexecute Lisp function-l,--loadLoad Lisp code file--eval,--executeEvaluate Lisp expression-batch,--batchrun noninteractively within the terminal
emacsclient-tterminal session--alternative=use specified Eamcs server, when no server is specified and no server running new server is created.--create-frame
8. Distributions
8.1. Emacs Prelude
Enhanced Emacs with ace-window, magit, avy, crux, and other packages preinstalled.
8.2. Doom Emacs
One can choose whether to use Evil or not. It uses <space> in Evil mode and C-c if not.
Various components are available as packages.
doom-modelinedoom-thems
8.3. Spacemacs
It uses <space> as the leader key, and use mnemonic keybindings.
9. Help
<C-h> ...for helps?,<C-h>show options<C-q>quick help for basic macrosbcurrent key bindingskckey (briefly)
mcurrent modeacommands for<M-x>ddocumentationf,v,ofunction, variables, bothkill-ringis also a variable
rEmacs manualFKfor command or key sequenceiall installed manual,infoRspecific manual
PPackage description
C-hcan be entered in the middle of prefix. It shows the available keybindings.
The default value for the help message the text at point.
10. Emacs Lisp
Elisp, .el
"TAB"is^Iand"<tab>"is tab key.- It is byte complied into
.elcfile
10.1. Object
10.1.1. Symbol
Symbol is an object that represent a variable or function. quote or ' wraps the variable as a symbol.
It consists of four parts: name, value, function value, property list. They can be accessed with symbol-name, symbol-value,
symbol-function, symbol-plist respectively.
fsetsets the function value of the variable. It can be set to a raw function or a symbol as a indirection.`(... ,a ...)backquote can be used to evaluate only certain part of expression.
Dynamically bound functions expands the scope when it is not bound locally, but lexically bound variable does not.
defvarmakes the variable dynamically bound.- Lexical binding is preferred these days.
boundpchecks if a symbol is bound to a value or void.
setflikesetqbut operates on any cell and variables.(let ((var val), ...) (statement))it binds local variable, dynamically on dynamic variable, lexically on free variable.let*defines them sequencially
(defun name (arguments) "optional documentation" (interactive optional-argument-passing-info) (body))- Function that is defined interactively with
(interactive OPTION)is a command which can be bound
- Function that is defined interactively with
(setq var val var val ...)- The variable is bound to the value.
- The
qis for quoted, which means thevardoes not need to be quoted
(defvar var val "optional documentation")- It marks the variable as special, so that it is always dynamically bound.
- The variable is not overrode, and
setqcan change the value, it is seen globally - It allows doc string.
(defcustom var val "documentation" :type TYPE)it specify a variable thatcustomizecan control(define-minor-mode MODE :init-value nil :lighter INDICATOR :global nil BODY)(provide 'PACKAGE)specified in the end of the package file.
10.1.2. Type
- String
"abc", Vector[a b c]arearray - Cons Cell
- It consists of two parts
carandcdr, that can contain value or reference. CAR and CDR - Wikipedia consor.form a cons cell out of two values.listis a series of cons cell that reference the next cons cell and ends innil
- It consists of two parts
- There are various types of data, such as
#<buffer>,#<marker>,#<frame>. These are only represented in the printed representation, and not to be defined in this way. - The value can be a closure and it can be called with
funcall#'can be used to explicitly tell it to use the function value.
10.1.3. Macro and Special Form
defmacrodefines a macro that interprets expression differently, that it may not evaluate the expression.- Special form is similar to macro and it is often the language feature.
(progn EXPRESSIONS)execute the expressions in order
10.2. Functions
- List
- A list is a series of nodes
(CAR CDR) -> (CAR CDR) -> ... cdrcan also be used to store value instead of the pointer to the next node, with(cons VAR1 VAR2)or equivalently(VAR1 . VAR2).- The reader reads the list and evaluate it if it is not quoted with
(quote LIST)or equivalently'LIST
- A list is a series of nodes
(append LIST1 LIST2)produces the new concatenated list- String
(concat STR1 STR2)concatenate into one string(format FORMAT_STR VAR)
- Point
(point)return current point position(goto-char NUM)move point to the positionNUM(forward-char &optional NUM),(backward-char &optional NUM)move point(beginning-of-buffer),(end-of-buffer)move point- Common motion command, such as
(forward-word),(forward-sentence)are also available. (point-min),(point-max)return possible point position while taking narrowing into account(save-excursion ...)save the point position, and allow point motions to be contained within the scope
- Buffer
- Get/Set Buffer
(current-buffer)get the current buffe(get-buffer BUFFER-OR-NAME)get buffer by name(get-file-buffer FILENAME)get buffer by file path(get-buffer-create BUFFER-OR-NAME)get buffer while creating it when it does not exists.(set-buffer BUFFER-OR-NAME)set current buffer toBUFFER(with-current-buffer BUF ...)set the current buffer within the scope(with-temp-buffer "CONTENT" ...)create a temporary buffer with given content
- Buffer File
(buffer-file-name)the file path of the current buffer. It isnilif not applicable.(find-file-noselect FILENAME) => BUFopen a file into a buffer without displaying it
- Buffer Text
(char-after NUM)return the character at the position(thing-at-point THING &optional NO-PROPERTIES)theTHINGcan be'word,'sentence,'urland others(search-forward STRING &optional BOUND NOERROR COUNT),(search-backward STRING)move the point after/before the (first) match(buffer-substring START END)return string at the given range within current buffer(buffer-substring-no-properties START END)
(insert STR)insert at point(insert-file-contents-literally PATH)(delete-region START END)delete the text within
- Get/Set Buffer
- Command
(this-command)return the object that represent the last executed command
- External Command
(shell-command COMMAND)xdg-opencan be used to open a file externally.
- Hook
(run-hook-with-args-until-success HOOK &rest ARGS)runs hooks sequenctially until one of them returnst.
10.3. Flow Control
(if (test) (if-true) (if-false))(when (condition) (if-ture) (if-ture) ...)(unless (condition) (if-false) (if-false) ...)(cond (condition1 if-true) (condition2 if-true) ...)it is similar to theswitchin C.- Loop Facility
(loop NAME_CLAUSE(named) VARIABLE_CLAUSE(initially, finally, for, as, with) MAIN_CLAUSE(do, when, collect, append,...)(cl-loop VAR_DEFINE(for, with, ...) BODY(if, repeat, collect, append, return, ...)- Loop Facility (Common Lisp Extensions)
- common lisp - List of LOOP keywords - Stack Overflow
10.4. Byte Compilation
- A lisp file from a package is byte compiled on installation. It needs to be recompiled via
package-recompileto load the code.
10.5. Utilities
(message "message" optional-format-vars)print message to the echo area%s,%dcan be used to format the string
-pis for predicate, and-qis for quoted.
10.6. History
The original Lisp came about in 1960 by John McCarthy. It diverged into several dialect in 1970s and unified with Common Lisp in 1980s. The ANSI standard was also established in 1990s.
It was a niche programming language among industry and academia and soon got outnumbered by other languages due to its low performance and lact of libraries. Java at work, Python at academia replaced them.
The Rise & Fall of LISP - Too Good For The Rest Of the World - YouTube
11. History
Editor descended from all the way to the 1970s
- Theming mechanism was added in version 24