From: Tom Yu Date: Tue, 27 Oct 2009 02:13:31 +0000 (+0000) Subject: Add "reindent" target to top-level Makefile.in. Add X-Git-Tag: krb5-1.8-alpha1~260 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8552d685d38e6d664186ac671f6bcd2269f41398;p=krb5.git Add "reindent" target to top-level Makefile.in. Add krb5-batch-indent.el. These perform a batch reindent based upon the Emacs file-local variable settings, taking care to distinguish between files that are supposed to conform to the coding style versus those that are marked as being exceptions. A later commit will explicitly mark the files that we expect to conform to our coding standards. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23061 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/Makefile.in b/src/Makefile.in index ac850338c..758f55eca 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -654,3 +654,14 @@ coverity prevent cov: Makefiles else \ echo "** Coverity Prevent analysis results not commit to Defect Manager"; \ fi + +FIND = find +XARGS = xargs +EMACS = emacs + +reindent:: + $(FIND) $(SRCTOP) \ + \( -name '*.[ch]' -o -name '*.hin' -o -name '*.[ch].in' \) \ + -print0 | $(XARGS) -0 $(EMACS) -q -batch \ + -l $(SRCTOP)/util/krb5-c-style.el \ + -l $(SRCTOP)/util/krb5-batch-reindent.el diff --git a/src/util/krb5-batch-reindent.el b/src/util/krb5-batch-reindent.el new file mode 100644 index 000000000..ec33555ae --- /dev/null +++ b/src/util/krb5-batch-reindent.el @@ -0,0 +1,33 @@ +;;; -*- mode: emacs-lisp; indent-tabs-mode: nil -*- +(if (not noninteractive) + (error "to be used only with -batch")) +;; Avoid vc-mode interference. +(setq vc-handled-backends nil) +(while command-line-args-left + (let ((filename (car command-line-args-left)) + (error nil) + ;; No backup files? + (make-backup-files nil)) + (find-file 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))) + + ;; Only reindent if the file C style is guessed to be "krb5". + (if (and (eq c-basic-offset 4) + (eq indent-tabs-mode nil)) + (progn + (c-set-style "krb5") + (c-indent-region (point-min) (point-max)))) + + (whitespace-cleanup) + + (save-buffer) + (kill-buffer) + (setq command-line-args-left (cdr command-line-args-left))))