<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="http://www.hodique.info/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="http://www.hodique.info/feed.php">
        <title>Yann Hodique blog:2011</title>
        <description></description>
        <link>http://www.hodique.info/</link>
        <image rdf:resource="http://www.hodique.info/lib/tpl/arctic/images/favicon.ico" />
       <dc:date>2012-02-05T17:30:39+01:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://www.hodique.info/blog/2011/12/11/fixing_greek_characters_display"/>
                <rdf:li rdf:resource="http://www.hodique.info/blog/2011/11/04/a_mocking_framework_for_emacs"/>
                <rdf:li rdf:resource="http://www.hodique.info/blog/2011/08/12/org-mode_links_for_magit"/>
                <rdf:li rdf:resource="http://www.hodique.info/blog/2011/07/31/tweaking_zsh_completion_for_git_checkout"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://www.hodique.info/lib/tpl/arctic/images/favicon.ico">
        <title>Yann Hodique</title>
        <link>http://www.hodique.info/</link>
        <url>http://www.hodique.info/lib/tpl/arctic/images/favicon.ico</url>
    </image>
    <item rdf:about="http://www.hodique.info/blog/2011/12/11/fixing_greek_characters_display">
        <dc:format>text/html</dc:format>
        <dc:date>2011-12-11T16:35:13+01:00</dc:date>
        <dc:creator>Yann Hodique</dc:creator>
        <title>fixing greek characters display</title>
        <link>http://www.hodique.info/blog/2011/12/11/fixing_greek_characters_display</link>
        <description>
&lt;div class=&quot;level1&quot;&gt;
&lt;/p&gt;
&lt;div class=&quot;styler styler-float-left&quot;&gt;
&lt;p&gt;
&lt;span class=&quot;vcard&quot;&gt;&lt;img src=&quot;http://www.hodique.info/lib/exe/fetch.php?hash=15d77b&amp;amp;cache=recache&amp;amp;media=http%3A%2F%2Fwww.gravatar.com%2Favatar.php%3Fgravatar_id%3Dd9b955e7af49b0cbfd68c15947b25012%26default%3Dhttp%253A%252F%252Fwww.hodique.info%252Flib%252Fexe%252Ffetch.php%253Fhash%253Dd44619%2526cache%253Drecache%2526media%253Dhttp%25253A%25252F%25252Fwww.hodique.info%25252F%25252Flib%25252Fplugins%25252Favatar%25252Fmonsterid.php%25253Fseed%25253Dd9b955e7af49b0cbfd68c15947b25012%252526size%25253D40%252526.png%26size%3D40%26rating%3DR%26.jpg&quot; class=&quot;media photo fn&quot; title=&quot;&amp;#x79;&amp;#x61;&amp;#x6e;&amp;#x6e;&amp;#x2e;&amp;#x68;&amp;#x6f;&amp;#x64;&amp;#x69;&amp;#x71;&amp;#x75;&amp;#x65;&amp;#x40;&amp;#x67;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&quot; alt=&quot;&amp;#x79;&amp;#x61;&amp;#x6e;&amp;#x6e;&amp;#x2e;&amp;#x68;&amp;#x6f;&amp;#x64;&amp;#x69;&amp;#x71;&amp;#x75;&amp;#x65;&amp;#x40;&amp;#x67;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&quot; width=&quot;40&quot; height=&quot;40&quot; /&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
I generally like the &lt;a href=&quot;http://blog.mayfounder.net/2009/02/10/adding-a-new-ttf-font-to-linux/&quot; class=&quot;urlextern&quot; title=&quot;http://blog.mayfounder.net/2009/02/10/adding-a-new-ttf-font-to-linux/&quot;  rel=&quot;nofollow&quot;&gt;Monaco&lt;/a&gt; font, that I use for both Emacs and my rxvt-unicode terminals in GNU/Linux. In order to achieve this, I had the following in my &lt;code&gt;~/.Xdefaults&lt;/code&gt;:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;emacs*font: Monaco:pixelsize=13

