The comment macro is delightfully simple.
(defmacro comment
"Ignores body, yields nil"
{:added "1.0"}
[& body])
Can this be modified to censor out words? For example, can I replace my colleague's constant use of "f***" in the comment
macro just by editing the comment
macro itself? Or will the comment
macro's inherent non-evaluation of its body stop my little prank?
Example: I want to change (comment I f***ing hate this code)
to (comment I ducking hate this code)
.
The comment
already censors everything - the result of its evaluation is nil
.
Looks like you want to rewrite the source code instead of changing how clojure treats the body of the comment
. Sometimes teams run code formatter as a pre-commit hook. It should not be hard to replace all occurences of f***
with duck
with a sed command and set it as a pre-commit hook.
Alternative approach is to setup git filter that on checkout replaces duck
with f***
and on commit converts back. This way repository will be censored but local representation can be with profanity. https://www.agwa.name/projects/git-crypt/ uses this approach to keep local files decrypted but encrypted on remote.