Function: emacs-lisp-mode

emacs-lisp-mode is an interactive and byte-compiled function defined in elisp-mode.el.gz.

Signature

(emacs-lisp-mode)

Documentation

Major mode for editing Lisp code to run in Emacs.

- DEL (backward-delete-char-untabify) converts tabs to spaces as it moves back.
- Blank lines separate paragraphs.
- Semicolons start comments.

When editing Lisp data (as opposed to code), lisp-data-mode can be used instead.

C-M-i completion-at-point
C-M-q indent-pp-sexp
C-M-q indent-sexp
C-M-q prog-indent-sexp
C-M-x eval-defun
C-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-x C-a C-c edebug-go-mode
C-x C-a C-l edebug-where
C-x C-a C-n edebug-next-mode
C-x C-a C-s edebug-step-mode
C-x C-a RET edebug-set-initial-mode
DEL backward-delete-char-untabify
M-q prog-fill-reindent-defun

In addition to any hooks its parent mode might have run, this mode runs the hook emacs-lisp-mode-hook, as the final or penultimate step during initialization.

View in manual

Probably introduced at or before Emacs version 16.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/elisp-mode.el.gz
;;;###autoload
(define-derived-mode emacs-lisp-mode lisp-data-mode
  `("ELisp"
    (lexical-binding (:propertize "/l"
                      help-echo "Using lexical-binding mode")
                     (:propertize "/d"
                      help-echo "Using old dynamic scoping mode\n\
mouse-1: Enable lexical-binding mode"
		      face warning
		      mouse-face mode-line-highlight
                      local-map ,elisp--dynlex-modeline-map)))
  "Major mode for editing Lisp code to run in Emacs.
\\<emacs-lisp-mode-map>
- \\[backward-delete-char-untabify] converts tabs to spaces as it moves back.
- Blank lines separate paragraphs.
- Semicolons start comments.

When editing Lisp data (as opposed to code), `lisp-data-mode' can
be used instead.

\\{emacs-lisp-mode-map}"
  :group 'lisp
  (defvar project-vc-external-roots-function)
  (setcar font-lock-defaults
          '(lisp-el-font-lock-keywords
            lisp-el-font-lock-keywords-1
            lisp-el-font-lock-keywords-2))
  (setf (nth 2 font-lock-defaults) nil)
  (add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers)
  (if (boundp 'electric-pair-text-pairs)
      (setq-local electric-pair-text-pairs
                  (append '((?\` . ?\') (?\‘ . ?\’))
                          electric-pair-text-pairs))
    (add-hook 'electric-pair-mode-hook #'emacs-lisp-set-electric-text-pairs))
  (add-hook 'eldoc-documentation-functions
            #'elisp-eldoc-funcall nil t)
  (add-hook 'eldoc-documentation-functions
            #'elisp-eldoc-var-docstring nil t)
  (add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
  (setq-local project-vc-external-roots-function #'elisp-load-path-roots)
  (setq-local syntax-propertize-function #'elisp-mode-syntax-propertize)
  (add-hook 'completion-at-point-functions
            #'elisp-completion-at-point nil 'local)
  (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
  (add-hook 'flymake-diagnostic-functions
            #'elisp-flymake-byte-compile nil t)
  (add-hook 'context-menu-functions #'elisp-context-menu 10 t))