diff --git a/core/siren-core-editor.el b/core/siren-core-editor.el index 044e0d7..58a9a5d 100644 --- a/core/siren-core-editor.el +++ b/core/siren-core-editor.el @@ -91,25 +91,6 @@ ;; (global-set-key [mouse-5] 'scroll-up-line) ) -;; Display whitespace characters globally -(diminish 'whitespace-mode) -(diminish 'global-whitespace-mode) -(setq whitespace-line-column 80) - -;; Customize Whitespace Characters -;; - Newline: \u00AC = ¬ -;; - Tab: \u2192 = → -;; \u00BB = » -;; \u25B6 = ▶ -(setq whitespace-display-mappings - (quote ((newline-mark ?\n [?\u00AC ?\n] [?$ ?\n]) - (tab-mark ?\t [?\u2192 ?\t] [?\u00BB ?\t] [?\\ ?\t])))) - -(setq whitespace-style - (quote (face tabs trailing space-before-tab newline - indentation space-after-tab tab-mark newline-mark - empty))) - ;; enabled change region case commands (put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil) diff --git a/core/siren-core-modules.el b/core/siren-core-modules.el index ed79e1d..477a385 100644 --- a/core/siren-core-modules.el +++ b/core/siren-core-modules.el @@ -43,6 +43,7 @@ (require 'siren-undohist) (require 'siren-uniquify) (require 'siren-which-key) +(require 'siren-whitespace) ;; UI (require 'siren-pixel-scroll) @@ -116,9 +117,6 @@ (require 'siren-toggle-quotes) (require 'siren-yasnippet) -;; Formatting -(require 'siren-whitespace-cleanup) - ;; Version control (require 'siren-code-review) (require 'siren-diff-hl) diff --git a/modules/editor/siren-whitespace.el b/modules/editor/siren-whitespace.el new file mode 100644 index 0000000..1abc838 --- /dev/null +++ b/modules/editor/siren-whitespace.el @@ -0,0 +1,41 @@ +;;; siren-whitespace.el --- jimeh's Emacs Siren: whitespace configuration. + +;;; Commentary: + +;; Basic configuration for whitespace package + +;;; Code: + +(use-package whitespace + :straight (:type built-in) + :diminish whitespace-mode global-whitespace-mode + :hook + (prog-mode . whitespace-cleanup-on-save-mode) + + :preface + (define-minor-mode whitespace-cleanup-on-save-mode + "Run whitespace-cleanup on buffer save" + :global nil + (if whitespace-cleanup-on-save-mode + (add-hook 'before-save-hook 'whitespace-cleanup-on-save-cleanup) + (remove-hook 'before-save-hook 'whitespace-cleanup-on-save-cleanup))) + + (defun whitespace-cleanup-on-save-cleanup() + (when (bound-and-true-p whitespace-cleanup-on-save-mode) + (whitespace-cleanup))) + + :custom + (whitespace-line-column 80) + (whitespace-style '(face tabs trailing space-before-tab newline + indentation space-after-tab tab-mark newline-mark + empty)) + (whitespace-display-mappings '((newline-mark ?\n + [?\u00AC ?\n] ;; \u00AC = ¬ + [?$ ?\n]) + (tab-mark ?\t + [?\u2192 ?\t] ;; \u2192 = → + [?\u00BB ?\t] ;; \u00BB = » + [?\\ ?\t])))) + +(provide 'siren-whitespace) +;;; siren-whitespace.el ends here