summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorThomas Ulmer <thomasmulmer02@gmail.com>2026-01-01 13:48:21 -0800
committerThomas Ulmer <thomasmulmer02@gmail.com>2026-01-01 13:48:21 -0800
commit56e6075c4295294edac5af361d8e1a74ba88858d (patch)
tree9faf2f2c51f695bcf9af4747a83ed88af7d0c72c /emacs
parent075d4a41bfe323c06c5b3a93da0dba3e306b5873 (diff)
emacs: more careful before save hook for prog
Diffstat (limited to 'emacs')
-rw-r--r--emacs/init.el21
1 files changed, 15 insertions, 6 deletions
diff --git a/emacs/init.el b/emacs/init.el
index 07bc75d..8eab92e 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -44,18 +44,27 @@
(set-frame-parameter nil 'alpha-background 100)
(set-frame-parameter nil 'alpha-background alpha-transparency))))
+(defvar my/prog-cleanup-excluded-modes
+ '(makefile-gmake-mode makefile-mode makefile-imake-mode
+ makefile-makepp-mode makefile-bsdmake-mode makefile-automake-mode))
+
+(defvar my/prog-cleanup-want-tabs-modes
+ '(makefile-gmake-mode makefile-mode makefile-imake-mode
+ makefile-makepp-mode makefile-bsdmake-mode makefile-automake-mode))
+
+(defvar my/prog-cleanup-indent-max-lines 500)
+
(defun my/clean-prog-file (&optional buffer)
"Fixes whitespace etc in BUFFER or current buffer."
(unless buffer (setq buffer (current-buffer)))
(with-current-buffer buffer
- (indent-region (point-min) (point-max))
- (untabify (point-min) (point-max))
+ (when (< (car (buffer-line-statistics buffer))
+ my/prog-cleanup-indent-max-lines)
+ (indent-region (point-min) (point-max)))
+ (unless (member major-mode my/prog-cleanup-want-tabs-modes)
+ (untabify (point-min) (point-max)))
(delete-trailing-whitespace)))
-(defvar my/prog-cleanup-excluded-modes
- '(makefile-gmake-mode makefile-mode makefile-imake-mode
- makefile-makepp-mode makefile-bsdmake-mode makefile-automake-mode))
-
(defun my/prog-buffer-setup ()
"Do setup in for mode buffers."
(superword-mode 1)