1
0
Fork 0

Use ws-butler

At work I have to work with a lot of files that other people work on as well.
Other people don’t usually have their editor set up to remove all trailing
whitespace, and we’re not allowed to make a change that includes a lot of extra
whitespace changes[1]. So I end up having to revert a lot of whitespace changes
just before submitting. And if I then have to make more changes, for example
because something was pointed out in a code review, I have to do it again.

‘ws-butler’ promises that it will still prevent me from submitting extraneous
whitespace, but will not touch lines that I haven’t changed, so that would
prevent me from having to revert them all the time.

[1]: This is good, having a lot of whitespace changes can distract from or even
completely hide the actual change you’re trying to make.
This commit is contained in:
Tom Willemse 2020-10-15 10:30:02 -07:00
parent b041947902
commit a49fda9c79
2 changed files with 23 additions and 8 deletions

View file

@ -4,8 +4,8 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2020.1015.100916
;; Package-Requires: (oni-data-dir expand-region multiple-cursors embrace gcmh diminish)
;; Version: 2020.1015.102640
;; Package-Requires: (oni-data-dir expand-region multiple-cursors embrace gcmh diminish ws-butler)
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@ -31,6 +31,7 @@
(require 'gcmh)
(require 'oni-data-dir)
(require 'recentf)
(require 'ws-butler)
(defconst oni-core--auto-save-directory (oni-data-dir-locate "auto-save-files/")
"Directory where auto-saves go.")
@ -40,11 +41,6 @@
(defvar oni-core--recentf-idle-timer nil
"Internal variable keeping track of a timer started for recentf-save-list.")
(defun oni-core--destroy-trailing-whitespace ()
"Delete trailing whitespace everywhere, except in Markdown buffers."
(if (not (eq major-mode 'markdown-mode))
(delete-trailing-whitespace)))
(defun oni-core--switch-newline-keys ()
"Switch the C-j and RET keys in the local buffer."
(if electric-indent-mode
@ -131,7 +127,6 @@
(setq-default truncate-lines t)
(setq-default fill-column 80)
(add-hook 'before-save-hook #'oni-core--destroy-trailing-whitespace)
(add-hook 'before-save-hook 'time-stamp)
(add-hook 'electric-indent-local-mode-hook #'oni-core--switch-newline-keys)
(add-hook 'minibuffer-setup-hook 'electric-pair-local-mode)
@ -155,11 +150,13 @@
(run-with-idle-timer 10 t #'oni-core-recentf-save-list-silently)))
(diminish 'gcmh-mode)
(diminish 'ws-butler-mode)
(electric-indent-mode -1)
(winner-mode)
(recentf-mode)
(gcmh-mode)
(ws-butler-global-mode)
(add-to-list 'display-buffer-alist
`(,(rx string-start

View file

@ -35,3 +35,21 @@
[[ "$output" == *"t" ]]
}
@test "Starting Emacs diminishes ws-butler-global-mode" {
run emacs -batch -l package -f package-initialize -l subr-x \
-eval "(prin1 (string-empty-p (car (alist-get 'ws-butler-mode minor-mode-alist))))"
echo "$output"
[[ "$output" == *"t" ]]
}
@test "Starting Emacs turns on ws-butler-mode" {
run emacs -batch -l package -f package-initialize \
-eval "(prin1 (bound-and-true-p ws-butler-mode))"
echo "$output"
[[ "$output" == *"t" ]]
}