urxvt*font: xft:Monaco:pixelsize=13&lt;/pre&gt;

&lt;p&gt;
Although it works perfectly fine for “normal text”, it does a disastrous job for fancier characters such as greek symbols. I don&amp;#039;t know much about fonts lookup, but I guess there&amp;#039;s a fallback mechanism to elect another font when the selected one does not contain the required symbols. 
&lt;/p&gt;

&lt;p&gt;
Anyway, as you can see in the following capture of my rxvt-unicode setup, it&amp;#039;s not exactly pretty (bottom left for the display before fixing). It gets mucc better after modifying my &lt;code&gt;~/.Xdefaults&lt;/code&gt; to contain:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;urxvt*font: xft:Monaco:pixelsize=13,xft:Monospace&lt;/pre&gt;

&lt;p&gt;
&lt;a href=&quot;http://www.hodique.info/_media/blog/2011/12/11/before_after_urxvt.png&quot; class=&quot;media&quot; title=&quot;blog:2011:12:11:before_after_urxvt.png&quot;&gt;&lt;img src=&quot;http://www.hodique.info/_media/blog/2011/12/11/before_after_urxvt.png?w=300&quot; class=&quot;media&quot; title=&quot;urxvt before and after fix&quot; alt=&quot;urxvt before and after fix&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Similarly for Emacs, the default display was not great (although at least readable). Putting something like the following in my &lt;code&gt;~/.emacs&lt;/code&gt; solved the issue for me.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;(set-fontset-font &amp;quot;fontset-default&amp;quot; &amp;#039;greek &amp;#039;(&amp;quot;dejavu sans mono&amp;quot;. &amp;quot;unicode-bmp&amp;quot;))&lt;/pre&gt;

&lt;p&gt;
&lt;a href=&quot;http://www.hodique.info/_media/blog/2011/12/11/before_after_emacs.png&quot; class=&quot;media&quot; title=&quot;blog:2011:12:11:before_after_emacs.png&quot;&gt;&lt;img src=&quot;http://www.hodique.info/_media/blog/2011/12/11/before_after_emacs.png?w=300&quot; class=&quot;media&quot; title=&quot;emacs before and after fix&quot; alt=&quot;emacs before and after fix&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
And now my Lisp lambdas can finally look good :)
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://www.hodique.info/tags/emacs&quot; class=&quot;wikilink1&quot; title=&quot;tags:emacs&quot; rel=&quot;tag&quot;&gt;emacs&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/urxvt?do=showtag&amp;amp;tag=tags%3Aurxvt&quot; class=&quot;wikilink1&quot; title=&quot;tags:urxvt&quot; rel=&quot;tag&quot;&gt;urxvt,&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/config&quot; class=&quot;wikilink1&quot; title=&quot;tags:config&quot; rel=&quot;tag&quot;&gt;config&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://www.hodique.info/blog/2011/12/11/fixing_greek_characters_display#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://www.hodique.info/blog/2011/11/04/a_mocking_framework_for_emacs">
        <dc:format>text/html</dc:format>
        <dc:date>2011-11-04T12:32:47+01:00</dc:date>
        <dc:creator>Yann Hodique</dc:creator>
        <title>A mocking framework for Emacs</title>
        <link>http://www.hodique.info/blog/2011/11/04/a_mocking_framework_for_emacs</link>
        <description>
