<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Paul Legato &#187; emacs</title>
	<atom:link href="http://www.paullegato.com/blog/tag/emacs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.paullegato.com</link>
	<description></description>
	<lastBuildDate>Tue, 06 Dec 2011 00:52:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Emacs clojure-mode eats line-final commas on save?</title>
		<link>http://www.paullegato.com/blog/emacs-clojure-mode-commas/</link>
		<comments>http://www.paullegato.com/blog/emacs-clojure-mode-commas/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 06:41:53 +0000</pubDate>
		<dc:creator>Paul Legato</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://www.paullegato.com/?p=61</guid>
		<description><![CDATA[Clojure-mode for Emacs will clobber any line-final commas, even if they're embedded in a string literal. O_o]]></description>
			<content:encoded><![CDATA[<p>Clojure-mode for Emacs will clobber any line-final commas, even if they&#8217;re embedded in a string literal. O_o<span id="more-61"></span></p>
<p>Demonstration: Create a file test.clj. (Make sure it&#8217;s using clojure-mode, of course.) Add the following:<br />
<code><br />
(str<br />
"A long multiline string literal,<br />
which has a line ending in a comma.")<br />
</code><br />
Hit C-x C-s and watch the comma disappear. WTF?</p>
<h2>Update</h2>
<p>I opened <a target="_blank" href="http://github.com/jochu/clojure-mode/issues#issue/2"  class="broken_link">a bug for this at GitHub</a>, where technomancy identifies &#8220;delete-trailing-whitespace enabled as a before-save-hook&#8221; as the culprit, along with comma being mistakenly identified as &#8220;whitespace&#8221;. I didn&#8217;t think I had &#8220;delete-trailing-whitespace&#8221; enabled (it&#8217;s not in my <code>.emacs</code>, at least.) I suppose it&#8217;s either enabled by default in AquaMacs, or else some mode enables it.</p>
<h2>Update #2:</h2>
<p>I found the problem. Emacs&#8217; Rails mode (<code>emacs-rails/untabify-file.el</code> at line 54, specifically) does</p>
<pre class="brush: plain; title: ; notranslate">
(add-hook 'write-file-hooks 'untabify-before-write)
</pre>
<p>This sets a (global!) write-file-hook. Untabify, in turn, calls <code>delete-trailing-whitespace</code>. Clojure-mode defines commas to be whitespace (even in string literals!), so they get clobbered.</p>
<h3>Workaround:</h3>
<p>Add </p>
<pre class="brush: plain; title: ; notranslate">
(remove-hook 'write-file-hooks 'untabify-before-write)
</pre>
<p>to <code>.emacs</code>, after rails-mode is loaded.</p>
<img src="http://www.paullegato.com/?ak_action=api_record_view&id=61&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.paullegato.com/blog/emacs-clojure-mode-commas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

