Function: electric-indent-mode
electric-indent-mode is an interactive and byte-compiled function
defined in electric.el.gz.
Signature
(electric-indent-mode &optional ARG)
Documentation
Toggle on-the-fly reindentation of text lines (Electric Indent mode).
When enabled, this reindents whenever the hook electric-indent-functions
returns non-nil, or if you insert one of the "electric characters".
The electric characters normally include the newline, but can
also include other characters as needed by the major mode; see
electric-indent-chars for the actual list.
By "reindent" we mean remove any existing indentation, and then indent the line according to context and rules of the major mode.
This is a global minor mode. To toggle the mode in a single buffer,
use electric-indent-local-mode.
This is a global minor mode. If called interactively, toggle the
Electric-Indent mode mode. If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable the
mode if ARG is nil, omitted, or is a positive number. Disable the mode
if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate (default-value \=electric-indent-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
Probably introduced at or before Emacs version 24.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/electric.el.gz
;;;###autoload
(define-minor-mode electric-indent-mode
"Toggle on-the-fly reindentation of text lines (Electric Indent mode).
When enabled, this reindents whenever the hook `electric-indent-functions'
returns non-nil, or if you insert one of the \"electric characters\".
The electric characters normally include the newline, but can
also include other characters as needed by the major mode; see
`electric-indent-chars' for the actual list.
By \"reindent\" we mean remove any existing indentation, and then
indent the line according to context and rules of the major mode.
This is a global minor mode. To toggle the mode in a single buffer,
use `electric-indent-local-mode'."
:global t :group 'electricity
:initialize #'custom-initialize-after-file-load
:init-value t
(if (not electric-indent-mode)
(unless (catch 'found
(dolist (buf (buffer-list))
(with-current-buffer buf
(if electric-indent-mode (throw 'found t)))))
(remove-hook 'post-self-insert-hook
#'electric-indent-post-self-insert-function))
(add-hook 'post-self-insert-hook
#'electric-indent-post-self-insert-function
60))
;; Toggle the reindentation on actions
(electric-indent--activate-indent-actions electric-indent-mode))