&lt;div class=&quot;level1&quot;&gt;
&lt;/p&gt;
&lt;div class=&quot;styler styler-float-left&quot;&gt;
&lt;p&gt;
&lt;span class=&quot;vcard&quot;&gt;&lt;img src=&quot;http://www.hodique.info/lib/exe/fetch.php?hash=15d77b&amp;amp;cache=recache&amp;amp;media=http%3A%2F%2Fwww.gravatar.com%2Favatar.php%3Fgravatar_id%3Dd9b955e7af49b0cbfd68c15947b25012%26default%3Dhttp%253A%252F%252Fwww.hodique.info%252Flib%252Fexe%252Ffetch.php%253Fhash%253Dd44619%2526cache%253Drecache%2526media%253Dhttp%25253A%25252F%25252Fwww.hodique.info%25252F%25252Flib%25252Fplugins%25252Favatar%25252Fmonsterid.php%25253Fseed%25253Dd9b955e7af49b0cbfd68c15947b25012%252526size%25253D40%252526.png%26size%3D40%26rating%3DR%26.jpg&quot; class=&quot;media photo fn&quot; title=&quot;&amp;#x79;&amp;#x61;&amp;#x6e;&amp;#x6e;&amp;#x2e;&amp;#x68;&amp;#x6f;&amp;#x64;&amp;#x69;&amp;#x71;&amp;#x75;&amp;#x65;&amp;#x40;&amp;#x67;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&quot; alt=&quot;&amp;#x79;&amp;#x61;&amp;#x6e;&amp;#x6e;&amp;#x2e;&amp;#x68;&amp;#x6f;&amp;#x64;&amp;#x69;&amp;#x71;&amp;#x75;&amp;#x65;&amp;#x40;&amp;#x67;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&quot; width=&quot;40&quot; height=&quot;40&quot; /&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
As I&amp;#039;m currently trying to introduce some unit tests for Magit (see &lt;a href=&quot;https://github.com/magit/magit/tree/unit-tests&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/magit/magit/tree/unit-tests&quot;  rel=&quot;nofollow&quot;&gt;the unit-test branch&lt;/a&gt;) I realize I really need some mocking capabilities. For some reason, even though we now have a testing framework released with Emacs (&lt;a href=&quot;http://www.emacswiki.org/emacs/ErtTestLibrary&quot; class=&quot;urlextern&quot; title=&quot;http://www.emacswiki.org/emacs/ErtTestLibrary&quot;  rel=&quot;nofollow&quot;&gt;ERT&lt;/a&gt;), no mocking library found its way to the core (yet?).
&lt;/p&gt;

&lt;p&gt;
In its manual, ERT refers to the 3rd party &lt;a href=&quot;http://www.emacswiki.org/emacs/EmacsLispMock&quot; class=&quot;urlextern&quot; title=&quot;http://www.emacswiki.org/emacs/EmacsLispMock&quot;  rel=&quot;nofollow&quot;&gt;el-mock.el&lt;/a&gt;, but I don&amp;#039;t like the DSL approach too much (feels un-lispy to me) and it has definitions I strongly disagree with (“Mocks are temporary functions which accept specified arguments and return constant value.”) that make my life harder as a test writer.
In my opinion, mocks are supposed to work in a record/replay way, which implies to be able to record different outputs for different (or even same) inputs. Returning a constant value is more of a stub thing. Actually I don&amp;#039;t care too much about the naming, but I need the feature anyway :p
&lt;/p&gt;

&lt;p&gt;
So, even though it is really nice for basic mocking (and achieves very low verbosity), el-mock.el is just not flexible enough for my purpose.
&lt;/p&gt;

&lt;p&gt;
Here comes &lt;a href=&quot;https://github.com/sigma/mocker.el&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/sigma/mocker.el&quot;  rel=&quot;nofollow&quot;&gt;mocker.el&lt;/a&gt;, my attempt at achieving greater mocking flexibility.
Admittedly, this is much more verbose, but for some twisted reason I like it better this way :)
Note that the architecture is meant to be flexible, so in theory it would even be possible to define a way to express mocking expressions in a DSL similar to el-mock.el&amp;#039;s.
&lt;/p&gt;

