From 75643f7715d94f34aa1417156864d79897391e1f Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Fri, 30 Oct 2009 21:34:19 +0000 Subject: [PATCH] Tweak batch reindent some more. Limit the initial bulk reindent, and refine the exception list somewhat. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23096 dc483132-0cff-0310-8789-dd5450dbe970 --- src/Makefile.in | 34 +++++++++++++++++++-------- src/util/krb5-batch-reindent.el | 41 ++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/src/Makefile.in b/src/Makefile.in index f528472d5..4ed577330 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -667,16 +667,30 @@ reindent:: -l $(SRCTOP)/util/krb5-batch-reindent.el mark-cstyle:: - $(FIND) $(SRCTOP) \( \ - -path $(SRCTOP)/appl/bsd -o \ - -path $(SRCTOP)/appl/gssftp -o \ - -path $(SRCTOP)/appl/telnet -o \ - -path $(SRCTOP)/include/gssrpc -o \ - -path $(SRCTOP)/lib/crypto/krb/yarrow -o \ - -path $(SRCTOP)/lib/rpc -o \ - -path $(SRCTOP)/plugins/kdb/db2/libdb2 -o \ - -path $(SRCTOP)/lib/krb5/unicode -o \ - -path $(SRCTOP)/windows/wintel \ + $(FIND) \ + $(SRCTOP)/clients \ + $(SRCTOP)/lib/kadm5 \ + $(SRCTOP)/lib/kdb \ + $(SRCTOP)/lib/krb5 \ + $(SRCTOP)/kadmin \ + $(SRCTOP)/kdc \ + \( \ + -path $(SRCTOP)/kadmin/cli/strftime.c -o \ + -path $(SRCTOP)/kadmin/server/ipropd_svc.c -o \ + -path $(SRCTOP)/kadmin/server/kadm_rpc_svc.c -o \ + -path $(SRCTOP)/lib/kadm5/admin_xdr.h -o \ + -path $(SRCTOP)/lib/kadm5/client/client_rpc.c -o \ + -path $(SRCTOP)/lib/kadm5/kadm_rpc.h -o \ + -path $(SRCTOP)/lib/kadm5/kadm_rpc_xdr.c -o \ + -path $(SRCTOP)/lib/kadm5/srv/adm_xdr.c -o \ + -path $(SRCTOP)/lib/krb5/asn.1 -o \ + -path $(SRCTOP)/lib/krb5/ccche/cc_file.c -o \ + -path $(SRCTOP)/lib/krb5/krb/deltat.c -o \ + -path $(SRCTOP)/lib/krb5/krb/preauth.c -o \ + -path $(SRCTOP)/lib/krb5/krb/ser_ctx.c -o \ + -path $(SRCTOP)/lib/krb5/krb/strftime.c -o \ + -path $(SRCTOP)/lib/krb5/krb/strptime.c -o \ + -path $(SRCTOP)/lib/krb5/unicode \ \) -prune -o \ -name '*.[ch]' \ -print0 | $(XARGS) -0 $(EMACS) -q -batch \ diff --git a/src/util/krb5-batch-reindent.el b/src/util/krb5-batch-reindent.el index 2a4c7682b..1fa82cc2a 100644 --- a/src/util/krb5-batch-reindent.el +++ b/src/util/krb5-batch-reindent.el @@ -3,21 +3,25 @@ (error "to be used only with -batch")) ;; Avoid vc-mode interference. (setq vc-handled-backends nil) + +;; for debugging +(defun report-tabs () + (let ((tab-found (search-forward "\t" nil t))) + (if tab-found + (message "Tab found @%s." tab-found) + (message "No tabs found.")))) + (while command-line-args-left (let ((filename (car command-line-args-left)) - (error nil) - ;; No backup files? + ;; No backup files; we have version control. (make-backup-files nil)) (find-file filename) + (message "Read %s." filename) - ;; (goto-char (point-min)) - ;; (if (looking-at "\\s-*/\\*\\s-*-\\*-.*-\\*-\\s-*\\*/\\s-*\n") - ;; (delete-region (match-beginning 0) (match-end 0))) - ;; (insert "/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */\n") - ;; (normal-mode) - - (if (eq indent-tabs-mode nil) - (untabify (point-min) (point-max))) + (if (not indent-tabs-mode) + (progn + (message "Untabifying...") + (untabify (point-min) (point-max)))) ;; Only reindent if the file C style is guessed to be "krb5". ;; Note that krb5-c-style.el already has a heuristic for setting @@ -26,7 +30,22 @@ (if (equal c-indentation-style "krb5") (c-indent-region (point-min) (point-max))) - (whitespace-cleanup) + ;; 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 (assq 'indent-tabs-mode file-local-variables-alist) + (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)) (save-buffer) (kill-buffer) -- 2.26.2