Emacs Lisp Cheat Sheet

From WikEmacs
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Special form

special form has its own rule for which arguments are evaluated

Special Form
Purpose Forms
Definition defconst defun defvar
Binding constructs let let* function
Conditional evaluation and cond if or
Sequential evaluation prog1 prog2 progn
Iteration while function
Syntactic extension defmacro
Quoting quote
Assignment setq setq-default
Nonlocal Exits catch condition-case unwind-protect
Save save-current-buffer save-excursion save-restriction save-window-excursion
Other interactive track-mouse with-output-to-temp-buffer

Standard Library

Number

Emacs supports two numeric data types: integers and floating point numbers

Number related function and Variable
Category Functions Variable
Integer Basics most-positive-fixnum most-negative-fixnum
Floating Point Basics logb float-e float-pi
Type Predicate Test floatp integerp numberp wholenump zerop
Comparison = eql /= < <= > >= max min abs
Conversions float truncate floor ceiling round
Arithmetic Operations 1+ 1- + - * / % mod
Rounding Operations ffloor fceiling ftruncate fround
Bitwise Operations lsh ash logand logior logxor lognot
Mathematical Functions sin cos tan asin acos atan exp log log10 expt sqrt
Random Numbers random

Character

See String section

String

A string in Emacs Lisp is an array that contains an ordered sequence of characters

String and Character related function and Variable
Category Functions Variable
Predicates for Strings stringp string-or-null-p char-or-string-p
Creating Strings make-string string substring substring-no-properties concat split-string split-string-default-separators
Modifying Strings store-substring clear-string
Comparison char-equal string= string-equal string< string-lessp compare-strings assoc-string
Conversion number-to-string string-to-number char-to-string string-to-char
Formatting Strings format
Case Conversion downcase upcase capitalize upcase-initials
The Case Table case-table-p set-standard-case-table standard-case-table current-case-table set-case-table with-case-table ascii-case-table set-case-syntax-pair set-case-syntax-delims set-case-syntax describe-buffer-case-table

List

Lists are built up from cons cells

List related function and Variable
Category Functions Variable
List-related Predicates consp atom listp nlistp null
List Elements car cdr car-safe cdr-safe pop nth nthcdr last safe-length caar cadr cadr cadr butlast nbutlast
Building Lists cons list make-list append reverse copy-tree number-sequence
List Variables push add-to-list add-to-ordered-list
Modifying Lists setcar setcdr nconc nreverse sort
Sets And Lists memq delq remq memql member delete remove member-ignore-case delete-dups
Association Lists assoc rassoc sassq rassq assoc-default copy-alist assq-delete-all rassq-delete-all
Rings make-ring ring-p ring-size ring-length ring-elements ring-copy ring-empty-p ring-ref ring-insert ring-remove ring-insert-at-beginning

Vector

Sequence

Hash Tables

Hash Tables related function and Variable
Category Functions Variable
Creating Hash make-hash-table makehash
Hash Access gethash puthash remhash clrhash maphash
Defining Hash define-hash-table-test sxhashsxhash
Other Hash hash-table-p copy-hash-table hash-table-count hash-table-test hash-table-weakness hash-table-rehash-size hash-table-rehash-threshold hash-table-size

Symbols

Symbols related function and Variable
Category Functions Variable
Predicates for symbols symbolp
Creating Symbols symbol-name make-symbol intern intern-soft obarray mapatoms unintern
Property Lists symbol-plist setplist get put plist-get plist-put lax-plist-get lax-plist-put plist-member

Minibuffer

Keymaps

File

Buffer

buffer is a lisp object containing text to be edited

Buffer related function and Variable
Category Functions Variable
Basic bufferp current-buffer set-buffer save-current-buffer with-current-buffer with-temp-buffer
Buffer Names buffer-name rename-buffer get-buffer generate-new-buffer-name
Buffer File Name buffer-file-name buffer-file-name buffer-file-truename buffer-file-number get-file-buffer find-buffer-visting set-visted-file-name list-buffers-directory
Buffer Modification buffer-modified-p set-buffer-modified-p restore-buffer-modified-p not-modified buffer-modified-tick buffer-chars-modified-tick
Buffer Modification Time verify-visited-file-modtime clear-visited-file-modtime visited-file-modtime set-visited-file-modtime ask-user-about-supersession-threat
Read-Only Buffers buffer-read-only inhibit-read-only toggle-read-only barf-if-buffer-read-only
Buffer List buffer-list other-buffer last-buffer bury-buffer unbury-buffer
Creating Buffers get-buffer-creat generate-new-buffer
Killing Buffers kill-buffer kill-buffer-query-function kill-buffer-hook buffer-offer-save buffer-save-without-query buffer-live-p
Indirect Buffers make-indirect-buffer clone-indirect-buffer buffer-base-buffer
Swapping Text Between Two Buffers buffer-swap-text
Buffer Gap gap-position gap-size

Windows

Frames

Positons

Marker

Text (unfinished)

Text is manipulated through Buffer object with point and marker.

Text related function and Variable
Category Function Variable
Near Point char-after char-before following-char preceding-char bobp eobp bolp eolp
Examining Buffer Contents buffer-substring buffer-substring-no-properties buffer-string filter-buffer-substring filter-buffer-substring-function buffer-substring-filters current-word thing-at-point
Comparing Text compare-buffer-substrings
Inserting Text insert insert-before-markers insert-char insert-buffer-substring insert-buffer-substring-no-properties
User-Level Insertion Commands insert-buffer self-insert-command newline overwrite-mode
Deleting Text erase-buffer delete-region delete-and-extract-region delete-char delete-backward-char backwar-delete-char-untabify backward-delete-char-untabify-method
User-Level Deletion Commands delete-horizontal-space delete-indentation fixup-whitespace just-one-space delete-blank-lines