<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: TextMate Emacs-like indentation (for R files)</title>
	<atom:link href="http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sun, 08 Feb 2009 10:43:07 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: VaudtVarken</title>
		<link>http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-7</link>
		<dc:creator>VaudtVarken</dc:creator>
		<pubDate>Sun, 08 Feb 2009 10:43:07 +0000</pubDate>
		<guid isPermaLink="false">http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-7</guid>
		<description>@Dan
Your solution doesn&#039;t indent the code.
Try indenting a line that&#039;s not in a function and that contains x&lt;-rnorm(mean=0,sd=1,100) ; # generate a 100 normally distributed numbers
Your solution is static.</description>
		<content:encoded><![CDATA[<p>@Dan<br />
Your solution doesn&#8217;t indent the code.<br />
Try indenting a line that&#8217;s not in a function and that contains x&lt;-rnorm(mean=0,sd=1,100) ; # generate a 100 normally distributed numbers<br />
Your solution is static.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Gunter</title>
		<link>http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-6</link>
		<dc:creator>Dan Gunter</dc:creator>
		<pubDate>Wed, 03 Dec 2008 01:25:17 +0000</pubDate>
		<guid isPermaLink="false">http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-6</guid>
		<description>You can also use R itself to do this, as documented in the R Extensions manual under &quot;Tidying R Code&quot;

options(keep.source = FALSE)
source(”myfuns.R”)
dump(ls(all = TRUE), file = “new.myfuns.R”)</description>
		<content:encoded><![CDATA[<p>You can also use R itself to do this, as documented in the R Extensions manual under &#8220;Tidying R Code&#8221;</p>
<p>options(keep.source = FALSE)<br />
source(”myfuns.R”)<br />
dump(ls(all = TRUE), file = “new.myfuns.R”)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NetLogger Blog &#187; Script to indent R code</title>
		<link>http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-5</link>
		<dc:creator>NetLogger Blog &#187; Script to indent R code</dc:creator>
		<pubDate>Tue, 02 Dec 2008 00:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-5</guid>
		<description>[...] found this page describing a way to do it with ESS (Emacs Speaks Statistics). So, I downloaded ESS from the ESS [...]</description>
		<content:encoded><![CDATA[<p>[...] found this page describing a way to do it with ESS (Emacs Speaks Statistics). So, I downloaded ESS from the ESS [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: i/o &#187; Blog Archive &#187; De-sucking Textmate indentation</title>
		<link>http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-4</link>
		<dc:creator>i/o &#187; Blog Archive &#187; De-sucking Textmate indentation</dc:creator>
		<pubDate>Sat, 27 Sep 2008 18:53:32 +0000</pubDate>
		<guid isPermaLink="false">http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-4</guid>
		<description>[...] I ran across this nice post to indent R files using Emacs in batch mode from Textmate. A very simple and effective idea (Emacs [...]</description>
		<content:encoded><![CDATA[<p>[...] I ran across this nice post to indent R files using Emacs in batch mode from Textmate. A very simple and effective idea (Emacs [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Murray</title>
		<link>http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-3</link>
		<dc:creator>Tom Murray</dc:creator>
		<pubDate>Sat, 27 Sep 2008 18:28:10 +0000</pubDate>
		<guid isPermaLink="false">http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/#comment-3</guid>
		<description>Great idea! Textmate&#039;s indentation drives me crazy, and sometimes makes me want to go back to really-long-command-strings-with-counter-intuitive-names-in-emacs. 

I did a little variant in Ruby that can handle any language for which an Emacs mode exists. It uses an external script file (this should be put in the Textmate support dir, but I&#039;m lazy) which takes the file extension as a parameter, so you can add &quot;Tidy&quot; commands to any Textmate language, like this:

/path/to/tidy.rb cpp      # C++
/path/to/tidy.rb ml        # OCaml ;-)
/path/to/tidy.rb java     # Java

Here&#039;s the code for tidy.rb itself:

#!/usr/bin/ruby


require &#039;ftools&#039;


# Use ending to tell Emacs what language mode to use.
ending = ARGV[0]
raise(&#039;No ending specified&#039;) if (ending.nil? &#124;&#124; ending.empty?)


# Handle selection (less useful, probably) or full file.
tmp_file = &quot;/tmp/textmate-tidy.#{$$}.#{ending}&quot;
selected = ENV[&#039;TM_SELECTED_TEXT&#039;] &#124;&#124; &#039;&#039;
if (selected.empty?)
    raise(&#039;No selected text or file.&#039;) if (ENV[&#039;TM_FILEPATH&#039;].empty?)
    File.copy(ENV[&#039;TM_FILEPATH&#039;], tmp_file)
else
    File.open(tmp_file, &#039;w&#039;) { &#124;fout&#124; fout.print selected }
end


# Do the indentation, loading user Emacs file (to handle user indent customizations).
user = ENV[&#039;USER&#039;] &#124;&#124; &#039;&#039;
user_opt = &quot;-u #{user}&quot; unless (user.empty?)
cmd = &quot;emacs -batch #{user_opt} &#039;#{tmp_file}&#039; -eval &#039;(indent-region (point-min) (point-max) nil)&#039; -f save-buffer &amp;&gt; /dev/null&quot;
system(cmd) &#124;&#124; raise(&quot;Failed to indent with Emacs.&quot;)
system(&quot;cat #{tmp_file}&quot;)
File.delete(tmp_file)</description>
		<content:encoded><![CDATA[<p>Great idea! Textmate&#8217;s indentation drives me crazy, and sometimes makes me want to go back to really-long-command-strings-with-counter-intuitive-names-in-emacs. </p>
<p>I did a little variant in Ruby that can handle any language for which an Emacs mode exists. It uses an external script file (this should be put in the Textmate support dir, but I&#8217;m lazy) which takes the file extension as a parameter, so you can add &#8220;Tidy&#8221; commands to any Textmate language, like this:</p>
<p>/path/to/tidy.rb cpp      # C++<br />
/path/to/tidy.rb ml        # OCaml <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
/path/to/tidy.rb java     # Java</p>
<p>Here&#8217;s the code for tidy.rb itself:</p>
<p>#!/usr/bin/ruby</p>
<p>require &#8216;ftools&#8217;</p>
<p># Use ending to tell Emacs what language mode to use.<br />
ending = ARGV[0]<br />
raise(&#8216;No ending specified&#8217;) if (ending.nil? || ending.empty?)</p>
<p># Handle selection (less useful, probably) or full file.<br />
tmp_file = &#8220;/tmp/textmate-tidy.#{$$}.#{ending}&#8221;<br />
selected = ENV['TM_SELECTED_TEXT'] || &#8221;<br />
if (selected.empty?)<br />
    raise(&#8216;No selected text or file.&#8217;) if (ENV['TM_FILEPATH'].empty?)<br />
    File.copy(ENV['TM_FILEPATH'], tmp_file)<br />
else<br />
    File.open(tmp_file, &#8216;w&#8217;) { |fout| fout.print selected }<br />
end</p>
<p># Do the indentation, loading user Emacs file (to handle user indent customizations).<br />
user = ENV['USER'] || &#8221;<br />
user_opt = &#8220;-u #{user}&#8221; unless (user.empty?)<br />
cmd = &#8220;emacs -batch #{user_opt} &#8216;#{tmp_file}&#8217; -eval &#8216;(indent-region (point-min) (point-max) nil)&#8217; -f save-buffer &amp;&gt; /dev/null&#8221;<br />
system(cmd) || raise(&#8220;Failed to indent with Emacs.&#8221;)<br />
system(&#8220;cat #{tmp_file}&#8221;)<br />
File.delete(tmp_file)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
