Path: blob/main/crypto/krb5/src/util/krb5-batch-reindent.el
34869 views
;;; -*- mode: emacs-lisp; indent-tabs-mode: nil -*-1(if (not noninteractive)2(error "to be used only with -batch"))3;; Avoid vc-mode interference.4(setq vc-handled-backends nil)56;; for debugging7(defun report-tabs ()8(let ((tab-found (search-forward "\t" nil t)))9(if tab-found10(message "Tab found @%s." tab-found)11(message "No tabs found."))))1213(defun whitespace-new ()14;; Sometimes whitespace-cleanup gets its internals confused15;; when whitespace-mode hasn't been activated on the buffer.16(let ((whitespace-indent-tabs-mode indent-tabs-mode)17(whitespace-style '(empty trailing)))18;; Only clean up tab issues if indent-tabs-mode is explicitly19;; set in the file local variables.20(if (local-variable-p 'indent-tabs-mode)21(progn22(message "Enabling tab cleanups.")23(add-to-list 'whitespace-style 'indentation)24(add-to-list 'whitespace-style 'space-before-tab)25(add-to-list 'whitespace-style 'space-after-tab)))26;; (message "indent-tabs-mode=%s" indent-tabs-mode)27(message "Cleaning whitespace...")28(whitespace-cleanup)))2930;; Old style whitespace.el uses different variables.31(defun whitespace-old ()32(let (whitespace-check-buffer-indent33whitespace-check-buffer-spacetab)34(if (local-variable-p 'indent-tabs-mode)35(progn36(message "Enabling tab cleanups.")37(setq whitespace-check-buffer-indent indent-tabs-mode)38(setq whitespace-check-buffer-spacetab t)))39(message "Cleaning whitespace...")40(whitespace-cleanup)))4142(while command-line-args-left43(let ((filename (car command-line-args-left))44;; No backup files; we have version control.45(make-backup-files nil))46(find-file filename)47(message "Read %s." filename)4849(if (not indent-tabs-mode)50(progn51(message "Untabifying...")52(untabify (point-min) (point-max))))5354;; Only reindent if the file C style is guessed to be "krb5".55;; Note that krb5-c-style.el already has a heuristic for setting56;; the C style if the file has "c-basic-offset: 4;57;; indent-tabs-mode: nil".58(if (equal c-indentation-style "krb5")59(c-indent-region (point-min) (point-max)))6061(if (fboundp 'whitespace-newline-mode)62(whitespace-new)63(whitespace-old))6465(save-buffer)66(kill-buffer nil)67(setq command-line-args-left (cdr command-line-args-left))))686970