Emacs: Xah Emacs Lisp Mode

By Xah Lee. Date: . Last updated: .

xah-elisp-mode is a major mode for emacs lisp.

screenshot xah elisp mode 2017 01 03
screenshot emacs lisp mode 2017 01 03


Download here: https://github.com/xahlee/xah-elisp-mode

Also on MELPA http://melpa.org/#/xah-elisp-mode [see Emacs: How to Install Packages Using ELPA, MELPA]

For any problems, file a report on github, or comment here.


  1. Syntax coloring of ALL elisp symbols documented in elisp manual, and ONLY those. If a symbol is not colored, it's either a typo or not documented in elisp manual.
  2. Symbols are colored by their technical type: function, special form, macro, command, user option, variable.
  3. Completion for function names with `ido-mode' interface for ALL symbols emacs knows (all in obarray, including loaded 3rd party packages). (press Tab after word). Ido supports flex match. That is, you can type any char that appear in the middle of symbol you are looking for (not just prefix).
  4. Command to format entire sexp expression unit. (press Tab before word.)
  5. Function param template. (press Space after function name.)
  6. 1 to 4 letters abbrevs for top 100 most used functions. e.g. “d” → expands to full template (defun …).

No dependency on third-party package. Only require bare GNU emacs.

Here's a example of syntax coloring.

(defun mark-sexp (&optional arg allow-extend)
  "Set mark ARG sexps from point..."
  (interactive "P\np")
  (cond ((and allow-extend
          (or (and (eq last-command this-command) (mark t))
          (and transient-mark-mode mark-active)))
     (setq arg (if arg (prefix-numeric-value arg)
             (if (< (mark) (point)) -1 1)))
        (goto-char (mark))
        (forward-sexp arg)
        (forward-sexp (prefix-numeric-value arg))
      nil t))))


There are 100+ abbrevs, and ~440 function templates.

Each abbrev is 1 to 4 letters. Abbrev expands to full function name, then it expands to function template of that function.

For example, here's some of the single-letter abbrevs:

type “d”, press space, it become “defun”, press space again, and it becomes

(defun ▮ ()
  (let (VAR)


here's a list of 1 letter and 2 letters abbrevs.

("c" "concat" )
("d" "defun" )
("f" "format" )
("i" "insert" )
("l" "let" )
("m" "message" )
("o" "&optional " )
("p" "point" )
("s" "setq" )
("w" "when" )

("ah" "add-hook" )
("bc" "backward-char" )
("bs" "buffer-substring" )
("bw" "backward-word" )
("ca" "char-after" )
("cb" "current-buffer" )
("cc" "condition-case" )
("cd" "copy-directory" )
("cf" "copy-file" )
("cw" "current-word" )
("dc" "delete-char" )
("dd" "delete-directory" )
("df" "delete-file" )
("dk" "define-key" )
("dr" "delete-region" )
("dv" "defvar" )
("eb" "erase-buffer" )
("fc" "forward-char" )
("ff" "find-file" )
("fl" "forward-line" )
("fw" "forward-word" )
("gb" "get-buffer" )
("gc" "goto-char" )
("kb" "kill-buffer" )
("kr" "kill-region" )
("la" "looking-at" )
("lb" "looking-back" )
("lc" "left-char" )
("mb" "match-beginning" )
("mc" "mapcar" )
("md" "make-directory" )
("me" "match-end" )
("ms" "match-string" )
("ns" "number-sequence" )
("pm" "point-min" )
("pn" "progn" )
("px" "point-max" )
("rb" "region-beginning" )
("rc" "right-char" )
("re" "region-end" )
("rf" "rename-file" )
("rm" "replace-match" )
("rq" "regexp-quote" )
("rr" "replace-regexp" )
("sb" "search-backward" )
("sc" "shell-command" )
("se" "save-excursion" )
("sf" "search-forward" )
("sm" "string-match" )
("sr" "save-restriction" )
("ss" "split-string" )
("wg" "widget-get" )
("wr" "write-region" )

Alt+x list-abbrevs to see the full list.

Support for Yasnippt, Auto-Complete, Company Mode

xah-elisp-mode is designed to not need yasnippt or company-mode.

company-mode is supported if you want to use it.

If you need help in setting up company mode, ask me.

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs


Emacs Lisp