Don't automatically cleanup whitespace if no-ws-cleanup is set to t.

This commit is contained in:
tastytea 2019-11-14 14:33:45 +01:00
parent 2159931d2a
commit 6230215acf

View File

@ -1,6 +1,6 @@
;;; common.el --- Common settings for text files. -*- lexical-binding: t; -*-
;; Time-stamp: <2019-11-09T12:04:11+00:00>
;; Time-stamp: <2019-11-14T13:26:33+00:00>
;;; Commentary:
@ -236,6 +236,17 @@
(whitespace-mode)
)
(defvar no-ws-cleanup nil
"Do not cleanup whitespace if t.")
(make-variable-buffer-local 'no-ws-cleanup)
(put 'no-ws-cleanup 'safe-local-variable #'booleanp) ; Mark as safe.
(defun my/ws-maybe-cleanup ()
"Run `whitespace-cleanup' if `no-ws-cleanup' is not t."
(unless no-ws-cleanup
(whitespace-cleanup))
)
:bind
("C-x w" . whitespace-mode)
@ -243,7 +254,7 @@
(prog-mode . my/ws-load-local-vars-first)
(conf-mode . my/ws-load-local-vars-first)
(text-mode . my/ws-load-local-vars-first)
(before-save . whitespace-cleanup)
(before-save . my/ws-maybe-cleanup)
:custom-face
(whitespace-space ((nil :foreground "gray18")))