-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuntabify-file.el
30 lines (25 loc) · 928 Bytes
/
untabify-file.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(require 'cl)
(require 'custom)
(defcustom untabify-exclude-list
'(makefile-mode
makefile-bsdmake-mode
change-log-mode
"Makefile$")
"List of regexp or modes to which is not applied untabify."
:group 'untabify)
(defun untabify-before-write ()
"Strip all trailing whitespaces and untabify buffer before
save."
(when (and (eq this-command 'save-buffer)
(not (find nil
untabify-exclude-list
:if #'(lambda (r)
(typecase r
(string (string-match r (buffer-name)))
(symbol (eq major-mode r)))))))
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace) ;; TtT: causes issues when sharing code ;;
)))
(add-hook 'write-file-hooks 'untabify-before-write)
(provide 'untabify-file)