Emacs: Replace variable my/no-ws-cleanup with my/reformat-save.

This commit is contained in:
tastytea 2020-10-27 09:50:20 +01:00
parent 5a7baad87b
commit 56d52c554c
3 changed files with 16 additions and 12 deletions

View File

@ -1,6 +1,6 @@
;;; global-variables.el --- Set some global variables. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-05-24T22:32:42+0200>
;; Time-stamp: <2020-10-27T09:44:20+0100>
;;; Commentary:
;; * Banish customizations.
@ -51,7 +51,11 @@
(setenv "LC_MESSAGES" "en_US.utf8")
(defvar slow-computer nil) ; Slow computers load fewer packages.
(if (member (system-name) '("steuerbeamter" "azimuth" "localhost"))
(setq slow-computer t)))) ; localhost is schnibble.
(setq slow-computer t)) ; localhost is schnibble.
(defvar-local my/reformat-save t
"Make changes to the buffer on save.
If t, run `whitespace-cleanup', `clang-format-buffer' and so on.")
(put 'my/reformat-save 'safe-local-variable #'booleanp)))
(provide 'basics/global-variables)
;;; global-variables.el ends here

View File

@ -1,6 +1,6 @@
;;; c++.el --- C++ settings. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-08-03T00:39:43+0200>
;; Time-stamp: <2020-10-27T09:46:38+0100>
;;; Commentary:
@ -119,9 +119,13 @@
(when (executable-find "clang-format")
(use-package clang-format
:commands (clang-format-buffer)
:config (defun my/clang-format-buffer-maybe ()
"Run `clang-format-buffer' if `my/reformat-save' is t."
(when my/reformat-save
(clang-format-buffer)))
:hook ((c-mode-common
. (lambda ()
(add-hook 'before-save-hook #'clang-format-buffer nil t))))))
. (lambda () (add-hook 'before-save-hook
#'my/clang-format-buffer-maybe nil t))))))
(provide 'programming/c++)
;;; c++.el ends here

View File

@ -1,6 +1,6 @@
;;; common.el --- Common settings for text files. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-10-14T21:42:37+0200>
;; Time-stamp: <2020-10-27T09:44:52+0100>
;;; Commentary:
@ -270,13 +270,9 @@
(hack-local-variables))
(whitespace-mode))
(defvar-local my/no-ws-cleanup nil
"Do not cleanup whitespace if t.")
(put 'my/no-ws-cleanup 'safe-local-variable #'booleanp)
(defun my/ws-maybe-cleanup ()
"Run `whitespace-cleanup' if `my/no-ws-cleanup' is not t."
(unless my/no-ws-cleanup
"Run `whitespace-cleanup' if `my/reformat-save' is t."
(when my/reformat-save
(whitespace-cleanup))))
:bind ("C-c w" . whitespace-mode)
:hook ((prog-mode . my/ws-load-local-vars-first)