Function: header-line-indent-mode
header-line-indent-mode is an autoloaded, interactive and
byte-compiled function defined in display-line-numbers.el.gz.
Signature
(header-line-indent-mode &optional ARG)
Documentation
Minor mode to help with alignment of header line when line numbers are shown.
This minor mode should be turned on in buffers which display header-line
that needs to be aligned with buffer text when display-line-numbers-mode(var)/display-line-numbers-mode(fun)
is turned on in the buffer.
Buffers that have this switched on should have a header-line-format
that uses the header-line-indent or the header-line-indent-width
variables, which this mode will keep up-to-date with the current
display of line numbers. For example, a header-line-format that
looks like this:
("" header-line-indent THE-REST...)
will make sure the text produced by THE-REST (which should be a header-line format string) is always indented to be aligned on display with the first column of buffer text.
The header-line-indent-width variable is also kept updated,
and can be used, for instance, in :align-to specs as part
of header-line-format, like this:
(space :align-to (+ header-line-indent-width 10))
See also line-number-display-width.
This is a minor mode. If called interactively, toggle the
Header-Line-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 header-line-indent-mode(var)/header-line-indent-mode(fun).
The mode's hook is called both when the mode is enabled and when it is disabled.
Probably introduced at or before Emacs version 29.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/display-line-numbers.el.gz
;;;###autoload
(define-minor-mode header-line-indent-mode
"Minor mode to help with alignment of header line when line numbers are shown.
This minor mode should be turned on in buffers which display header-line
that needs to be aligned with buffer text when `display-line-numbers-mode'
is turned on in the buffer.
Buffers that have this switched on should have a `header-line-format'
that uses the `header-line-indent' or the `header-line-indent-width'
variables, which this mode will keep up-to-date with the current
display of line numbers. For example, a `header-line-format' that
looks like this:
(\"\" header-line-indent THE-REST...)
will make sure the text produced by THE-REST (which should be
a header-line format string) is always indented to be aligned on
display with the first column of buffer text.
The `header-line-indent-width' variable is also kept updated,
and can be used, for instance, in `:align-to' specs as part
of `header-line-format', like this:
(space :align-to (+ header-line-indent-width 10))
See also `line-number-display-width'."
:lighter nil
(if header-line-indent-mode
(progn
(setq-local header-line-indent ""
header-line-indent-width 0)
(add-hook 'pre-redisplay-functions
#'header-line-indent--watch-line-number-width nil t)
(add-hook 'window-scroll-functions
#'header-line-indent--window-scroll-function nil t))
(setq-local header-line-indent ""
header-line-indent-width 0)
(remove-hook 'pre-redisplay-functions
#'header-line-indent--watch-line-number-width t)
(remove-hook 'window-scroll-functions
#'header-line-indent--window-scroll-function t)))