 ;; or M-x load-file the file, so we won't accidentally
 ;; evaluate (save-buffers-kill-emacs)...
 
-(let ((index 0))
-  (if (elt argv index)
-      (while (elt argv index)
-        (message "Processing %s..." (elt argv index))
-        (find-file (elt argv index))
+(let ((file-index 0))
+  (if (elt argv file-index)
+      (while (elt argv file-index)
+        (find-file (elt argv file-index))
         (fd-io-styleify)
-        (setq index (1+ index))))
-  (if (> index 0)
-      (save-buffers-kill-emacs t)))
+        (message "Done %s..." (elt argv file-index))
+        (setq file-index (1+ file-index))))
+  (if (> file-index 0)
+      (let ((junk 0))
+        (message "Save and quit...")
+        (save-buffers-kill-emacs t))))
   
 

#!/usr/bin/emacs --script

;; Insert style boilerplate
;;
;; Breaking the string in half keeps emacs
;; from trying to interpret the local variable
;; settings e.g. when it reads the lisp source code

(defun insert-style-boilerplate () (interactive)
       (save-excursion (goto-char (point-max))
                       (insert "
/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Var" "iables:
 * eval: (c-set-style \"gnu\")
 * End:
 */")))

;; Insert indent-off ... indent-on brackets around
;; a certain xxx_foreach macro, etc. which "indent"

;; are few examples (fortunately).

(defun fix-initializer (what) (interactive)
       (find-indent-offs)
       (save-excursion 
         (goto-char (point-min))
         (while (search-forward-regexp what (point-max) t)
           (move-beginning-of-line nil)
           (previous-line)
           (let ((index 0)(pointval 0))
             (while (and (< pointval (point))(elt indent-offset-list index))
               (setq pointval (elt indent-offset-list index))
               (setq index (1+ index)))
             (if (not (eq pointval (point)))
                 (let ((junk 0))
                   (next-line)
                   (open-line 1)
                   (c-indent-line-or-region)
                   (insert "/* *INDENT-OFF* */")
                   (search-forward "{")
                   (backward-char)
                   (forward-sexp)
                   (move-end-of-line nil)
                   (newline 1)
                   (c-indent-line-or-region)
                   (insert "/* *INDENT-ON* */")
                   (find-indent-offs))
               (search-forward "*INDENT-ON*"))))))

(defun fix-pool-foreach () (interactive)
       (fix-initializer "pool_foreach *("))
