Emacs Lisp Mode is enabled for any files ending in
.el or when editing the Emacs InitFile.
Completion is very well configured. Simply use
‘M-TAB’. Because Emacs’s SelfDocumentation is really good its possible to read up on a function or variable in HelpMode based on its DocString.
ByteCompilation is possible with
‘M-x byte-compile-file’. Unfortunately, not all of the Emacs Lisp mode features are available in the LispInteractionMode. See InferiorEmacsLispMode for an Emacs Lisp REPL.
Starting a new Emacs Lisp file with
‘M-x auto-insert’ will use SkeletonMode to give the standard format for your source code. Enabling the global minor mode AutoInsertMode can do this for you every time you start a new file.
As an example of customizing Emacs Lisp Mode, with Emacs Lisp, we will enable these features.
‘RET’reindent the current and new line.
Try these customizations by adding the following code it to your InitFile or by EvaluatingExpressions. If you are already visiting a buffer in Emacs Lisp Mode, then after evaluating this code reopen the associated file or restart the mode with
(add-hook 'emacs-lisp-mode-hook (lambda () ;; Use spaces, not tabs. (setq indent-tabs-mode nil) ;; Keep M-TAB for `completion-at-point' (define-key flyspell-mode-map "\M-\t" nil) ;; Pretty-print eval'd expressions. (define-key emacs-lisp-mode-map "\C-x\C-e" 'pp-eval-last-sexp) ;; Recompile if .elc exists. (add-hook (make-local-variable 'after-save-hook) (lambda () (byte-force-recompile default-directory))) (define-key emacs-lisp-mode-map "\r" 'reindent-then-newline-and-indent))) (add-hook 'emacs-lisp-mode-hook 'eldoc-mode) (add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode) ;; Requires Ispell
‘byte-compile-file’ instead of
‘byte-force-recompile’ above to compile regardless if the file is already compiled.
Related EmacsLisp major and minor modes:
‘debug’) – Step through code. Entry per function; using breakpoints; or upon error or quit (
‘edebug’) – Step through or trace code