Reindent to the canonical stroustrup style
Whitespace only -- `git diff -w` is empty. TODO.md 2.3 recorded that the
tree mixed hard tabs and space indents within the same functions;
tests/aksl_capture.h was the worst of it, with the assertion macros
space-indented and everything around them tabbed.
The style is the one libakerror standardised on and the one AGENTS.md
already describes: Emacs cc-mode "stroustrup", c-basic-offset 4,
indent-tabs-mode on, tab-width 8. A correct file is a fixed point of
indent-region under those settings, and the tree is one now -- a second
pass produces no diff.
scripts/reindent.el is that pass, checked in so "correct" is something
you can run rather than something you have to remember. It is not
clang-format and deliberately so: AGENTS.md forbids introducing one
without discussion, and this is a good illustration of why. cc-mode
indents every declaration in akstdlib.h one level for the extern "C" { }
wrapping the file body, so the script sets inextern-lang to 0 -- a
cc-mode offset with no clang-format equivalent, and without it the first
run moved 364 lines in the wrong direction.
Its own commit, no behaviour change, and the suite is green either side.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
scripts/reindent.el
Normal file
25
scripts/reindent.el
Normal file
@@ -0,0 +1,25 @@
|
||||
;; Canonical reindent: Emacs cc-mode "stroustrup", c-basic-offset 4,
|
||||
;; indent-tabs-mode on, tab-width 8. A correct file is a fixed point of this.
|
||||
;;
|
||||
;; inextern-lang is set to 0 because akstdlib.h wraps its whole body in
|
||||
;; extern "C" { }, and cc-mode otherwise indents every declaration in the file
|
||||
;; one level for it. That is a real cc-mode behaviour rather than a bug, but it
|
||||
;; is not the house style and not what the file looked like before.
|
||||
;;
|
||||
;; AGENTS.md forbids introducing clang-format, and this is why the tool that
|
||||
;; decides what "correct" means has to be the same engine the author's editor
|
||||
;; runs: this offset is not something clang-format could be made to agree with.
|
||||
(require 'cc-mode)
|
||||
(setq-default indent-tabs-mode t)
|
||||
(setq-default tab-width 8)
|
||||
(setq c-default-style "stroustrup")
|
||||
(dolist (file command-line-args-left)
|
||||
(find-file file)
|
||||
(c-mode)
|
||||
(setq indent-tabs-mode t
|
||||
tab-width 8
|
||||
c-basic-offset 4)
|
||||
(c-set-offset 'inextern-lang 0)
|
||||
(indent-region (point-min) (point-max))
|
||||
(when (buffer-modified-p) (save-buffer))
|
||||
(kill-buffer))
|
||||
Reference in New Issue
Block a user