From a4de491950d4c6221f70abf76ac590d8dd70a380 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sat, 2 Nov 2019 16:16:29 +0100 Subject: [PATCH] Emacs: Use ws-butler and remove own hacks. --- .emacs.d/lisp/hook-functions.el | 20 -------------------- .emacs.d/lisp/init-lisp.el | 1 - .emacs.d/lisp/init-scheme.el | 1 - .emacs.d/lisp/main.el | 10 +++------- 4 files changed, 3 insertions(+), 29 deletions(-) diff --git a/.emacs.d/lisp/hook-functions.el b/.emacs.d/lisp/hook-functions.el index 2c059d07..618294b4 100644 --- a/.emacs.d/lisp/hook-functions.el +++ b/.emacs.d/lisp/hook-functions.el @@ -8,26 +8,6 @@ "Unconditionally turn on `comint-dynamic-complete-filename' for the current buffer." (add-to-list 'completion-at-point-functions 'comint-dynamic-complete-filename t)) -(defun ambrevar/turn-on-delete-trailing-whitespace () - "Add the `delete-trailing-whitespace' function to `before-save-hook'. -This does not affect .csv files." - (unless (or (string= (file-name-extension buffer-file-name) "csv") - ;; REVIEW: Emacs 26.1 hangs when running delete-trailing-whitespace on image. - (eq major-mode 'image-mode)) - (add-hook 'before-save-hook 'delete-trailing-whitespace nil t))) - -(defun ambrevar/turn-off-delete-trailing-whitespace () - "Unconditionally remove the `delete-trailing-whitespace' function to `before-save-hook'." - (remove-hook 'before-save-hook 'delete-trailing-whitespace t)) - -(defun ambrevar/turn-on-prettify-before-save () - "Unconditionally add the `ambrevar/prettify' function to `before-save-hook'." - (add-hook 'before-save-hook 'ambrevar/prettify nil t)) - -(defun ambrevar/turn-off-prettify-before-save () - "Unconditionally remove the `ambrevar/prettify' function to `before-save-hook'." - (remove-hook 'before-save-hook 'ambrevar/prettify t)) - (defun ambrevar/turn-off-indent-tabs () "Unconditionally turn off tab indentation." (setq indent-tabs-mode nil)) diff --git a/.emacs.d/lisp/init-lisp.el b/.emacs.d/lisp/init-lisp.el index 6cc3f16d..58376765 100644 --- a/.emacs.d/lisp/init-lisp.el +++ b/.emacs.d/lisp/init-lisp.el @@ -31,7 +31,6 @@ "\\s-+(\\([^)]+\\)")) 2)) -(add-hook 'lisp-mode-hook 'ambrevar/turn-on-prettify-before-save) (add-hook 'lisp-mode-hook 'ambrevar/turn-on-complete-filename) (add-hook 'lisp-mode-hook 'ambrevar/turn-on-tab-width-to-8) ; Because some existing code uses tabs. (add-hook 'lisp-mode-hook 'ambrevar/turn-off-indent-tabs) ; Should not use tabs. diff --git a/.emacs.d/lisp/init-scheme.el b/.emacs.d/lisp/init-scheme.el index 896acd88..5f579481 100644 --- a/.emacs.d/lisp/init-scheme.el +++ b/.emacs.d/lisp/init-scheme.el @@ -3,7 +3,6 @@ (require 'init-lispy) (require 'init-rainbow) -(add-hook 'scheme-mode-hook 'ambrevar/turn-on-prettify-before-save) (add-hook 'scheme-mode-hook 'ambrevar/turn-on-complete-filename) (add-hook 'scheme-mode-hook 'ambrevar/turn-on-tab-width-to-8) ; Because some existing code uses tabs. (add-hook 'scheme-mode-hook 'ambrevar/turn-off-indent-tabs) ; Should not use tabs. diff --git a/.emacs.d/lisp/main.el b/.emacs.d/lisp/main.el index e8e7dc0e..286d8ea0 100644 --- a/.emacs.d/lisp/main.el +++ b/.emacs.d/lisp/main.el @@ -101,13 +101,6 @@ ;;; Reported at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23740. ;; (setq whitespace-action '(report-on-bogus)) -;;; Add formatting functions to the buffer-local `before-save-hook'. -;;; WARNING: this can break some configuration files needing whitespaces at the -;;; end. This can also slow down saving on big files. Some modes (e.g. lisp) run -;;; `ambrevar/prettify' in their local hook, which is redundant with this. -;; (add-hook 'find-file-hook 'ambrevar/turn-on-prettify-before-save) -(add-hook 'find-file-hook 'ambrevar/turn-on-delete-trailing-whitespace) - ;;; Cycle spacing instead of just-one-space. This frees M-\. (global-set-key [remap just-one-space] 'cycle-spacing) @@ -428,4 +421,7 @@ (setq tab-width 2 left-margin 2)) (add-hook 'change-log-mode-hook 'ambrevar/change-log-set-indent-rules) +(when (require 'ws-butler nil 'noerror) + (ws-butler-global-mode)) + (provide 'main)