Last active
March 30, 2017 09:18
-
-
Save mookid/6c149993042d699c4e037747c46722cf to your computer and use it in GitHub Desktop.
Untabify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; I don't want to introduce tabs in my code; but I don't want to break Makefiles, | |
;; or to introduce diffs in third party code. | |
;; Here is my solution: | |
(defun my-untabify-buffer () | |
"Untabify the current buffer, unless `my-untabify-this-buffer' is nil." | |
(and my-untabify-this-buffer (untabify (point-min) (point-max)))) | |
(define-minor-mode my-untabify-mode | |
"Untabify buffer on save." nil " untab" nil | |
(if my-untabify-mode | |
(progn | |
(make-variable-buffer-local 'my-untabify-this-buffer) | |
(setq my-untabify-this-buffer (not (derived-mode-p 'makefile-mode))) | |
(add-hook 'before-save-hook 'my-untabify-buffer nil t)) | |
(progn | |
(kill-local-variable 'my-untabify-this-buffer) | |
(remove-hook 'before-save-hook 'my-untabify-buffer t)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment