Forum: CFEngine Help Subject: Re: tidy/prettyprint for cfengine3 ? Author: zzamboni Link to topic: https://cfengine.com/forum/read.php?3,25480,25502#msg-25502
Aleksey, This is the script I used to ensure consistent formatting on all the examples in my book. It uses Ted's emacs-mode in batch mode, and it only does indentation - there's no other reformatting taking place. It's essentially a beefed-up version of the one-liner Ted posted above, but it makes sure everything is properly loaded and sets up all the desired parameters, so it does not depend (too much) on how things are set in the .emacs file. It's also very crude - you need to at least change the load-path value in the emacs command. --Diego #!/bin/bash if [[ $# -eq 0 ]]; then FILES=src/*.cf else FILES="$@" fi for i in $FILES; do echo "Processing $i ..." emacs --batch $i --eval '(progn (add-to-list '"'"'load-path "/Users/zamboni/.emacs.d/packages") (require '"'"'cfengine) (push '"'"'("\\.cf\\'"'"'" . cfengine3-mode) auto-mode-alist) (setq-default cfengine-parameters-indent (quote (promise pname 2))) (setq-default indent-tabs-mode nil) (cfengine3-mode) (indent-region (point-min) (point-max) nil) (untabify (point-min) (point-max)))' --eval '(write-region (point-min) (point-max) "'`basename $i.new`'")' && mv $i.new $i done _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine