<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[(think)]]></title>
  <link href="http://bbatsov.github.com/atom.xml" rel="self"/>
  <link href="http://bbatsov.github.com/"/>
  <updated>2013-04-24T11:52:39+03:00</updated>
  <id>http://bbatsov.github.com/</id>
  <author>
    <name><![CDATA[Bozhidar Batsov]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[WikEmacs lives on under new stewardship]]></title>
    <link href="http://bbatsov.github.com/articles/2013/04/24/wikemacs-lives-on-under-new-stewardship/"/>
    <updated>2013-04-24T11:36:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2013/04/24/wikemacs-lives-on-under-new-stewardship</id>
    <content type="html"><![CDATA[<p>Several months passed since I stated my intent
<a href="articles/2013/01/27/the-wikemacs-experiment-is-over-long-live-emacswiki/">to shutdown WikEmacs</a>. While
I still consider the project a failed experiment and stand by
everything I wrote in that post, I have received since lots of messages from
people who were sad to see WikEmacs go. One person in particular,
<a href="https://twitter.com/holocronweaver">Jesse Johnson</a>, was committed to
seeing the project move forward and offered to take over its stewardship.</p>

<p>In the end I&#8217;ve decided that in spirit of the FOSS ideals I don&#8217;t have
the right to take away something people like and want to use(especially
given the fact that they contributed most of the content there) and
handed over the domain and the data to Jesse.</p>

<p><a href="http://wikemacs.org/index.php/Main_Page">WikEmacs</a> has been running
for a couple of weeks now under his management and will continue to
exist for a long time. If you liked the project I guess this is a good
moment to show you love and spread the word.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[RuboCop 0.6.0 released]]></title>
    <link href="http://bbatsov.github.com/articles/2013/04/23/rubocop-0-dot-6-0-released/"/>
    <updated>2013-04-23T14:46:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2013/04/23/rubocop-0-dot-6-0-released</id>
    <content type="html"><![CDATA[<p><a href="https://github.com/bbatsov/rubocop">RuboCop</a> 0.6.0 was just released!
It&#8217;s RuboCop&#8217;s biggest and most ambitious release yet.  Here&#8217;s the
highlights:</p>

<ul>
<li>15 new cops(checks)</li>
<li>Support for disabling cops locally in a file with <code>rubocop:disable</code> comments</li>
<li>Half a dozen bugs squashed</li>
<li>Small improvements across the board</li>
</ul>


<p>I guess the support for disabling cops locally deserves a bit of special treatment.</p>

<p>So here&#8217;s the basics - you&#8217;re now allowed to enable/disable certain cops
(checks) and to alter their behavior if they accept any parameters.</p>

<p>One or more individual cops can be disabled locally in a section of a
file by adding a comment such as:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># rubocop:disable LineLength, StringLiterals</span>
</span><span class='line'><span class="o">[.</span><span class="n">.</span><span class="o">.]</span>
</span><span class='line'><span class="c1"># rubocop:enable LineLength, StringLiterals</span>
</span></code></pre></td></tr></table></div></figure>


<p>You can also disable <em>all</em> cops with:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># rubocop:disable all</span>
</span><span class='line'><span class="o">[.</span><span class="n">.</span><span class="o">.]</span>
</span><span class='line'><span class="c1"># rubocop:enable all</span>
</span></code></pre></td></tr></table></div></figure>


<p>One or more cops can be disabled on a single line with an end-of-line
comment:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">for</span> <span class="n">x</span> <span class="k">in</span> <span class="p">(</span><span class="mi">0</span><span class="o">.</span><span class="n">.</span><span class="mi">19</span><span class="p">)</span> <span class="c1"># rubocop:disable AvoidFor</span>
</span></code></pre></td></tr></table></div></figure>


<p>You can see all the gory details in the
<a href="https://github.com/bbatsov/rubocop/blob/master/CHANGELOG.md">changelog</a>. I hope you&#8217;ll enjoy RuboCop 0.6.0!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[RuboCop]]></title>
    <link href="http://bbatsov.github.com/articles/2013/04/15/rubocop/"/>
    <updated>2013-04-15T17:22:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2013/04/15/rubocop</id>
    <content type="html"><![CDATA[<p>After I launched the
<a href="https://github.com/bbatsov/ruby-style-guide">Ruby Style Guide</a> I
often received requests to create a tool enforcing the rules in the guide
automatically.</p>

<p>Today this tool is a reality - meet
<a href="https://github.com/bbatsov/rubocop">RuboCop</a>. RuboCop already covers
a significant portion of the Guide, supports both MRI 1.9 and MRI 2.0
and has pretty neat Emacs integration(via
<a href="https://github.com/bbatsov/rubocop-emacs">rubocop.el</a> and
<a href="https://github.com/lunaryorn/flycheck">flycheck</a>).</p>

<p>I&#8217;d love to see more Ruby hackers check out RuboCop!</p>

<p>I&#8217;d love to thank all the great people who contributed code, issue
reports and ideas to RuboCop&#8217;s development and I sincerely hope many
Ruby hackers will find it useful!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Emacs Redux]]></title>
    <link href="http://bbatsov.github.com/articles/2013/04/15/emacs-redux/"/>
    <updated>2013-04-15T17:10:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2013/04/15/emacs-redux</id>
    <content type="html"><![CDATA[<p>I&#8217;ve recently launched a new blog dedicated to Emacs -
<a href="http://emacsredux.com/">Emacs Redux</a>.</p>

<p>There I’ll be sharing with you (hopefully) useful tips and tricks to
make your experience with Emacs more productive and more enjoyable.</p>

<p>I hope you&#8217;ll like it!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The WikEmacs Experiment is over! Long Live EmacsWiki!]]></title>
    <link href="http://bbatsov.github.com/articles/2013/01/27/the-wikemacs-experiment-is-over-long-live-emacswiki/"/>
    <updated>2013-01-27T09:23:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2013/01/27/the-wikemacs-experiment-is-over-long-live-emacswiki</id>
    <content type="html"><![CDATA[<p>Less than an year ago
<a href="http://batsov.com/articles/2012/03/20/die-emacswiki/">amid a lot of turmoil</a>
I&#8217;ve started
<a href="http://batsov.com/articles/2012/03/26/wikemacs-the-other-emacs-wiki/">an alternative to EmacsWiki</a>. The
project took off to a great start, but quickly lost traction and now
it&#8217;s time to face the truth - I had an assumption, it turned out it(I)
was wrong and I should come to terms with that.</p>

<p>It&#8217;s more than apparent at this point that the majority of the Emacs
community is happy with EmacsWiki and that&#8217;s fine by me. I&#8217;ll be
closing down WikEmacs after 2-3 months and I suggest that everyone who&#8217;s
contributed significant chunks of content to it migrate them to
EmacsWiki (I&#8217;ll personally move everything good I find). I don&#8217;t want
the work people have done to just disappear.</p>

<p>Given the small interest in WikEmacs I doubt that many will miss it. I
thank all the contributors and the supporters of the idea. In the long
term it would be better for us to have a single repository of Emacs
knowledge, that&#8217;s why I decided to terminate WikEmacs sooner rather than later.</p>

<p>I want to extend a big public apology to Alex Schroeder for my harsh
criticism of EmacsWiki.  One year later I see that stewarding
documentation projects and nurturing a healthy community around them
is much harder than writing software. I&#8217;m but a humble software
engineer and you&#8217;ll have to forgive me for my misguided actions.</p>

<p>I hope that something good has(will) come up from all this drama. At
the very least I urge everyone who cares for EmacsWiki to try and
clean up, extend and improve at least a couple of articles on subjects
that are of importance to him. I know that&#8217;s something I&#8217;ll be doing
from now on.</p>

<p>See you on EmacsWiki!</p>

<p>WikEmacs is dead! Long live the one true EmacsWiki!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Just juxt it!]]></title>
    <link href="http://bbatsov.github.com/articles/2013/01/20/just-juxt-it/"/>
    <updated>2013-01-20T18:16:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2013/01/20/just-juxt-it</id>
    <content type="html"><![CDATA[<p><code>juxt</code> is one remarkably useful core Clojure function, that doesn&#8217;t
seem to be widely used (or understood for that matter), but is part of
the arsenal of every experienced Clojure hacker.</p>

<p>Looking at the official docs you&#8217;ll see that <code>juxt</code> takes a set of
functions and returns a function that is the juxtaposition of those
functions. The returned function takes a variable number of
arguments, and returns a vector containing the result of applying each
function to the arguments (from left to right). Basically:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">((</span><span class="nf">juxt</span> <span class="nv">a</span> <span class="nv">b</span> <span class="nv">c</span><span class="p">)</span> <span class="nv">x</span><span class="p">)</span> <span class="nv">=&gt;</span> <span class="p">[(</span><span class="nf">a</span> <span class="nv">x</span><span class="p">)</span> <span class="p">(</span><span class="nf">b</span> <span class="nv">x</span><span class="p">)</span> <span class="p">(</span><span class="nf">c</span> <span class="nv">x</span><span class="p">)]</span>
</span></code></pre></td></tr></table></div></figure>


<p>At first glace that probably doesn&#8217;t seem particularly useful. Let&#8217;s
see some practical applications of <code>juxt</code>. What if we wanted to split
a sequence into two sequences - one with the values that satisfy some
predicate and one with the values that don&#8217;t. While there are many
ways to do so, <code>juxt</code> offers one particularly elegant:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="c1">;; illustration of the general idea</span>
</span><span class='line'><span class="p">((</span><span class="nf">juxt</span> <span class="nb">filter </span><span class="nv">remove</span><span class="p">)</span> <span class="nv">pred</span> <span class="nv">coll</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="c1">;; separate the even from the odd numbers</span>
</span><span class='line'><span class="p">((</span><span class="nf">juxt</span> <span class="nb">filter </span><span class="nv">remove</span><span class="p">)</span> <span class="nv">even?</span> <span class="p">(</span><span class="nb">range </span><span class="mi">1</span> <span class="mi">10</span><span class="p">))</span>
</span><span class='line'><span class="c1">;; =&gt; [(2 4 6 8) (1 3 5 7 9)]</span>
</span></code></pre></td></tr></table></div></figure>


<p><code>juxt</code> is also quite helpful when dealing with multiple map keys:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="c1">;; extract the values of a couple of maps keys</span>
</span><span class='line'><span class="p">((</span><span class="nf">juxt</span> <span class="ss">:alias</span> <span class="ss">:name</span><span class="p">)</span> <span class="p">{</span><span class="ss">:alias</span> <span class="s">&quot;Batman&quot;</span> <span class="ss">:name</span> <span class="s">&quot;Bruce Wayne&quot;</span><span class="p">})</span>
</span><span class='line'><span class="c1">;; =&gt; [&quot;Batman&quot; &quot;Bruce Wayne&quot;]</span>
</span><span class='line'>
</span><span class='line'><span class="c1">;; sort a vector of maps by a composite criteria</span>
</span><span class='line'><span class="p">(</span><span class="nb">sort-by </span><span class="p">(</span><span class="nf">juxt</span> <span class="ss">:alias</span> <span class="ss">:name</span><span class="p">)</span>
</span><span class='line'>         <span class="p">[{</span><span class="ss">:alias</span> <span class="s">&quot;Batman&quot;</span> <span class="ss">:name</span> <span class="s">&quot;Bruce Wayne&quot;</span><span class="p">}</span>
</span><span class='line'>          <span class="p">{</span><span class="ss">:alias</span> <span class="s">&quot;Robin&quot;</span> <span class="ss">:name</span> <span class="s">&quot;Jason Todd&quot;</span><span class="p">}</span>
</span><span class='line'>          <span class="p">{</span><span class="ss">:alias</span> <span class="s">&quot;Robin&quot;</span> <span class="ss">:name</span> <span class="s">&quot;Tim Drake&quot;</span><span class="p">}</span>
</span><span class='line'>          <span class="p">{</span><span class="ss">:alias</span> <span class="s">&quot;Robin&quot;</span> <span class="ss">:name</span> <span class="s">&quot;Dick Grayson&quot;</span><span class="p">}])</span>
</span><span class='line'>
</span><span class='line'><span class="c1">;; =&gt; ({:name &quot;Bruce Wayne&quot;, :alias &quot;Batman&quot;} {:name &quot;Dick Grayson&quot;, :alias &quot;Robin&quot;} {:name &quot;Jason Todd&quot;, :alias &quot;Robin&quot;} {:name &quot;Tim Drake&quot;, :alias &quot;Robin&quot;})</span>
</span></code></pre></td></tr></table></div></figure>


<p>Hopefully this short article has whetted your appetite and you&#8217;ll find
even more elegant uses for <code>juxt</code> in your code.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[drop-nth in Clojure]]></title>
    <link href="http://bbatsov.github.com/articles/2013/01/20/drop-nth-in-clojure/"/>
    <updated>2013-01-20T15:31:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2013/01/20/drop-nth-in-clojure</id>
    <content type="html"><![CDATA[<p>For some reason the standard Clojure library doesn&#8217;t have a <code>drop-nth</code>
function (although it has <code>take-nth</code>). Luckily implementing it is trivial:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">(</span><span class="kd">defn </span><span class="nv">drop-nth</span>
</span><span class='line'>  <span class="p">[</span><span class="nv">n</span> <span class="nv">coll</span><span class="p">]</span>
</span><span class='line'>  <span class="p">(</span><span class="nf">-&gt;&gt;</span> <span class="nv">coll</span>
</span><span class='line'>       <span class="p">(</span><span class="nb">map vector </span><span class="p">(</span><span class="nb">iterate inc </span><span class="mi">1</span><span class="p">))</span>
</span><span class='line'>       <span class="p">(</span><span class="nb">remove </span><span class="o">#</span><span class="p">(</span><span class="nb">zero? </span><span class="p">(</span><span class="nf">mod</span> <span class="p">(</span><span class="nb">first </span><span class="nv">%</span><span class="p">)</span> <span class="nv">n</span><span class="p">)))</span>
</span><span class='line'>       <span class="p">(</span><span class="nb">map </span><span class="nv">second</span><span class="p">)))</span>
</span></code></pre></td></tr></table></div></figure>


<p>Let&#8217;s try it out:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">(</span><span class="nf">drop-nth</span> <span class="mi">3</span> <span class="p">(</span><span class="nb">range </span><span class="mi">1</span> <span class="mi">10</span><span class="p">))</span>
</span><span class='line'><span class="c1">;; =&gt; (1 2 4 5 7 8)</span>
</span><span class='line'><span class="p">(</span><span class="nf">drop-nth</span> <span class="mi">5</span> <span class="p">(</span><span class="nb">range </span><span class="mi">1</span> <span class="mi">10</span><span class="p">))</span>
</span><span class='line'><span class="c1">;; =&gt; (1 2 3 4 6 7 8 9)</span>
</span><span class='line'><span class="p">(</span><span class="nf">drop-nth</span> <span class="mi">5</span> <span class="p">(</span><span class="nb">range </span><span class="mi">1</span> <span class="mi">20</span><span class="p">))</span>
</span><span class='line'><span class="c1">;; =&gt; (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19)</span>
</span></code></pre></td></tr></table></div></figure>


<p>Looks good to me. Hopefully it will be of some use to someone.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Emacs Tip #8: Manipulating Word Case]]></title>
    <link href="http://bbatsov.github.com/articles/2012/12/16/emacs-tip-number-8-manipulating-word-case/"/>
    <updated>2012-12-16T17:57:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2012/12/16/emacs-tip-number-8-manipulating-word-case</id>
    <content type="html"><![CDATA[<p>One operation that we have to do fairly often when editing text is
manipulating the case of words. The most popular case manipulations
are probably <strong>capitalize</strong>, <strong>convert to lowercase</strong> and <strong>convert to
uppercase</strong>. Emacs naturally has built-in commands for all of those.</p>

<p>Pressing <code>M-c</code> runs the command <code>capitalize-word</code>, which will
capitalize the next word and move the cursor after it. Pressing <code>M--
M-c</code> will capitalize the previous word without moving the cursor.</p>

<p>Pressing <code>M-l</code> runs the command <code>downcase-word</code>, which will lowercase
the next word and move the cursor after it. Pressing <code>M-- M-l</code> will
lowercase the previous word without moving the cursor.</p>

<p>Pressing <code>M-u</code> runs the command <code>upcase-word</code>, which will uppercase the
next word and move the cursor after it. Pressing <code>M-- M-u</code> will uppercase
the previous word without moving the cursor.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Deleting Remote Git Branches]]></title>
    <link href="http://bbatsov.github.com/articles/2012/12/16/deleting-remote-git-branches/"/>
    <updated>2012-12-16T10:10:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2012/12/16/deleting-remote-git-branches</id>
    <content type="html"><![CDATA[<p>This post is mostly a note to myself, since I constantly forget how to
delete remote Git branches.</p>

<p>The classic way to do so (introduced in Git 1.5) would be:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>git push origin :branch-to-delete
</span></code></pre></td></tr></table></div></figure>


<p>So, if I were migrating an application from MySQL to PostgreSQL I might want to delete
the <code>postgres</code> branch when I&#8217;m done:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>git push origin :postgres
</span></code></pre></td></tr></table></div></figure>


<p>You have to agree this syntax is hardly something one can easily
remember(and I&#8217;m extra certain nobody would have guessed it on their
own). Fortunately in Git 1.7 a nicer alternative to the above command
was introduced:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>git push origin --delete branch-to-delete
</span></code></pre></td></tr></table></div></figure>


<p>That&#8217;s all from me for today. Now go ahead and delete those unneeded Git branches.</p>

<p>P.S. GitHub users might also want to take a look at this
<a href="https://github.com/blog/1335-tidying-up-after-pull-requests">article</a>
describing recently added functionality to clean up after pull
requests.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Emacs 24.3 introduces native OSX full-screen support]]></title>
    <link href="http://bbatsov.github.com/articles/2012/12/09/emacs-24-dot-3-introduces-native-osx-full-screen-support/"/>
    <updated>2012-12-09T13:34:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2012/12/09/emacs-24-dot-3-introduces-native-osx-full-screen-support</id>
    <content type="html"><![CDATA[<p>One of the most requested Emacs features - native OSX Lion style
full-screen support has finally landed in Emacs 24.3 (due to be
released in a few months). If you&#8217;re eager to try it out right now
homebrew is a good option:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>brew install emacs --cocoa --use-git-head --HEAD
</span></code></pre></td></tr></table></div></figure>


<p>Homebrew&#8217;s devs have even backported the full-screen patch to Emacs
24.2, so if you&#8217;re not very adventurous you can just do:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>brew install emacs --cocoa
</span></code></pre></td></tr></table></div></figure>


<p>Alternatively you can install the
<a href="http://emacsformacosx.com/emacs-builds/Emacs-pretest-24.2.91-universal-10.6.8.dmg">Emacs 24.2.91 pretest</a>
(or a newer pretest/nightly build) from
<a href="http://emacsformacosx.com/">Emacs for Mac OSX</a>. Personally I
recommend this option, since cloning the Emacs git mirror (as homebrew
does) takes like forever.</p>

<p>Here&#8217;s the beast in action:</p>

<p><img src="http://bbatsov.github.com/images/articles/emacs-full-screen.png"></p>

<p>This was a short article, but I do hope you&#8217;ll find it useful.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[From Linux to OSX: Meet Your New Apps]]></title>
    <link href="http://bbatsov.github.com/articles/2012/12/09/from-linux-to-osx-meet-your-new-apps/"/>
    <updated>2012-12-09T11:41:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2012/12/09/from-linux-to-osx-meet-your-new-apps</id>
    <content type="html"><![CDATA[<h2>Prelude</h2>

<p>It&#8217;s time I resume what I started in
<a href="http://batsov.com/articles/2012/09/09/from-linux-to-osx-1-year-later/">my previous article documenting my first year as an OSX user</a>
a few months ago.</p>

<p>In this article I&#8217;ll focus primarily on the applications I&#8217;ve adopted
during my short time being a Mac OSX user, after being a GNU/Linux
user for quite some time before that. The focus of the article will be
mostly desktop applications, since the command-line tools are more or
less the same in both operating system. I will mention a couple of OSX
specific command-line tools near the end of the article though.</p>

<!--more-->


<h2>Productivity</h2>

<h3>Office Suite</h3>

<p>On Linux I was mostly using LibreOffice (chiefly its Impress
module) and while it did get the job done I wasn&#8217;t particularly
fond of it. At some point I was so frustrated with LibreOffice, that I
started running Microsoft Office with
<a href="http://www.codeweavers.com/products/">CodeWeavers CrossOver for Linux</a>. If
you like LibreOffice - it&#8217;s available on OSX as well. If you don&#8217;t
like it - you have some solid alternative available.</p>

<p>First, there is a native port of Microsoft Office for OSX. It&#8217;s a far
cry from the Windows version of the app, but it does have a few
advantages over LibreOffice. If you&#8217;re doing a lot of document
authoring and editing it might be a good option for you.</p>

<p>The other office suite you might want to explore is Apple&#8217;s own
<strong>iWorks</strong>. It has a few distinct advantages over Microsoft Office -
you can buy only the apps you need (as opposed to the whole suite), it
integrates great with the OS (but that&#8217;s hardly a suprise) and it&#8217;s
much cheaper. I only bought <strong>Pages</strong> (Apple&#8217;s <strong>Word</strong> alternative)
and <strong>Keynote</strong> (<strong>PowerPoint</strong> alternative). Pages is a so-so
application, but Keynote is simply fantastic. I write a lot of
presentations and for the first I actually enjoy the process.</p>

<h3>Instant Messaging</h3>

<h4>Skype</h4>

<p>Skype has a native client for OSX, that&#8217;s much more stable and
featureful than the Linux one.</p>

<h4>Pidgin/Kopete</h4>

<p>OSX Mountain Lion ships with an app similar to Pidgin and Kopete
called <strong>Messages</strong> (and iMessage in older OSX versions). It supports
a plethora of chat protocols, but it kept constantly disconnecting and
crashing for me, so I started looking for an
alternative. <a href="http://adium.im/">Adium</a> is a great free IM app that
supports many protocols and works flawlessly (at least for me), so I&#8217;d
recommend it to everyone.</p>

<h4>IRC</h4>

<p>If you&#8217;re in the market for an XChat replacement look no further than
<a href="http://colloquy.info/">Colloquy</a>. Personally I used Emacs&#8217;s ERC under
Linux and continue to use it under OSX as well.</p>

<h4>Twitter</h4>

<p>Twitter has an official desktop app for OSX, that&#8217;s available for free
in the Mac App store. It has one notable shortcoming - no retina
support. Rumour has it Twitter will kill the app in the future, but it
gets the job done for the time being and there are plenty of
alternatives lying around.</p>

<h3>Browser</h3>

<p>The default OSX browser Safari is great and has some fairly unique
features like pinch to zoom gesture support (smartphone users will
appreciate those). Unfortunately it has a pretty small selection of
plugins and might not be well suited for power users. I recommend the
use of Google Chrome on OSX, since Firefox really seems to lag in terms
of features there (the upcoming Firefox 18 will be the first with
Retina support).</p>

<h3>Email</h3>

<p>OSX&#8217;s default application <strong>Mail</strong> is decent, but nothing
more. Thunderbird is available for OSX, but I personally think it&#8217;s no
better than Mail. My desktop email client of choice is the delightful
<a href="http://www.sparrowmailapp.com/mac.php">Sparrow</a>. It&#8217;s the first
desktop email client I ever liked (I used to check my email with
terminal clients and Emacs afterwards) and has great integration with
GMail (it even supports GMail&#8217;s keyboard shortcuts), Dropbox,
Facebook, etc. While it&#8217;s a doomed product since
<a href="http://www.sparrowmailapp.com/">Google acquired Sparrow</a> I plan to
continue using it in the foreseeable future.</p>

<h3>Keyboard remapping</h3>

<p>By default you cannot remap that many things in OSX. The small utility
<a href="http://pqrs.org/macosx/keyremap4macbook/">KeyRemap4MacBook</a> allows
you to do much crazier remappings and despite its name the tool works
on all recent Macs.</p>

<h3>Virtualization Software</h3>

<p>The go-to desktop virtualization solution favoured by most Linux users
is VirtualBox and it&#8217;s available for OSX as well. VirtualBox gets the
job done, but doesn&#8217;t even come close to
<a href="http://www.parallels.com/">Parallels</a> in terms of performance,
stability and integration with OSX. Parallels support for Windows
guests is particularly good.</p>

<h2>Software Development</h2>

<h3>Text Editing</h3>

<p>Every major text editor has a port for OSX, so things are pretty
much the same here. On OSX you&#8217;ll also get access to
<a href="http://macromates.com/">TextMate</a>. My affection for Emacs is widely
known though. Excellent Emacs builds are available
<a href="http://emacsformacosx.com/">here</a> and the upcoming Emacs 24.3 will
finally feature OSX Lion style full-screen support. If the mention of
Emacs and vim scares you I&#8217;d recommend trying out
<a href="http://www.sublimetext.com/2">Sublime Text 2</a>.</p>

<h3>IDEs</h3>

<p>Eclipse, NetBeans and IntelliJ are available (no suprise since they
are all Java apps) and look and perform great on OSX. There&#8217;s also
Apple&#8217;s own XCode, which I found unwieldy.</p>

<h3>Terminal Emulator</h3>

<p>OSX comes with a pretty barebone terminal emulator called
<strong>Terminal</strong>. I wouldn&#8217;t advice anyone to spent much time with it.</p>

<p>Install <a href="http://www.iterm2.com/#/section/home">iTerm2</a>. It redefines
the meaning of insanely great.</p>

<h3>Shells</h3>

<p>OSX comes with Bash enabled by default, but Zsh is also preinstalled
and you can easily enable it by typing:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>chsh -s /bin/zsh
</span></code></pre></td></tr></table></div></figure>


<h2>Media</h2>

<h3>Video player</h3>

<p>As in Linux <a href="http://www.videolan.org/vlc/index.html">VLC</a> is the king.</p>

<h3>Audio player</h3>

<p>iTunes fits the bill for a basic music player. I still haven&#8217;t found an
OSX app which I like as much as Linux&#8217;s Amarok and Exaile.</p>

<h3>UPnP server</h3>

<p>Under Linux I used to use MediaTomb and it performed great. It&#8217;s
available for OSX as well, but was causing a lot of problems for me,
so I finally decided to go with a commercial solution. I heartily
recommend <a href="http://www.yazsoft.com/products/playback/">Playback</a>. Of
course if your media player supports NFS you should go with it instead
of UPnP.</p>

<h2>File Transfer</h2>

<h3>FTP</h3>

<p><a href="http://filezilla-project.org/download.php?type=client">Filezilla</a> is
extremely popular under Linux and has a native OSX version as
well. <a href="http://cyberduck.ch/">Cyberduck</a> seems to be the top choice of
OSX users.</p>

<h3>Bittorrent</h3>

<p>There are plenty of great Bittorrent clients on Linux - Deluge,
KTorrent, Transmission, etc. Transmission is the only with an OSX port
and it seems that it&#8217;s also the only popular OSX torrent client.</p>

<h2>Package Management</h2>

<p>OSX has no official package managent tool but it has plenty of
unofficial ones. Currently
<a href="http://mxcl.github.com/homebrew/">homebrew</a> seems to be the most
popular option. Its package selection is quite vast and I&#8217;ve rarely
experienced problems with it. While regular users are unlikely to use
anything from outside the Mac App store, developers and power users
should definitely check homebrew out.</p>

<h2>Command Line</h2>

<p>Most of the command line applications that you know and love from
Linux are available in OSX (by default or installable via homebrew) as
well (but might be slightly different since Linux ships with GNU&#8217;s
version of many tools and OSX with BSD&#8217;s). Here&#8217;s a few notable OSX
specific commands:</p>

<ul>
<li><code>open</code> - opens a file or directory in the appropriate desktop application</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>open doc.pdf
</span></code></pre></td></tr></table></div></figure>


<ul>
<li><p><code>pbcopy</code> and <code>pbpaste</code> allow you to interact with OSX&#8217;s clipboard</p></li>
<li><p><code>launchctl</code> is a rough equivalent to the <code>service</code> and <code>chkconfig</code> commands on some Linux distros</p></li>
<li><p><code>fs_usage</code> allows you to monitor your filesystem usage statistics</p></li>
<li><p><code>system_profiler</code> gives you information about your hardware configuration (kind of like <code>lshw</code>)</p></li>
</ul>


<h2>Epilogue</h2>

<p>This was a whirlwind tour of so many apps. I hope that my superficial
treatment of many of them won&#8217;t stop you from trying them out. It
seems to me that the app selection catalogue on OSX is not as vast as
the one on Linux, but there&#8217;s also a tendency that established OSX
apps are much more polished and reliable.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Dealing with SSL certificate validation errors in Rails]]></title>
    <link href="http://bbatsov.github.com/articles/2012/12/06/dealing-with-ssl-certificate-validation-errors-in-rails/"/>
    <updated>2012-12-06T17:07:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2012/12/06/dealing-with-ssl-certificate-validation-errors-in-rails</id>
    <content type="html"><![CDATA[<p>I often see this question asked - &#8220;I&#8217;m getting the following error</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>OpenSSL::SSL::SSLError: hostname was not match with the server certificate</span></code></pre></td></tr></table></div></figure>


<p>when trying to deliver an email with Rails 3. How can I solve the problem?&#8221;</p>

<p>Obviously the best solution would be get a valid certificate for your hostname, but sometimes
this is not possible or you simply don&#8217;t want to bother with this stuff (on your development machine for instance).
The solution to the problem commonly suggested is to turn off encryption completely like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="no">ActionMailer</span><span class="o">::</span><span class="no">Base</span><span class="o">.</span><span class="n">smtp_settings</span> <span class="o">=</span> <span class="p">{</span>
</span><span class='line'>  <span class="ss">:address</span>              <span class="o">=&gt;</span> <span class="s1">&#39;mail.foo.com&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:port</span>                 <span class="o">=&gt;</span> <span class="mi">587</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:domain</span>               <span class="o">=&gt;</span> <span class="s1">&#39;foo.com&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:user_name</span>            <span class="o">=&gt;</span> <span class="s1">&#39;addy@foo.com&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:password</span>             <span class="o">=&gt;</span> <span class="s1">&#39;foofoo&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:authentication</span>       <span class="o">=&gt;</span> <span class="s1">&#39;plain&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:enable_starttls_auto</span> <span class="o">=&gt;</span> <span class="kp">true</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>This bit of code represent a portion of your <code>ActionMailer</code> configuration and you&#8217;d put it in <code>application.rb</code> or
<code>env.rb</code> (where env is something like <code>development</code>, <code>staging</code>, <code>production</code>, etc).</p>

<p>While the solution is OK for <code>development.rb</code> you&#8217;d be crazy to use
this code in production! Disabling encryption means that your username
and password will traverse the Internet in plain text! A simple, but
secure solution would be to just disable the certificate validation,
without sacrificing the secure connection:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="no">ActionMailer</span><span class="o">::</span><span class="no">Base</span><span class="o">.</span><span class="n">smtp_settings</span> <span class="o">=</span> <span class="p">{</span>
</span><span class='line'>  <span class="ss">:address</span>              <span class="o">=&gt;</span> <span class="s1">&#39;mail.foo.com&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:port</span>                 <span class="o">=&gt;</span> <span class="mi">587</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:domain</span>               <span class="o">=&gt;</span> <span class="s1">&#39;foo.com&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:user_name</span>            <span class="o">=&gt;</span> <span class="s1">&#39;addy@foo.com&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:password</span>             <span class="o">=&gt;</span> <span class="s1">&#39;foofoo&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:authentication</span>       <span class="o">=&gt;</span> <span class="s1">&#39;plain&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:enable_starttls_auto</span> <span class="o">=&gt;</span> <span class="kp">true</span><span class="p">,</span>
</span><span class='line'>  <span class="ss">:openssl_verify_mode</span>  <span class="o">=&gt;</span> <span class="s1">&#39;none&#39;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>This code snippet is mostly the same as the one shown before. The crucial difference is the line
<code>:openssl_verify_mode =&gt; 'none'</code>.</p>

<p>I hope someone will find this short article useful. Happy hacking!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Emacs Tip #7: Remap Return to Control in OSX]]></title>
    <link href="http://bbatsov.github.com/articles/2012/12/06/emacs-tip-number-7-remap-return-to-control-in-osx/"/>
    <updated>2012-12-06T16:06:00+02:00</updated>
    <id>http://bbatsov.github.com/articles/2012/12/06/emacs-tip-number-7-remap-return-to-control-in-osx</id>
    <content type="html"><![CDATA[<p>One of the major problems when using
<a href="http://batsov.com/articles/2012/10/14/emacs-on-osx/">Emacs on OSX</a> is
not related to OSX itself - the problem has to do with the Mac&#8217;s
hardware. Recent Mac keyboards(both laptop and desktop, with the
exception of the wired full size Mac keyboard) lack a right <code>Control</code>
key and it happens to be extremely important if you&#8217;re looking to
fully leverage the power of Emacs.</p>

<p>The traditional solution to the problem is to use a tool like
<a href="http://pqrs.org/macosx/keyremap4macbook/">KeyRemap4MacBook</a> to remap
the right <code>Option</code> key to right <code>Control</code> and to use a snippet like
this to make <code>Command</code> behave like <code>Meta</code> in Emacs:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='cl'><span class='line'><span class="p">(</span><span class="k">setq</span> <span class="nv">mac-command-modifier</span> <span class="ss">&#39;meta</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>


<p>This works, but it&#8217;s hardly ideal since you&#8217;re remapping <code>Option</code> at
fairly low level and you won&#8217;t be able to use it anywhere as <code>Option</code>.</p>

<p>A much better idea would be to leverage a little know capability of
KeyRemap4MacBook (a great program which despite its name works with
desktop Macs as well) and map the <code>Return</code> key to <code>Control</code> only
when it&#8217;s held down (it will behave like a normal Return key in all
other situations). The option you&#8217;ll have to find in KeyRemap4MacBook
is in the <code>Change Return</code> section and it labeled <code>Return to Control_R
(+ When you type Return only, send Return)</code>.</p>

<p>This approach has several advantages.  First and foremost you&#8217;re not
sacrificing a valuable key like <code>Option</code>. Second - it&#8217;s much easier to
hit <code>Return</code> with your right pinky than it is to hit <code>Option</code>
(especially if you&#8217;re using a US layout keyboard - these have long
single row <code>Return</code> keys, compared to the short 2 row Returns found on
European keyboards). Lastly, if you&#8217;ve already remapped <code>CapsLock</code> to
<code>Control</code> (like so many people do) you&#8217;re getting a pretty symmetrical
mapping on the opposite side of your keyboard.</p>

<p>All in all - remapping <code>Return</code> to <code>Control</code> is a huge win if you&#8217;re
using heavily one of Apple&#8217;s smaller keyboards. Of course, if you have
the option to use an external keyboard you&#8217;d do yourself a solid if you
obtained a good full size keyboard like the
<a href="http://batsov.com/articles/2008/06/16/das-keyboard/">Das Keyboard</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Emacs Tip #6: Remove variable &amp; function definitions]]></title>
    <link href="http://bbatsov.github.com/articles/2012/10/20/emacs-tip-number-6-remove-variable-and-function-definitions/"/>
    <updated>2012-10-20T20:29:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2012/10/20/emacs-tip-number-6-remove-variable-and-function-definitions</id>
    <content type="html"><![CDATA[<p>From time to time you might want to void (unbind) a variable or a
function definition in Emacs. Most often you&#8217;ll probably be dealing
with variables created with <code>defvar</code> whose values you&#8217;ll want to
update.  The magic functions you need are the following:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='cl'><span class='line'><span class="c1">;; this will make the symbol my-nasty-variable&#39;s value void</span>
</span><span class='line'><span class="p">(</span><span class="nb">makunbound</span> <span class="ss">&#39;my-nasty-variable</span><span class="p">)</span>
</span><span class='line'><span class="c1">;; this will make the symbol my-nasty-function&#39;s</span>
</span><span class='line'><span class="c1">;; function definition void</span>
</span><span class='line'><span class="p">(</span><span class="nb">fmakunbound</span> <span class="ss">&#39;my-nasty-function</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>


<p>The names aren&#8217;t exactly intuitive and even I happen to forget them from time to
time. Now at least I&#8217;ll now where to look for them if that happens
again. :-)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Emacs on OSX]]></title>
    <link href="http://bbatsov.github.com/articles/2012/10/14/emacs-on-osx/"/>
    <updated>2012-10-14T22:03:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2012/10/14/emacs-on-osx</id>
    <content type="html"><![CDATA[<h2>Prelude</h2>

<p>In this article I&#8217;ll share with you a few tips and tricks about
running Emacs under the Max OSX operating system.</p>

<h2>Installation</h2>

<p>While Emacs is available for installation from
<a href="http://wikemacs.org/wiki/Installing_Emacs_on_OS_X">various sources</a>
I personally recommend you to use the
<a href="http://wikemacs.org/wiki/Installing_Emacs_on_OS_X">Emacs for Mac OSX binary distribution</a>.</p>

<p>Installation via Homebrew is also a decent option, although it more time consuming.</p>

<p>After the installation you might want to wipe out the ancient Emacs 22
that ships with OSX by default(its presence will only cause headaches, trust me):</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>sudo rm /usr/bin/emacs
</span><span class='line'><span class="nv">$ </span>sudo rm -rf /usr/share/emacs
</span></code></pre></td></tr></table></div></figure>


<p>Keep in mind that the OSX updates will (unfortunately) bring Emacs 22 back from the dead, so
you might consider altering your <code>PATH</code> instead.</p>

<p>Alternatively you can just create an alias in your shell and when you
invoke <code>emacs</code> it will run the newly installed version:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span><span class="nb">alias </span><span class="nv">emacs</span><span class="o">=</span><span class="s2">&quot;/Applications/Emacs.app/Contents/MacOS/Emacs&quot;</span>
</span></code></pre></td></tr></table></div></figure>


<p>If you installed via Homebrew that path might look like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span><span class="nb">alias </span><span class="nv">emacs</span><span class="o">=</span><span class="s2">&quot;/usr/local/Cellar/emacs/24.2/Emacs.app/Contents/MacOS/Emacs -nw&quot;</span>
</span></code></pre></td></tr></table></div></figure>


<p>To make it permanent, if using bash, add that line to
<code>~/.bash_profile</code>. zsh users will want to update <code>~/.zshrc</code> instead.</p>

<h2>Full-screen support</h2>

<p>The Homebrew Emacs formula includes a patch providing the <code>M-x
ns-toggle-fullscreen</code> command for switching between normal and
full-screen modes. It works well, but does not provide the typical OS
X Lion full-screen app experience. In particular, it remains on the
desktop, obscuring non-full-screen applications, rather than moving to
its own space. For OSX Lion style fullscreen support have a look at
this
<a href="http://sourcematters.org/2012/04/10/full-screen-emacs-24-for-os-x-lion.html">article</a>.</p>

<p>Another option that you might want to explore is
the <a href="http://osxdaily.com/2011/07/22/enable-full-screen-support-all-apps-os-x-lion-maximizer/">maximizer</a>
utility that brings full-screen support for all Cocoa apps under Lion.</p>

<h2>Keybindings</h2>

<p>I heartily recommend you to remap your <em>Caps Lock</em> key to <em>Control</em>. This
can be easily done via <em>Preferences -> Keyboard -> Modifier Keys</em>. If
you&#8217;re using a laptop keyboard or the bluetooth keyboard you&#8217;ll
definitely want to remap your right Option key to Control as
well. No one can use effectively Emacs without a right Control
key. Remapping it is a bit more involved and requires the use of the
third-party utility
<a href="http://pqrs.org/macosx/keyremap4macbook/">KeyRemap4MacBook</a>.</p>

<p>On a regular Mac keyboard you&#8217;ll probably want to map Command to Meta
and Option to Super. On an external Windows keyboard you&#8217;ll want to
map Command to Super and Option to Meta (on Windows keyboard the
Command and Option keys are swapped). Add this to your <code>init.el</code> (or
<code>.emacs</code>) file:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='cl'><span class='line'><span class="p">(</span><span class="k">setq</span> <span class="nv">mac-command-modifier</span> <span class="ss">&#39;super</span><span class="p">)</span>
</span><span class='line'><span class="p">(</span><span class="k">setq</span> <span class="nv">mac-option-modifier</span> <span class="ss">&#39;meta</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>


<p>If you often switch between your laptop keyboard and an external
Windows keyboard (like me) you might want to define this helper
command and bind it to some key combo (<code>C-c w</code> in the example):</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='cl'><span class='line'><span class="p">(</span><span class="nb">defun</span> <span class="nv">swap-meta-and-super</span> <span class="p">()</span>
</span><span class='line'>  <span class="s">&quot;Swap the mapping of meta and super. Very useful for people using their Mac</span>
</span><span class='line'><span class="s">with a Windows external keyboard from time to time.&quot;</span>
</span><span class='line'>  <span class="p">(</span><span class="nv">interactive</span><span class="p">)</span>
</span><span class='line'>  <span class="p">(</span><span class="k">if</span> <span class="p">(</span><span class="nb">eq</span> <span class="nv">mac-command-modifier</span> <span class="ss">&#39;super</span><span class="p">)</span>
</span><span class='line'>      <span class="p">(</span><span class="k">progn</span>
</span><span class='line'>        <span class="p">(</span><span class="k">setq</span> <span class="nv">mac-command-modifier</span> <span class="ss">&#39;meta</span><span class="p">)</span>
</span><span class='line'>        <span class="p">(</span><span class="k">setq</span> <span class="nv">mac-option-modifier</span> <span class="ss">&#39;super</span><span class="p">)</span>
</span><span class='line'>        <span class="p">(</span><span class="nv">message</span> <span class="s">&quot;Command is now bound to META and Option is bound to SUPER.&quot;</span><span class="p">))</span>
</span><span class='line'>    <span class="p">(</span><span class="k">progn</span>
</span><span class='line'>      <span class="p">(</span><span class="k">setq</span> <span class="nv">mac-command-modifier</span> <span class="ss">&#39;super</span><span class="p">)</span>
</span><span class='line'>      <span class="p">(</span><span class="k">setq</span> <span class="nv">mac-option-modifier</span> <span class="ss">&#39;meta</span><span class="p">)</span>
</span><span class='line'>      <span class="p">(</span><span class="nv">message</span> <span class="s">&quot;Command is now bound to SUPER and Option is bound to META.&quot;</span><span class="p">))))</span>
</span><span class='line'>
</span><span class='line'><span class="p">(</span><span class="nv">global-set-key</span> <span class="p">(</span><span class="nv">kbd</span> <span class="s">&quot;C-c w&quot;</span><span class="p">)</span> <span class="ss">&#39;swap-meta-and-super</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Setting the PATH variable</h2>

<p>Long story short - if you&#8217;re running Emacs from Spotlight (or any
other launcher for that matter) your <code>PATH</code> and <code>exec-path</code> variables
won&#8217;t be same as the ones in your shell (and that&#8217;s every nasty since
you want be able to run some external programs from Emacs). The best
way to handle this would be installing the package
<a href="https://github.com/purcell/exec-path-from-shell">exec-path-from-shell</a>
by Steve Purcell.</p>

<h2>Flyspell</h2>

<p>For flyspell to work correctly you&#8217;ll need to install aspell plus a few dictionaries.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>brew install aspell --lang<span class="o">=</span>en
</span></code></pre></td></tr></table></div></figure>


<h2>More goodies</h2>

<p>If you want to spare yourself part of the headache of configuring
Emacs on OSX and get a lot of extra firepower you might want to install
<a href="https://github.com/bbatsov/prelude">Emacs Prelude</a> - an enhanced
Emacs 24.x configuration (developed by yours truly) that should make
your experience with Emacs both more pleasant and more powerful.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Rails Tip #1: Use Pry Instead of irb for the Rails Console]]></title>
    <link href="http://bbatsov.github.com/articles/2012/10/14/rails-tip-number-1-use-pry-instead-of-irb-for-the-rails-console/"/>
    <updated>2012-10-14T18:06:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2012/10/14/rails-tip-number-1-use-pry-instead-of-irb-for-the-rails-console</id>
    <content type="html"><![CDATA[<p>This tip is going to be a really short one. Hopefully by now you&#8217;ve
heard about <a href="http://pryrepl.org/">pry</a> - a fantastic <code>irb</code>
replacement, that somewhat reminds me of the mighty Lisp REPLs. What
you might not know is how to hook it into Rails so that the <code>rails
console</code> (a.k.a. <code>rails c</code>) command would fire a pry shell instead of
an irb one. There are several ways to do so, but I find one
particularly straightforward - the awesome little gem
<a href="https://github.com/rweng/pry-rails">pry-rails</a>.</p>

<p>So what are you waiting for? Go ahead, install the little sucker and
enjoy your new pry-powered Rails console.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ruby Tip #3: Matching on an Object's Class in a Case Expression]]></title>
    <link href="http://bbatsov.github.com/articles/2012/10/14/ruby-tip-number-3-matching-on-an-objects-class-in-a-case-expression/"/>
    <updated>2012-10-14T15:23:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2012/10/14/ruby-tip-number-3-matching-on-an-objects-class-in-a-case-expression</id>
    <content type="html"><![CDATA[<p>From time to time you might want to take different actions depending
on an object&#8217;s class. One handy way to do so is with a <code>case</code>
expression:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">case</span> <span class="n">object</span>
</span><span class='line'><span class="k">when</span> <span class="no">Fixnum</span> <span class="k">then</span> <span class="nb">puts</span> <span class="s1">&#39;Object is an integer number&#39;</span>
</span><span class='line'><span class="k">when</span> <span class="nb">String</span> <span class="k">then</span> <span class="nb">puts</span> <span class="s1">&#39;Object is a string&#39;</span>
</span><span class='line'><span class="k">when</span> <span class="no">Hash</span> <span class="k">then</span> <span class="nb">puts</span> <span class="s1">&#39;Object is a hash&#39;</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>Behind the scenes this is transformed to:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">if</span> <span class="no">Fixnum</span> <span class="o">===</span> <span class="n">object</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s1">&#39;Object is an integer number&#39;</span>
</span><span class='line'><span class="k">elsif</span> <span class="nb">String</span> <span class="o">===</span> <span class="n">object</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s1">&#39;Object is a string&#39;</span>
</span><span class='line'><span class="k">elsif</span> <span class="no">Hash</span> <span class="o">===</span> <span class="n">object</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s1">&#39;Object is a hash&#39;</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>A lot of people seem to make the following mistake, so beware:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># WRONG - Class === Class will return false</span>
</span><span class='line'><span class="k">case</span> <span class="n">object</span><span class="o">.</span><span class="n">class</span>
</span><span class='line'><span class="k">when</span> <span class="no">Fixnum</span> <span class="k">then</span> <span class="nb">puts</span> <span class="s1">&#39;Object is an integer number&#39;</span>
</span><span class='line'><span class="k">when</span> <span class="nb">String</span> <span class="k">then</span> <span class="nb">puts</span> <span class="s1">&#39;Object is a string&#39;</span>
</span><span class='line'><span class="k">when</span> <span class="no">Hash</span> <span class="k">then</span> <span class="nb">puts</span> <span class="s1">&#39;Object is a hash&#39;</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>Hopefully you&#8217;ll find this small tip useful.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Setting up fallback locale(s) in Rails 3]]></title>
    <link href="http://bbatsov.github.com/articles/2012/09/12/setting-up-fallback-locale-s-in-rails-3/"/>
    <updated>2012-09-12T14:56:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2012/09/12/setting-up-fallback-locale-s-in-rails-3</id>
    <content type="html"><![CDATA[<p>I18n(internationalization) and l10n(localization) are topics that are
covered superbly by the
<a href="http://guides.rubyonrails.org/i18n.html">Rails Guides</a>. The one thing
that&#8217;s left out is the setup of fallback locales in case something is
missing in the currently selected locale (and mark my words -
something probably is). Therefore I&#8217;m writing this
post.</p>

<p>Ideally we&#8217;d have i18n-ed and localized everything perfectly, but
that&#8217;s rarely the case. I&#8217;d rather have the users see things from
another locale than error messages. So how do we do that in Rails 3?
It&#8217;s pretty simple actually. There are three fallback options we can
select and they all require small changes to the <code>application.rb</code> file.</p>

<ul>
<li>fallback to the default locale</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># fallback to what&#39;s specified in config.i18n.default_locale</span>
</span><span class='line'><span class="n">config</span><span class="o">.</span><span class="n">i18n</span><span class="o">.</span><span class="n">fallbacks</span> <span class="o">=</span> <span class="kp">true</span>
</span></code></pre></td></tr></table></div></figure>


<ul>
<li>fallback to a specified locale</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># fallback to en, regardless of what&#39;s in config.i18n.default_locale</span>
</span><span class='line'><span class="n">config</span><span class="o">.</span><span class="n">i18n</span><span class="o">.</span><span class="n">fallbacks</span> <span class="o">=</span> <span class="o">[</span><span class="ss">:en</span><span class="o">]</span>
</span></code></pre></td></tr></table></div></figure>


<ul>
<li>specify a fallback map (different fallback locales for different
locales)</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># missing translations of es and fr languages will fallback to english</span>
</span><span class='line'><span class="c1"># missing translations in german will fallback to french</span>
</span><span class='line'><span class="n">config</span><span class="o">.</span><span class="n">i18n</span><span class="o">.</span><span class="n">fallbacks</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;es&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;en&#39;</span><span class="p">,</span> <span class="s1">&#39;fr&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;en&#39;</span><span class="p">,</span> <span class="s1">&#39;de&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;fr&#39;</span><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Well, that&#8217;s the gist of it. Happy coding!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[From Linux to OSX - 1 Year Later]]></title>
    <link href="http://bbatsov.github.com/articles/2012/09/09/from-linux-to-osx-1-year-later/"/>
    <updated>2012-09-09T22:11:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2012/09/09/from-linux-to-osx-1-year-later</id>
    <content type="html"><![CDATA[<h2>Prelude</h2>

<p>A little more than an year ago I wrote my rant post
<a href="http://batsov.com/articles/2011/06/11/linux-desktop-experience-killing-linux-on-the-desktop/">The Linux Desktop Experience is Killing Linux on the Desktop</a>
and for the first time in 8 years I wasn&#8217;t a desktop Linux user
anymore. I spent about a month wrestling with Windows 7, but let&#8217;s
face it - Windows is ill suited for professional Ruby programmers like
me (and it&#8217;s ill suited for most programmers, except maybe Java &amp; .Net I
guess).</p>

<p>Anyways, it was never my intention to stick with Windows - I was just
doing my Mac due diligence. Now with 1+ year of OSX usage I&#8217;d
like to share a few things about my experience thus far with you.</p>

<!--more-->


<h2>From Linux to OSX</h2>

<p>The transition was initially painful - I felt very odd dragging app
icons to the <code>Applications</code> folder to install them. To be honest I was
quite puzzled what was I supposed to do the first time I had to
install an app this way (it didn&#8217;t have those helpful hints with the arrows most apps
do). The Linux distro package management is definitely infinitely
better, or at least it seems so from where I&#8217;m standing. Luckily for me most of the
tools I use are available from the third-party <a href="http://mxcl.github.com/homebrew/">homebrew</a> package
manager for OSX. It&#8217;s like an extremely basic version of the mighty
Gentoo <code>portage</code>, but it generally gets the job done.</p>

<p>On a more positive note - I was impressed with the quality and
responsiveness of the OSX desktop and the fact that Emacs keybindings
are used by default in its editor toolkit (and strangely puzzled by
the lack of right control key - how is one supposed to hit <code>Control +
a</code> I dare ask?). One app in particular - <code>spotlight</code>, blew me off the
water, especially after having dealt on Linux with crappy clones like
<code>beagle</code> in the past. Spotlight can truly find just about anything,
was it&#8217;s own SQL-like query language and is <strong>blazingly</strong> fast.</p>

<p>I quickly found a good terminal emulator (that would be
<a href="http://www.iterm2.com/#/section/home">iterm2</a> - it&#8217;s actually the
best terminal emulator in the world IMHO) and
most of the command-line apps I used from day to day were already lying around
(after all OSX <strong>is</strong> Unix) - to my great surprise even stuff like PostgreSQL
(only on OSX Server) and <code>zsh</code> came preinstalled. Most of the other
apps I really needed had native OSX ports; the others - worthy
alternatives.</p>

<p>Having hated OpenOffice.org for many years I was very pleasantly
surprised by quality of apps like <code>Keynote</code> &amp; <code>Words</code>.</p>

<p>Being a keyboard chap preaching in the church of <code>Das Keyboard</code> I was
a bit underwhelmed by the whole multi-touch mumbo-jumbo at first, but
after a while I came to the conclusion that Apple have the only
trackpads and mice that are actually worth using (even though I still
like using the keyboard way more).</p>

<p>To sum it all up - I got up to speed fairly quickly, but it was a
bumpy ride.</p>

<p>Here&#8217;s a bit more details&#8230;</p>

<h2>The things I love about OSX</h2>

<h3>The Desktop</h3>

<p>It&#8217;s pretty, it&#8217;s quick, it&#8217;s stable. It makes KDE4 and GNOME3 look
like school projects in comparison. And did I mention that the fonts
on OSX are even prettier than the ones in Windows?</p>

<h3>The OSX flavored apps</h3>

<p><a href="http://sparrowapp.com/">Sparrow</a> is the first desktop mail client I ever liked (shame on
you Google for killing it).</p>

<p>iTerm2 is the ultimate terminal emulator. It alone warrants the
purchase of a Mac.</p>

<p>Keynote is the best presentation program I&#8217;ve come to use thus far.</p>

<p><a href="http://www.parallels.com/">Parallels Desktop</a> is light years ahead of VirtualBox and KVM (as far
as desktop virtualization is concerned).</p>

<p>I could go on a lot like this, but I&#8217;ll stop now.</p>

<p>It&#8217;s obvious that Mac users have developed a taste in extremely
refined software.</p>

<h3>Hardware compatibility</h3>

<p>If something is supposed to work with OSX - it works superbly
out-of-the-box. I&#8217;ve almost forgotten now the days of constant battle
with crappy hardware. Sleep &amp; Wake just work. Battery life is
exceptional (due to very advanced power management capabilities).</p>

<p>Certainly controlling all of the hardware an OS will run on helps a
lot, but we still have to acknowledge Apple&#8217;s achievement.</p>

<h3>Stability</h3>

<p>One year, three Macs - only two or three system crashes. For a
developer that likes to tinker a little bit more than he should -
that&#8217;s impressive.</p>

<p>That having said I had some Linux desktops that used run for more than
half an year without reboots (and the reboots were often caused by
power outages or distro/kernel updates). Linux stability on a (fairly
new) laptop? Well, that&#8217;s a whole different story&#8230;</p>

<h2>The things that are OK</h2>

<h3>The default apps</h3>

<p>The apps bundled with OSX are not bad at all, but they aren&#8217;t
particularly great. Still - Safari is a very good browser, Mail is a
much better desktop client than Evolution/Thunderbird, Calendar is a
good organizer (but a bit buggy when it comes down to Google Calendar
integration), Messages is so-so.</p>

<p>The bottom line is - you can go a long way with the bundled apps, but
they aren&#8217;t exactly perfect. My advice - shop for alternatives (both
open-source and proprietary).</p>

<h3>Mac App Store</h3>

<p>Decent way to distribute proprietary apps, but with all the
restrictions on the app sandboxing there aren&#8217;t many interesting apps
out there. Hopefully it&#8217;ll get better in time. The ability to upgrade
your OSX by purchasing the new version from the App Store is very cool
(for a proprietary OS of course).</p>

<h3>Emacs</h3>

<p>The Cocoa port of Emacs is a bit immature and there are some visual
glitches here and there (try out <code>M-x linum-mode</code> for instance), but
they are forgivable. I&#8217;m also missing the deep integration Emacs had with Linux.
And who the fuck designed all the official Mac keyboards without a
right control key? I finally understood why so many Mac users where on
vim :-)</p>

<p>Btw, remapping the <code>Caps</code> to <code>Control</code> is not the answer. I do it now,
I did it on Linux as well. You simply not supposed to hit Control +
any other key with the same hand. It&#8217;s disruptive to your
typing&#8230; But then again - you should probably do most of your typing
will a full sized keyboard :-)</p>

<h3>Software Development</h3>

<p>OSX doesn&#8217;t nurture software development as much as Linux does, but it
comes pretty close in second place. All the tools you know and love
are available, but their installation &amp; setup is a little bit more
involved on OSX. There is a reason why the screenshots in most
programming books show OSX.</p>

<h3>System administration</h3>

<p>Definitely a step back from Linux. Programs like <code>launchctl</code> (for instance) are not
exactly fun to work with, but they do get the job done. I&#8217;d never use
an OSX box for anything more than a desktop workstation. Setting up a
sensible <code>$PATH</code> is not as trivial as it was on Linux either
(<code>/etc/paths</code> and some plist I forgotten come to mind).</p>

<h2>The things I hate</h2>

<h3>The special keys</h3>

<p>Not exactly an OSX feature, but still&#8230;</p>

<p>One year and I still hate <code>Command</code> and <code>Option</code> - option is basically <code>Alt</code>
on a strange location and Command is totally useless IMHO. I&#8217;d
probably wouldn&#8217;t have hated them as much if there were room left on
the Apple keyboards (expect of course the old wired Apple keyboard) for an addition control key. Luckily for me I use an
external
<a href="http://batsov.com/articles/2008/06/16/das-keyboard/">Das Keyboard Ultimate</a>
most of the time&#8230;</p>

<p>Command and Option do have some value, I&#8217;d probably would have
appreciated it if they didn&#8217;t come at the cost of my beloved right
control (which I guess only Emacs users are missing anyways).</p>

<h3>No standard all mighty package manager</h3>

<p>On Linux I had <code>aptitude</code>, <code>yum</code>, <code>portage</code> and <code>pacman</code> - all amazing at what
they do. On OSX - <code>homebrew</code> is a decent option, but it&#8217;s a far cry from
the might and magic of the Linux package managers. Still, <code>homebrew</code>
is better than it&#8217;s alternative, so beware!</p>

<h3>Ugly XML config files</h3>

<p>Here and there in OSX you have to write some appalling <a href="http://en.wikipedia.org/wiki/Property_list">XML config
files</a>. I thought I&#8217;d never see the likes of those again after I put
Java development behind me :-)</p>

<h3>XCode</h3>

<p>You need to install a giant lame IDE just to get a bunch of command
line development tools? That&#8217;s one of the most annoying things I&#8217;ve
encountered up-to-date in OSX.</p>

<p>Yep, I know about the tools being available
<a href="http://kennethreitz.com/xcode-gcc-and-homebrew.html">separately</a> for
couple of months now, but requesting an Apple developer registration
just to get them seems a bit to much to me.</p>

<h2>Epilogue</h2>

<p>Am I happier now without Linux? Definitely! Is OSX a better OS than
Linux? Absolutely not! It does have a <strong>much</strong> better desktop
experience and since I spend most of the time on a computer
interacting with the desktop - that&#8217;s a big win for me. Of course I
wouldn&#8217;t mind seeing Linux achieve this level of desktop maturity and
stability.</p>

<p>Should you dump Linux and join me in <strong>darkness</strong>? How the hell should
I know? :-) I&#8217;m just sharing my two cents - if you&#8217;re happy using
Linux you should <strong>definitely</strong> stick with it. Obviously I wasn&#8217;t and
there weren&#8217;t that many alternatives lying around.</p>

<p>Not having to deal with hardware problems and immature desktop apps is
like a breath of fresh air and it more than compensates for the few
shortcomings of OSX. Nothing compensates the lack of that right
control key on most keyboards, but after all that&#8217;s not an OS problem
;-)</p>

<p>There is great vibrant hacker community gathered around OSX and it&#8217;s
one of the main driving forces of the OS. There is unfortunately a lot
of corporate pressure from Apple as well, but as you already know by
now - there are never perfect things, there are always
compromises. I&#8217;d rather use a proprietary OS that stays out of my way,
than a free OS into which I bump at every turn.</p>

<p>Soon I&#8217;ll blog a little bit more about the practical aspects and
implication of the migration. Cheers, mates!</p>

<p><strong>P.S. I&#8217;ve updated the original post a bit to reflect some of the
initial feedback I received.</strong></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[guru-mode]]></title>
    <link href="http://bbatsov.github.com/articles/2012/09/09/guru-mode/"/>
    <updated>2012-09-09T21:17:00+03:00</updated>
    <id>http://bbatsov.github.com/articles/2012/09/09/guru-mode</id>
    <content type="html"><![CDATA[<p>Getting started with Emacs is hard. That&#8217;s a fact of life and you
shouldn&#8217;t believe anyone telling you otherwise.</p>

<p>One of the harder parts of the journey to Emacs mastery is remembering
all those keybindings at the beginning (<code>C-h t</code>), which can be really
overwhelming. To make matters worse for many common commands there are
two sets of keybindings - the Emacs ones (that are touch typing
friendly) and the popular ones (that typically involve the use of the
arrow keys). Most people never get to use the <em>proper</em> keybindings and
forever make use of the arrow keys.</p>

<p>To help Emacs newcomers get used to the proper Emacs keybindings I&#8217;ve
created <a href="http://github.com/bbatsov/guru-mode">guru-mode</a> - a simple
minor mode that will show you a (helpful) message in the minibuffer
every time you try to use a <em>non Emacs way</em> keybinding.</p>

<p><img src="http://bbatsov.github.com/images/articles/guru-mode.png"></p>

<p>It will probably annoy you <strong>a lot</strong> in the beginning, but trust me -
it&#8217;ll be worth it in the long run.</p>

<p><code>guru-mode</code> comes bundled with
<a href="http://github.com/bbatsov/prelude">Emacs Prelude</a> and is available
for installation from <a href="http://marmalade-repo.org">Marmalade</a> and <a href="http://melpa.milkbox.net">MELPA</a>.</p>

<p>P.S. True Emacs mastery cannot be achieved if you do not practice
touch typing; if you&#8217;re doing hunt-and-peck typing you&#8217;d better fire up the
venerable <code>gtypist</code> before looking at <code>guru-mode</code>.</p>
]]></content>
  </entry>
  
</feed>
