Function: org-indent-mode
org-indent-mode is an autoloaded, interactive and byte-compiled
function defined in org-indent.el.gz.
Signature
(org-indent-mode &optional ARG)
Documentation
When active, indent text according to outline structure.
Internally this works by adding line-prefix and wrap-prefix
properties, after each buffer modification, on the modified zone.
The process is synchronous. Though, initial indentation of buffer, which can take a few seconds on large buffers, is done during idle time.
This is a minor mode. If called interactively, toggle the Org-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 the variable org-indent-mode(var)/org-indent-mode(fun).
The mode's hook is called both when the mode is enabled and when it is disabled.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-indent.el.gz
;;;###autoload
(define-minor-mode org-indent-mode
"When active, indent text according to outline structure.
Internally this works by adding `line-prefix' and `wrap-prefix'
properties, after each buffer modification, on the modified zone.
The process is synchronous. Though, initial indentation of
buffer, which can take a few seconds on large buffers, is done
during idle time."
:lighter " Ind"
(cond
(org-indent-mode
;; mode was turned on.
(setq-local indent-tabs-mode nil)
(setq-local org-indent--initial-marker (copy-marker 1))
(when org-indent-mode-turns-off-org-adapt-indentation
;; Don't turn off `org-adapt-indentation' when its value is
;; 'headline-data, just indent headline data specially.
(or (eq org-adapt-indentation 'headline-data)
(setq-local org-adapt-indentation nil)))
(when org-indent-mode-turns-on-hiding-stars
(setq-local org-hide-leading-stars t))
(org-indent--compute-prefixes)
(add-function :filter-return (local 'filter-buffer-substring-function)
#'org-indent-remove-properties-from-string)
(add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local)
(add-hook 'before-change-functions
'org-indent-notify-modified-headline nil 'local)
(and font-lock-mode (org-restart-font-lock))
(org-indent-remove-properties (point-min) (point-max))
;; Submit current buffer to initialize agent. If it's the first
;; buffer submitted, also start the agent. Current buffer is
;; pushed in both cases to avoid a race condition.
(if org-indent-agentized-buffers
(push (current-buffer) org-indent-agentized-buffers)
(push (current-buffer) org-indent-agentized-buffers)
(setq org-indent-agent-timer
(run-with-idle-timer 0.2 t #'org-indent-initialize-agent))))
(t
;; Mode was turned off (or we refused to turn it on)
(kill-local-variable 'org-adapt-indentation)
(setq org-indent-agentized-buffers
(delq (current-buffer) org-indent-agentized-buffers))
(when (markerp org-indent--initial-marker)
(set-marker org-indent--initial-marker nil))
(when (local-variable-p 'org-hide-leading-stars)
(kill-local-variable 'org-hide-leading-stars))
(remove-function (local 'filter-buffer-substring-function)
#'org-indent-remove-properties-from-string)
(remove-hook 'after-change-functions 'org-indent-refresh-maybe 'local)
(remove-hook 'before-change-functions
'org-indent-notify-modified-headline 'local)
(org-with-wide-buffer
(org-indent-remove-properties (point-min) (point-max)))
(and font-lock-mode (org-restart-font-lock))
(redraw-display))))