From: Tom Yu Date: Sun, 1 Nov 2009 04:35:20 +0000 (+0000) Subject: Rework in an attempt to deal with variant Emacs versions X-Git-Tag: krb5-1.8-alpha1~226 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0f6169b5c35fdeb43a06c7a9f167ffbcd771ba32;p=krb5.git Rework in an attempt to deal with variant Emacs versions git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23113 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/krb5-batch-reindent.el b/src/util/krb5-batch-reindent.el index c1c24211a..a22ef7b2c 100644 --- a/src/util/krb5-batch-reindent.el +++ b/src/util/krb5-batch-reindent.el @@ -11,6 +11,35 @@ (message "Tab found @%s." tab-found) (message "No tabs found.")))) +(defun whitespace-new () + ;; Sometimes whitespace-cleanup gets its internals confused + ;; when whitespace-mode hasn't been activated on the buffer. + (let ((whitespace-indent-tabs-mode indent-tabs-mode) + (whitespace-style '(empty trailing))) + ;; Only clean up tab issues if indent-tabs-mode is explicitly + ;; set in the file local variables. + (if (local-variable-p 'indent-tabs-mode) + (progn + (message "Enabling tab cleanups.") + (add-to-list 'whitespace-style 'indentation) + (add-to-list 'whitespace-style 'space-before-tab) + (add-to-list 'whitespace-style 'space-after-tab))) +;; (message "indent-tabs-mode=%s" indent-tabs-mode) + (message "Cleaning whitespace...") + (whitespace-cleanup))) + +;; Old style whitespace.el uses different variables. +(defun whitespace-old () + (let (whitespace-check-indent-whitespace + whitespace-check-spacetab-whitespace) + (if (local-variable-p 'indent-tabs-mode) + (progn + (message "Enabling tab cleanups.") + (setq whitespace-check-indent-whitespace indent-tabs-mode) + (setq whitespace-check-spacetab-whitespace t))) + (message "Cleaning whitespace...") + (whitespace-cleanup))) + (while command-line-args-left (let ((filename (car command-line-args-left)) ;; No backup files; we have version control. @@ -30,22 +59,9 @@ (if (equal c-indentation-style "krb5") (c-indent-region (point-min) (point-max))) - ;; Sometimes whitespace-cleanup gets its internals confused - ;; when whitespace-mode hasn't been activated on the buffer. - (let ((whitespace-indent-tabs-mode indent-tabs-mode) - (whitespace-style '(empty trailing))) - ;; Only clean up tab issues if indent-tabs-mode is explicitly - ;; set in the file local variables. - (if (local-variable-p 'indent-tabs-mode) - (progn - (message "Enabling tab cleanups.") - (add-to-list 'whitespace-style 'indentation) - (add-to-list 'whitespace-style 'space-before-tab) - (add-to-list 'whitespace-style 'space-after-tab))) -;; (message "indent-tabs-mode=%s" indent-tabs-mode) - (setq tab-found (search-forward "\t" nil t)) - (message "Cleaning whitespace...") - (whitespace-cleanup)) + (if (custom-variable-p 'whitespace-style) + (whitespace-new) + (whitespace-old)) (save-buffer) (kill-buffer nil)