Function: global-whitespace-mode

global-whitespace-mode is an autoloaded, interactive and byte-compiled function defined in whitespace.el.gz.

Signature

(global-whitespace-mode &optional ARG)

Documentation

Toggle whitespace visualization globally (Global Whitespace mode).

This is a minor mode. If called interactively, toggle the Global 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 (default-value \=global-whitespace-mode)'.

The mode's hook is called both when the mode is enabled and when it is disabled.

See also whitespace-style, whitespace-newline and whitespace-display-mappings.

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/whitespace.el.gz
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; User commands - Global mode


;;;###autoload
(define-minor-mode global-whitespace-mode
  "Toggle whitespace visualization globally (Global Whitespace mode).

See also `whitespace-style', `whitespace-newline' and
`whitespace-display-mappings'."
  :lighter    " WS"
  :init-value nil
  :global     t
  :group      'whitespace
  (cond
   (noninteractive			; running a batch job
    (setq global-whitespace-mode nil))
   (global-whitespace-mode		; global-whitespace-mode on
    (save-current-buffer
      (add-hook 'find-file-hook 'whitespace-turn-on-if-enabled)
      (add-hook 'after-change-major-mode-hook 'whitespace-turn-on-if-enabled)
      (dolist (buffer (buffer-list))	; adjust all local mode
	(set-buffer buffer)
	(unless whitespace-mode
	  (whitespace-turn-on-if-enabled)))))
   (t					; global-whitespace-mode off
    (save-current-buffer
      (remove-hook 'find-file-hook 'whitespace-turn-on-if-enabled)
      (remove-hook 'after-change-major-mode-hook 'whitespace-turn-on-if-enabled)
      (dolist (buffer (buffer-list))	; adjust all local mode
	(set-buffer buffer)
	(unless whitespace-mode
	  (whitespace-turn-off)))))))