Emacs: Turn on `delete-trailing-whitespace' locally
parent
8f3042fb71
commit
9f9370d196
|
@ -412,6 +412,11 @@ This does not interfere with `subword-mode'."
|
||||||
"Unconditionally add the `fmt' function to `before-save-hook'."
|
"Unconditionally add the `fmt' function to `before-save-hook'."
|
||||||
(add-hook 'before-save-hook 'fmt nil t))
|
(add-hook 'before-save-hook 'fmt nil t))
|
||||||
|
|
||||||
|
(defun turn-on-delete-trailing-whitespace ()
|
||||||
|
"Unconditionally add the `delete-trailing-whitespace' function to `before-save-hook'."
|
||||||
|
(unless (string= (file-name-extension buffer-file-name) "csv")
|
||||||
|
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t)))
|
||||||
|
|
||||||
(defun turn-off-indent-tabs ()
|
(defun turn-off-indent-tabs ()
|
||||||
"Unconditionally turn off tab indentation."
|
"Unconditionally turn off tab indentation."
|
||||||
(setq indent-tabs-mode nil))
|
(setq indent-tabs-mode nil))
|
||||||
|
|
|
@ -110,12 +110,12 @@
|
||||||
;;; Reported at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23740.
|
;;; Reported at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23740.
|
||||||
;; (setq whitespace-action '(report-on-bogus))
|
;; (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
|
;;; 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
|
;;; end. This can also slow down saving on big files. Some modes (e.g. lisp) run
|
||||||
;;; `fmt' in their local hook, which is redundant with this.
|
;;; `fmt' in their local hook, which is redundant with this.
|
||||||
;; (require 'functions) ; for `fmt'
|
;; (add-hook 'find-file-hook 'turn-on-fmt-before-save)
|
||||||
;; (add-hook 'before-save-hook 'fmt)
|
(add-hook 'find-file-hook 'turn-on-delete-trailing-whitespace)
|
||||||
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
|
||||||
|
|
||||||
;;; Hippie expand
|
;;; Hippie expand
|
||||||
;; (global-set-key (kbd "M-/") 'hippie-expand)
|
;; (global-set-key (kbd "M-/") 'hippie-expand)
|
||||||
|
|
Loading…
Reference in New Issue