Clojure-mode for Emacs will clobber any line-final commas, even if they’re embedded in a string literal. O_o
Demonstration: Create a file test.clj. (Make sure it’s using clojure-mode, of course.) Add the following:
"A long multiline string literal,
which has a line ending in a comma.")
Hit C-x C-s and watch the comma disappear. WTF?
I opened a bug for this at GitHub, where technomancy identifies “delete-trailing-whitespace enabled as a before-save-hook” as the culprit, along with comma being mistakenly identified as “whitespace”. I didn’t think I had “delete-trailing-whitespace” enabled (it’s not in my
.emacs, at least.) I suppose it’s either enabled by default in AquaMacs, or else some mode enables it.
I found the problem. Emacs’ Rails mode (
emacs-rails/untabify-file.el at line 54, specifically) does
(add-hook 'write-file-hooks 'untabify-before-write)
This sets a (global!) write-file-hook. Untabify, in turn, calls
delete-trailing-whitespace. Clojure-mode defines commas to be whitespace (even in string literals!), so they get clobbered.
(remove-hook 'write-file-hooks 'untabify-before-write)
.emacs, after rails-mode is loaded.