&lt;p&gt;
2 quick examples taken from the documentation:
&lt;/p&gt;
&lt;pre class=&quot;code lang=&quot;lisp&quot;&gt;(mocker-let ((foo (x y z)
                  ((:input '(1 2 3) :output 4)
                   (:input '(4 5 6) :output 10)))
             (bar (x)
                  ((:input '(42) :output 4))))
  (+ (foo 1 2 3)
     (foo 4 5 6)
     (bar 42)))
&amp;nbsp;
;;; make `foo' generate the fibonacci suite, no matter how it's called
(mocker-let ((foo (x)
                  ((:input-matcher (lambda (x) t)
                    :output-generator (lexical-let ((x 0) (y 1))
                                        (lambda (any)
                                          (let ((z (+ x y)))
                                            (setq x y y z))))
                    :max-occur nil))))
  (* (foo 1) (foo 0) (foo 42)))&lt;/pre&gt;

&lt;p&gt;
For more details, please refer to the &lt;a href=&quot;https://github.com/sigma/mocker.el&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/sigma/mocker.el&quot;  rel=&quot;nofollow&quot;&gt;page of the project&lt;/a&gt;. Bottom line, &lt;code&gt;mocker-let&lt;/code&gt; is just a macro around &lt;code&gt;flet&lt;/code&gt; that specializes in recording expected behaviors, then consuming them.
&lt;/p&gt;

&lt;p&gt;
For what matters, I&amp;#039;d like it a lot if a proper mocking solution (whatever it may be) made its way to Emacs (as part of ERT or not). Maybe if there are enough people interested in this we can come up with something together :)
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://www.hodique.info/tags/emacs&quot; class=&quot;wikilink1&quot; title=&quot;tags:emacs&quot; rel=&quot;tag&quot;&gt;emacs&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/code&quot; class=&quot;wikilink1&quot; title=&quot;tags:code&quot; rel=&quot;tag&quot;&gt;code&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/testing&quot; class=&quot;wikilink1&quot; title=&quot;tags:testing&quot; rel=&quot;tag&quot;&gt;testing&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://www.hodique.info/blog/2011/11/04/a_mocking_framework_for_emacs#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://www.hodique.info/blog/2011/08/12/org-mode_links_for_magit">
        <dc:format>text/html</dc:format>
        <dc:date>2011-08-12T09:29:25+01:00</dc:date>
        <dc:creator>Yann Hodique</dc:creator>
        <title>Org-mode links for Magit</title>
        <link>http://www.hodique.info/blog/2011/08/12/org-mode_links_for_magit</link>
        <description>
&lt;div class=&quot;level1&quot;&gt;
&lt;/p&gt;
&lt;div class=&quot;styler styler-float-left&quot;&gt;
&lt;p&gt;
&lt;span class=&quot;vcard&quot;&gt;&lt;img src=&quot;http://www.hodique.info/lib/exe/fetch.php?hash=15d77b&amp;amp;cache=recache&amp;amp;media=http%3A%2F%2Fwww.gravatar.com%2Favatar.php%3Fgravatar_id%3Dd9b955e7af49b0cbfd68c15947b25012%26default%3Dhttp%253A%252F%252Fwww.hodique.info%252Flib%252Fexe%252Ffetch.php%253Fhash%253Dd44619%2526cache%253Drecache%2526media%253Dhttp%25253A%25252F%25252Fwww.hodique.info%25252F%25252Flib%25252Fplugins%25252Favatar%25252Fmonsterid.php%25253Fseed%25253Dd9b955e7af49b0cbfd68c15947b25012%252526size%25253D40%252526.png%26size%3D40%26rating%3DR%26.jpg&quot; class=&quot;media photo fn&quot; title=&quot;&amp;#x79;&amp;#x61;&amp;#x6e;&amp;#x6e;&amp;#x2e;&amp;#x68;&amp;#x6f;&amp;#x64;&amp;#x69;&amp;#x71;&amp;#x75;&amp;#x65;&amp;#x40;&amp;#x67;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&quot; alt=&quot;&amp;#x79;&amp;#x61;&amp;#x6e;&amp;#x6e;&amp;#x2e;&amp;#x68;&amp;#x6f;&amp;#x64;&amp;#x69;&amp;#x71;&amp;#x75;&amp;#x65;&amp;#x40;&amp;#x67;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&quot; width=&quot;40&quot; height=&quot;40&quot; /&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
Since some people seem to find it useful, let&amp;#039;s advertise it a bit :)
I&amp;#039;ve wrote a very small extension to &lt;a href=&quot;http://orgmode.org/&quot; class=&quot;urlextern&quot; title=&quot;http://orgmode.org/&quot;  rel=&quot;nofollow&quot;&gt;Org-Mode&lt;/a&gt; and &lt;a href=&quot;http://magit.github.com/magit/&quot; class=&quot;urlextern&quot; title=&quot;http://magit.github.com/magit/&quot;  rel=&quot;nofollow&quot;&gt;Magit&lt;/a&gt;, that allows me to put links to magit items in my org files.
See &lt;a href=&quot;https://github.com/sigma/org-magit&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/sigma/org-magit&quot;  rel=&quot;nofollow&quot;&gt;https://github.com/sigma/org-magit&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Currently 3 types of links are supported:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;magit:/path/to/repo::commit@&amp;lt;hash&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;magit:/path/to/repo::status&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;magit:/path/to/repo::log&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
But you probably don&amp;#039;t want to bother, and use &lt;code&gt;org-store-link&lt;/code&gt; from the target buffer.
&lt;/p&gt;

&lt;p&gt;
See the header of &lt;code&gt;org-magit.el&lt;/code&gt; for more information.
&lt;/p&gt;

&lt;p&gt;
Within emacs, opening those links will just invoke magit with the proper environment. When exporting to &lt;acronym title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/acronym&gt;, this extension tries to convert the links to something meaningful, using a list of web frontend and their &lt;acronym title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/acronym&gt; schemes. Only &lt;a href=&quot;http://github.com&quot; class=&quot;urlextern&quot; title=&quot;http://github.com&quot;  rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt; is provided out of the box, but nothing prevents from adding more. Actually I&amp;#039;m doing exactly that to point to an internal &lt;a href=&quot;http://hjemli.net/git/cgit/about/&quot; class=&quot;urlextern&quot; title=&quot;http://hjemli.net/git/cgit/about/&quot;  rel=&quot;nofollow&quot;&gt;cgit&lt;/a&gt; instance I have at work.
&lt;/p&gt;

&lt;p&gt;
I&amp;#039;m using this as a set of bookmarks, and also to link actual commits to my development tasks.
&lt;/p&gt;

&lt;p&gt;
(once I&amp;#039;m done with a couple of improvements, I&amp;#039;ll definitely push into magit contrib)
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://www.hodique.info/tags/emacs&quot; class=&quot;wikilink1&quot; title=&quot;tags:emacs&quot; rel=&quot;tag&quot;&gt;emacs&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/code&quot; class=&quot;wikilink1&quot; title=&quot;tags:code&quot; rel=&quot;tag&quot;&gt;code&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/magit?do=showtag&amp;amp;tag=tags%3Amagit&quot; class=&quot;wikilink1&quot; title=&quot;tags:magit&quot; rel=&quot;tag&quot;&gt;magit&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/org?do=showtag&amp;amp;tag=tags%3Aorg&quot; class=&quot;wikilink1&quot; title=&quot;tags:org&quot; rel=&quot;tag&quot;&gt;org&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://www.hodique.info/blog/2011/08/12/org-mode_links_for_magit#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://www.hodique.info/blog/2011/07/31/tweaking_zsh_completion_for_git_checkout">
        <dc:format>text/html</dc:format>
        <dc:date>2011-08-05T19:19:57+01:00</dc:date>
        <dc:creator>Yann Hodique</dc:creator>
        <title>Tweaking zsh completion for git checkout</title>
        <link>http://www.hodique.info/blog/2011/07/31/tweaking_zsh_completion_for_git_checkout</link>
        <description>
&lt;div class=&quot;level1&quot;&gt;
&lt;/p&gt;
&lt;div class=&quot;styler styler-float-left&quot;&gt;
&lt;p&gt;
&lt;span class=&quot;vcard&quot;&gt;&lt;img src=&quot;http://www.hodique.info/lib/exe/fetch.php?hash=15d77b&amp;amp;cache=recache&amp;amp;media=http%3A%2F%2Fwww.gravatar.com%2Favatar.php%3Fgravatar_id%3Dd9b955e7af49b0cbfd68c15947b25012%26default%3Dhttp%253A%252F%252Fwww.hodique.info%252Flib%252Fexe%252Ffetch.php%253Fhash%253Dd44619%2526cache%253Drecache%2526media%253Dhttp%25253A%25252F%25252Fwww.hodique.info%25252F%25252Flib%25252Fplugins%25252Favatar%25252Fmonsterid.php%25253Fseed%25253Dd9b955e7af49b0cbfd68c15947b25012%252526size%25253D40%252526.png%26size%3D40%26rating%3DR%26.jpg&quot; class=&quot;media photo fn&quot; title=&quot;&amp;#x79;&amp;#x61;&amp;#x6e;&amp;#x6e;&amp;#x2e;&amp;#x68;&amp;#x6f;&amp;#x64;&amp;#x69;&amp;#x71;&amp;#x75;&amp;#x65;&amp;#x40;&amp;#x67;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&quot; alt=&quot;&amp;#x79;&amp;#x61;&amp;#x6e;&amp;#x6e;&amp;#x2e;&amp;#x68;&amp;#x6f;&amp;#x64;&amp;#x69;&amp;#x71;&amp;#x75;&amp;#x65;&amp;#x40;&amp;#x67;&amp;#x6d;&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#x2e;&amp;#x63;&amp;#x6f;&amp;#x6d;&quot; width=&quot;40&quot; height=&quot;40&quot; /&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
By default, zsh completion allows you to complete according to “git checkout” semantics.
So &lt;code&gt;git checkout path/to/&amp;lt;TAB&amp;gt;&lt;/code&gt; will actually work for updating files from the index (and some other similar cases).
&lt;/p&gt;

&lt;p&gt;
There&amp;#039;s nothing to say about it, it&amp;#039;s obviously correct. Now, there are 2 things that make it inconvenient for me:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; first of all, I happen to work regularly with &lt;strong&gt;huge&lt;/strong&gt; repositories, with &lt;strong&gt;huge&lt;/strong&gt; working directories (approximately 35GB). Since the completion code ends up calling &lt;code&gt;git ls-files&lt;/code&gt;, even caching doesn&amp;#039;t help that much reducing the time spent building the completion table. And I wouldn&amp;#039;t want to pay the price even the first time.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; second, my branches generally use a directory-like layout (like &lt;code&gt;t/bugfix/&amp;lt;id&amp;gt;&lt;/code&gt;, so that it makes the whole completion list rather confusing.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Due to the second point, I happen to always use &lt;code&gt;-&lt;/code&gt;&lt;code&gt;-&lt;/code&gt; to make it clear I&amp;#039;m refering to filenames in the above scenario.
So instead of &lt;code&gt;git checkout path/to/&amp;lt;TAB&amp;gt;&lt;/code&gt;, I would actually always write &lt;code&gt;git checkout -&lt;/code&gt;&lt;code&gt;- path/to/&amp;lt;TAB&amp;gt;&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
From there, the solution to my problem is obvious, I just have to disable filename completion until &lt;code&gt;-&lt;/code&gt;&lt;code&gt;-&lt;/code&gt; is seen.
&lt;/p&gt;

&lt;p&gt;
Here&amp;#039;s the code (put it as a &lt;code&gt;_git-checkout&lt;/code&gt; function in your &lt;code&gt;$fpath&lt;/code&gt;):
&lt;/p&gt;
&lt;dl class=&quot;file&quot;&gt;
&lt;dt&gt;&lt;a href=&quot;http://www.hodique.info/_export/code/blog/2011/07/31/tweaking_zsh_completion_for_git_checkout?codeblock=0&quot; title=&quot;Download Snippet&quot; class=&quot;mediafile mf_&quot;&gt;_git-checkout&lt;/a&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;pre class=&quot;code file bash&quot;&gt;&lt;span class=&quot;co0&quot;&gt;#compdef git-checkout&lt;/span&gt;
&lt;span class=&quot;kw3&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;curcontext&lt;/span&gt;=&lt;span class=&quot;re1&quot;&gt;$curcontext&lt;/span&gt; state line
&lt;span class=&quot;kw3&quot;&gt;declare&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-A&lt;/span&gt; opt_args
&amp;nbsp;
&lt;span class=&quot;kw3&quot;&gt;local&lt;/span&gt; new_branch_reflog_arg
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; words&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;I&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;-b&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;re2&quot;&gt;new_branch_reflog_arg&lt;/span&gt;=&lt;span class=&quot;st_h&quot;&gt;'-l[create the new branch'&lt;/span&gt;&lt;span class=&quot;co3&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'s reflog]'&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;re2&quot;&gt;new_branch_reflog_arg&lt;/span&gt;=&lt;span class=&quot;st_h&quot;&gt;'-l[create the branch'&lt;/span&gt;&lt;span class=&quot;co3&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'s reflog]'&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;fi&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; compset &lt;span class=&quot;re5&quot;&gt;-N&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'--'&lt;/span&gt;; &lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt;
    __git_cached_files
&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;
    _arguments &lt;span class=&quot;re5&quot;&gt;-C&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-S&lt;/span&gt; \
        &lt;span class=&quot;st_h&quot;&gt;'-q[suppress feedback messages]'&lt;/span&gt; \
                                                                                  \
        - switch-branch \
        &lt;span class=&quot;st_h&quot;&gt;'-f[force a complete re-read]'&lt;/span&gt; \
        &lt;span class=&quot;st_h&quot;&gt;'-b[create a new branch based at given branch]: :__git_guard_branch-name'&lt;/span&gt; \
        &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;-t,--track&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'[set up configuration so pull merges from the start point]'&lt;/span&gt; \
        &lt;span class=&quot;st_h&quot;&gt;'--no-track[override the branch.autosetupmerge configuration variable]'&lt;/span&gt; \
        &lt;span class=&quot;re1&quot;&gt;$new_branch_reflog_arg&lt;/span&gt; \
        &lt;span class=&quot;st_h&quot;&gt;'-m[3way merge current branch, working tree and new branch]'&lt;/span&gt; \
        &lt;span class=&quot;st_h&quot;&gt;'::branch:__git_revisions'&lt;/span&gt; \
                                                                                  \
        - update-files \
        &lt;span class=&quot;st_h&quot;&gt;'::tree-ish:__git_tree_ishs'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;ret&lt;/span&gt;=&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;fi&lt;/span&gt;&lt;/pre&gt;
&lt;/dd&gt;&lt;/dl&gt;

&lt;p&gt;
You can compare to the original version in &lt;code&gt;/usr/share/zsh/functions/Completion/Unix/_git&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
Edit: thanks to Friedrich for pointing out the need for a &lt;code&gt;#compdef&lt;/code&gt; cookie to ensure proper behavior
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://www.hodique.info/tags/zsh&quot; class=&quot;wikilink1&quot; title=&quot;tags:zsh&quot; rel=&quot;tag&quot;&gt;zsh&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/code&quot; class=&quot;wikilink1&quot; title=&quot;tags:code&quot; rel=&quot;tag&quot;&gt;code&lt;/a&gt;,
	&lt;a href=&quot;http://www.hodique.info/tags/git&quot; class=&quot;wikilink1&quot; title=&quot;tags:git&quot; rel=&quot;tag&quot;&gt;git&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://www.hodique.info/blog/2011/07/31/tweaking_zsh_completion_for_git_checkout#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
</rdf:RDF>

