Function: display-line-numbers-mode
display-line-numbers-mode is an autoloaded, interactive and
byte-compiled function defined in display-line-numbers.el.gz.
Signature
(display-line-numbers-mode &optional ARG)
Documentation
Toggle display of line numbers in the buffer.
This uses display-line-numbers internally.
To change the type of line numbers displayed by default,
customize display-line-numbers-type. To change the type while
the mode is on, set display-line-numbers directly.
This is a minor mode. If called interactively, toggle the
Display-Line-Numbers 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 display-line-numbers-mode(var)/display-line-numbers-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 26.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/display-line-numbers.el.gz
;;;###autoload
(define-minor-mode display-line-numbers-mode
"Toggle display of line numbers in the buffer.
This uses `display-line-numbers' internally.
To change the type of line numbers displayed by default,
customize `display-line-numbers-type'. To change the type while
the mode is on, set `display-line-numbers' directly."
:lighter nil
(if display-line-numbers-mode
(progn
(when display-line-numbers-width-start
(setq display-line-numbers-width
(length (number-to-string
(+ (count-lines (point-min) (point-max))
(if (and (numberp display-line-numbers-width-start)
(> display-line-numbers-width-start 0))
display-line-numbers-width-start
0))))))
(when display-line-numbers-grow-only
(add-hook 'pre-command-hook #'display-line-numbers-update-width nil t))
(setq display-line-numbers display-line-numbers-type))
(remove-hook 'pre-command-hook #'display-line-numbers-update-width t)
(setq display-line-numbers nil)))