Difference between revisions of "Emacs Lisp Cheat Sheet"

From WikEmacs
Jump to: navigation, search
(Marker)
(Standard Library)
Line 30: Line 30:
  
 
==Standard Library==
 
==Standard Library==
 
+
Including function, variable, macro, option, command
 
=== Number ===
 
=== Number ===
 
Emacs supports two numeric data types: '''integers''' and '''floating point numbers'''
 
Emacs supports two numeric data types: '''integers''' and '''floating point numbers'''

Revision as of 05:18, 14 July 2012

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

Including function, variable, macro, option, command

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

Vector related function and Variable
Category Functions Variable
Vector Functions vectorp vector make-vector vconcat
Bool-vectors make-bool-vector bool-vector-p

Sequence

sequence type is the union of two other Lisp types: lists and arrays. While array has four types, all one-dimensional: strings, vectors, bool-vectors, char-tables.

Sequence related function and Variable
Category Functions Variable
Sequence Functions sequencep length elt copy-sequence
Array Functions arrayp aref aset fillarray
Char-Tables make-char-table char-table-p char-table-subtype char-table-parent set-char-table-parent char-table-extra-slot set-char-table-extra-slot char-table-range set-char-table-range map-char-table

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

A minibuffer is a special buffer that Emacs commands use to read arguments more complicated than the single numeric prefix argument.

Minibuffer related function and Variable
Category Functions Variable
Text from Minibuffer read-from-minibuffer read-string read-regexp minibuffer-allow-text-properties minibuffer-local-map read-no-blanks-input minibuffer-local-ns-map
Object from Minibuffer read-minibuffer eval-minibuffer edit-and-eval-command
Minibuffer History add-to-history history-add-new-input history-length history-delete-duplicates minibuffer-history query-replace-history file-name-history buffer-name-history regexp-history extended-command-history shell-command-history read-expression-history
Basic Completion try-completion all-completions test-completion completion-boundaries completion-ignore-case completion-regexp-list lazy-completion-table completion-in-region
Minibuffer Completion completing-read
Completion Commands minibuffer-completion-table minibuffer-completion-predicate minibuffer-completion-confirm minibuffer-confirm-exit-commands minibuffer-complete-word minibuffer-complete minibuffer-complete-and-exit minibuffer-completion-help display-completion-list completion-auto-help minibuffer-local-completion-map minibuffer-local-must-match-map minibuffer-local-filename-completion-map minibuffer-local-filename-must-match-map
High-Level Completion read-buffer read-buffer-function read-buffer-completion-ignore-case read-command read-variable read-color
Reading File Names read-file-name read-file-name-function read-file-name-completion-ignore-case read-directory-name insert-default-directory read-shell-command minibuffer-local-shell-command-map
Completion Styles completion-styles completion-styles-alist
Programmed Completion completion-table-dynamic completion-annotate-function
Yes-or-No Queries y-or-n-p y-or-n-p-with-timeout yes-or-no-p
Multiple Queries map-y-or-n-p
Reading a Password read-passwd
Minibuffer Commands exit-minibuffer self-insert-and-exit previous-history-element next-history-element previous-matching-history-element next-matching-history-element
Minibuffer Contents minibuffer-prompt minibuffer-prompt-end minibuffer-prompt-width minibuffer-contents minibuffer-contents-no-properties minibuffer-completion-contents delete-minibuffer-contents
Minibuffer Windows active-minibuffer-window minibuffer-window set-minibuffer-window window-minibuffer-p minibuffer-window-active-p
Recursive Mini minibuffer-depth enable-recursive-minibuffers
Minibuffer Miscellany minibufferp minibuffer-setup-hook minibuffer-exit-hook minibuffer-help-form minibuffer-scroll-window minibuffer-selected-window max-mini-window-height

Keymaps

File

File related function and Variable
Category Functions Variable
Visiting Files find-file find-file-literally find-file-noselect find-file-other-window find-file-read-only view-file find-file-wildcards find-file-hook find-file-not-found-functions find-file-literally create-file-buffer after-find-file
Saving Buffers save-buffer save-some-buffers write-file write-file-functions write-contents-functions before-save-hook after-save-hook file-precious-flag require-final-newline
Reading from Files insert-file-contents insert-file-contents-literally
Writing to Files append-to-file write-region with-temp-file
File Locks file-locked-p lock-buffer unlock-buffer ask-user-about-lock
Information about Files file-exists-p file-readable-p file-executable-p file-writable-p file-accessible-directory-p access-file file-ownership-preserved-p file-newer-than-file-p file-symlink-p file-directory-p file-regular-p file-truename file-chase-links file-modes file-nlinks file-attributes locate-file executable-find
Changing Files add-name-to-file rename-file copy-file make-symbolic-link delete-file set-file-modes set-default-file-modes default-file-modes read-file-modes file-modes-symbolic-to-number set-file-times
File Names file-name-directory file-name-nondirectory file-name-sans-versions file-name-extension file-name-sans-extension file-name-absolute-p file-relative-name file-name-as-directory directory-file-name abbreviate-file-name expand-file-name default-directory substitute-in-file-name make-temp-file make-temp-name temporary-file-directory small-temporary-file-directory file-name-all-completions file-name-completion completion-ignored-extensions convert-standard-filename
Contents of Directories directory-files directory-files-and-attributes file-expand-wildcards insert-directory insert-directory-program
Create/Delete Dirs make-directory copy-directory delete-directory
Magic File Names inhibit-file-name-handlers inhibit-file-name-operation find-file-name-handler file-local-copy file-remote-p unhandled-file-name-directory
Format Conversion format-alist buffer-file-format format-write-file format-find-file format-insert-file buffer-auto-save-file-format write-region-annotate-functions write-region-post-annotation-function after-insert-file-functions

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

Positions related function and Variable
Category Functions Variable
Point point point-min point-max buffer-end buffer-size
Motion goto-char forward-char backward-char forward-word

backward-word words-include-escapes inhibit-field-text-motion beginning-of-buffer end-of-buffer beginning-of-line line-beginning-position end-of-line line-end-position forward-line count-lines line-number-at-pos vertical-motion count-screen-lines move-to-window-line compute-motion forward-list backward-list up-list down-list forward-sexp backward-sexp beginning-of-defun end-of-defun defun-prompt-regexp open-paren-in-column-0-is-defun-start beginning-of-defun-function end-of-defun-function

Excursions save-excursion
Narrowing narrow-to-region narrow-to-page widen save-restriction

Marker

Marker related function and Variable
Category Functions Variable
Predicates on Markers markerp integer-or-marker-p number-or-marker-p
Creating Markers make-marker point-marker point-min-marker point-max-marker copy-marker
Information from Markers marker-position marker-buffer buffer-has-markers-at
Marker Insertion Types set-marker-insertion-type marker-insertion-type
Moving Markers set-marker move-marker
The Mark mark mark-marker set-mark push-mark pop-mark transient-mark-mode mark-even-if-inactive deactivate-mark deactivate-mark mark-active activate-mark-hook deactivate-mark-hook handle-shift-selection mark-ring mark-ring-max
The Region region-beginning region-end use-region-p

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