Emacs: Use ws-butler and remove own hacks.

master
Pierre Neidhardt 2019-11-02 16:16:29 +01:00
parent c3f5fa236e
commit a4de491950
4 changed files with 3 additions and 29 deletions

View File

@ -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))

View File

@ -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.

View File

@ -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.

View File

@ -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)