mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
feat(editor): improve whitespace-mode setup and cleanup on save
Move away from the whitespace-cleanup-mode package, and instead simply define our own whitespace-cleanup-on-save-mode minor-mode that uses a before-save-hook.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
41
modules/editor/siren-whitespace.el
Normal file
41
modules/editor/siren-whitespace.el
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user