Function: delete-trailing-whitespace-mode
delete-trailing-whitespace-mode is an interactive and byte-compiled
function defined in simple.el.gz.
Signature
(delete-trailing-whitespace-mode &optional ARG)
Documentation
Delete trailing whitespace before saving the current buffer.
This is a minor mode. If called interactively, toggle the
Delete-Trailing-Whitespace 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 delete-trailing-whitespace-mode(var)/delete-trailing-whitespace-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 31.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(define-minor-mode delete-trailing-whitespace-mode
"Delete trailing whitespace before saving the current buffer."
:global nil
(cond
(delete-trailing-whitespace-mode
(add-hook 'before-save-hook
#'delete-trailing-whitespace-if-possible nil t))
(t
(remove-hook 'before-save-hook
#'delete-trailing-whitespace-if-possible t))))