1 #!/usr/bin/emacs --script
3 ;; insert style boilerplate
4 (defun insert-style-boilerplate () (interactive)
5 (save-excursion (goto-char (point-max))
8 * fd.io coding-style-patch-verification: ON
11 * eval: (c-set-style \"gnu\")
16 (defun fix-foreach () (interactive)
17 (save-excursion (goto-char (point-min))
18 (while (search-forward-regexp
19 "[pool|hash|clib_fifo|clib_bitmap]_foreach"
21 (move-beginning-of-line nil)
23 (c-indent-line-or-region)
24 (insert "/* *INDENT-OFF* */")
28 (move-end-of-line nil)
30 (c-indent-line-or-region)
31 (insert "/* *INDENT-ON* */"))))
33 (defun fix-initializer (what) (interactive)
35 (goto-char (point-min))
36 (while (search-forward-regexp what (point-max) t)
37 (move-beginning-of-line nil)
39 (c-indent-line-or-region)
40 (insert "/* *INDENT-OFF* */")
44 (move-end-of-line nil)
46 (c-indent-line-or-region)
47 (insert "/* *INDENT-ON* */"))))
49 (defun fix-vlib-register-thread () (interactive)
50 (fix-initializer "VLIB_REGISTER_THREAD *("))
52 (defun fix-vlib-cli-command () (interactive)
53 (fix-initializer "VLIB_CLI_COMMAND *("))
55 (defun fix-vlib-register-node () (interactive)
56 (fix-initializer "VLIB_REGISTER_NODE *("))
59 ;; Driver routine which runs the set of keyboard macros
60 ;; defined above, as well as the bottom boilerplate lisp fn.
62 (defun fd-io-styleify () (interactive)
64 (fix-vlib-register-thread)
65 (fix-vlib-cli-command)
66 (fix-vlib-register-node)
67 (insert-style-boilerplate))
70 (while (elt argv index)
71 (message "Processing %s..." (elt argv index))
72 (find-file (elt argv index))
74 (setq index (1+ index)))
75 (save-buffers-kill-emacs t)