<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Posts on Pir-hana Cafe</title>
    <link>https://pir-hana.cafe/posts/</link>
    <description>Recent content in Posts on Pir-hana Cafe</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 03 Feb 2015 12:44:00 -0500</lastBuildDate>
    
        <atom:link href="https://pir-hana.cafe/posts/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>A More Evil Helm</title>
      <link>https://pir-hana.cafe/posts/a-more-evil-helm/</link>
      <pubDate>Tue, 03 Feb 2015 12:44:00 -0500</pubDate>
      
      <guid>https://pir-hana.cafe/posts/a-more-evil-helm/</guid>
      <description>&lt;h2 id=&#34;2020-update&#34;&gt;2020 Update&lt;/h2&gt;
&lt;p&gt;There are now &lt;a href=&#34;https://github.com/raxod502/selectrum/issues/23#issuecomment-602064501&#34;&gt;one billion completion frameworks&lt;/a&gt;, and the major ones now have packages that define a hydra for you (e.g. the ivy repo has &lt;code&gt;ivy-hydra&lt;/code&gt;). If you&amp;rsquo;re interested in defining your own or modifying an existing one, you&amp;rsquo;d probably be better off reading the hydra documentation than this post.&lt;/p&gt;
&lt;h2 id=&#34;modes-submodes-states-and-now-hydras&#34;&gt;Modes, Submodes, States, and Now Hydras&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/abo-abo/hydra&#34;&gt;hydra&lt;/a&gt; package for Emacs basically provides an extremely convenient way to create custom, persistent states where single keys will have a different effect than they normally would. The point is the same as that behind modal editing. If you&amp;rsquo;re going to be performing multiple related actions in a sequence, it is more efficient to enter a state where you can execute those actions using only single keys.&lt;/p&gt;
&lt;p&gt;I use the word &amp;ldquo;state&amp;rdquo; because the word &amp;ldquo;mode&amp;rdquo; has a very different different meaning in Emacs (kind of like &amp;ldquo;yank&amp;rdquo; does). The equivalent of a vim mode in Emacs is basically an evil state (using &lt;a href=&#34;https://github.com/emacs-evil/evil&#34;&gt;evil&lt;/a&gt;). The equivalent of a &lt;a href=&#34;http://www.vim.org/scripts/script.php?script%5Fid=2467&#34;&gt;vim-submode&lt;/a&gt; would be a hydra. There have already been evil plugins such as &lt;a href=&#34;https://github.com/syl20bnr/evil-lisp-state&#34;&gt;evil-lisp-state&lt;/a&gt; and code in Spacemacs that create mini-states for more specific tasks, but hydra makes the creation of these much simpler.&lt;/p&gt;
&lt;p&gt;A commonly given example of when one might use a hydra is when repeating an action over and over, such as scrolling or zooming. However, it&amp;rsquo;s generally simpler to just use the dot operator for repeating single actions. A better one would be the &lt;a href=&#34;http://oremacs.com/2015/02/03/one-hydra-two-hydra/&#34;&gt;example&lt;/a&gt; given by Oleh Krehel (hydra&amp;rsquo;s author) and bcarell for switching between splits.&lt;/p&gt;
&lt;p&gt;Hydra has other convenience features, such as allowing for help text for each key or &amp;ldquo;head&amp;rdquo; in the hydra to be printed in the echo area. It does everything one would initially hope for and allows for global hydras as well as hydras in specific major modes. It even makes a &amp;ldquo;color&amp;rdquo; distinction where a head with the color blue will exit the state while those that are red (default) will not.&lt;/p&gt;
&lt;h2 id=&#34;a-hydra-to-make-helm-more-like-unite&#34;&gt;A Hydra to Make Helm More Like Unite&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/emacs-helm/helm&#34;&gt;Helm&lt;/a&gt; is pretty much the Emacs equivalent of &lt;a href=&#34;https://github.com/Shougo/unite.vim&#34;&gt;unite&lt;/a&gt; except even more integrated. One thing I sometimes miss when using Helm is the ability to switch from &lt;code&gt;insert&lt;/code&gt; to &lt;code&gt;normal&lt;/code&gt; to do things like mark or move between candidates. I originally created mini-states using the same method &lt;code&gt;evil-lisp-state&lt;/code&gt; uses. It works, but it&amp;rsquo;s ugly, long (&amp;gt;60 lines), and you have to define a new evil state each time. Spacemacs has a more simple way to do things if you want to extract it, but I prefer hydra. With hydra there&amp;rsquo;s no evil involved, and it&amp;rsquo;s as easy as this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#ef6155&#34;&gt;defhydra&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-like-unite&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;vim movement&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;?&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-help&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;help&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;&amp;lt;escape&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;keyboard-escape-quit&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;exit&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;&amp;lt;SPC&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-toggle-visible-mark&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;mark&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;a&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-toggle-all-marks&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;(un)mark all&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#776e71&#34;&gt;;; not sure if there&amp;#39;s a better way to do this&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;/&amp;#34;&lt;/span&gt; (lambda ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (interactive)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#06b6ef&#34;&gt;execute-kbd-macro&lt;/span&gt; [&lt;span style=&#34;color:#48b685&#34;&gt;?\C&lt;/span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;-s&lt;/span&gt;]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;search&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;v&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-execute-persistent-action&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;g&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-beginning-of-buffer&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;top&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;G&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-end-of-buffer&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;bottom&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;j&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-next-line&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;down&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;k&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-previous-line&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;up&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;i&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;cancel&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then bind it:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#776e71&#34;&gt;;; to escape&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#06b6ef&#34;&gt;define-key&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-map&lt;/span&gt; (&lt;span style=&#34;color:#ef6155&#34;&gt;kbd&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;&amp;lt;escape&amp;gt;&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#39;helm-like-unite/body&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#776e71&#34;&gt;;; or with key-chord.el; suggested by ReneFroger&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#ef6155&#34;&gt;key-chord-define&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;minibuffer-local-map&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;jk&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#39;helm-like-unite/body&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you can enter the &lt;code&gt;helm-like-unite&lt;/code&gt; hydra with &lt;code&gt;escape&lt;/code&gt; in helm and then use &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; to navigate up and down and &lt;code&gt;space&lt;/code&gt; to mark candidates. Hydra even makes numbers work as digit arguments, so you can do &lt;code&gt;9k&lt;/code&gt; as you would in vim. You can use &lt;code&gt;escape&lt;/code&gt; to quit helm or &lt;code&gt;i&lt;/code&gt; to return to normal functionality. Keys not mapped in a hydra will exit the hydra, so &lt;code&gt;return&lt;/code&gt; and &lt;code&gt;tab&lt;/code&gt; will have their normal behaviour. &lt;code&gt;?&lt;/code&gt; will bring up helm&amp;rsquo;s help. &lt;code&gt;/&lt;/code&gt; will do whatever &lt;code&gt;C-s&lt;/code&gt; would do for those selected buffers (e.g. &lt;code&gt;helm-buffers-run-multi-occur&lt;/code&gt; or &lt;code&gt;helm-ff-run-grep&lt;/code&gt;). &lt;code&gt;v&lt;/code&gt; will describe the function, or preview the buffer/file, or go to a line (in helm occur), etc.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s trivial to add more actions, for example binding &lt;code&gt;p&lt;/code&gt; to &lt;code&gt;helm-copy-to-buffer&lt;/code&gt; or &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;u&lt;/code&gt; to &lt;code&gt;helm-next-page&lt;/code&gt; and &lt;code&gt;helm-previous-page&lt;/code&gt;. Here are some other suggestions:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#776e71&#34;&gt;;; suggested by ReneFroger&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;h&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-previous-source&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;l&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-next-source&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#776e71&#34;&gt;;; suggested by Sylvain Benner (syl20bnr)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#776e71&#34;&gt;;; if you want to use a key besides TAB to go to action select and then exit the hydra&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;r&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ef6155&#34;&gt;helm-select-action&lt;/span&gt; :color &lt;span style=&#34;color:#ef6155&#34;&gt;blue&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;potential-problems&#34;&gt;Potential Problems&lt;/h2&gt;
&lt;p&gt;A downside could be that it now takes two escapes to get out of helm unless you use a different key to enter the hydra (one escape to enter the hydra and one to then quit helm). Anyway, this will probably appeal mostly only to evil users. If you don&amp;rsquo;t move up and down and mark specific candidates a lot in helm, this probably isn&amp;rsquo;t worth it. I still think it&amp;rsquo;s a cool example of hydra&amp;rsquo;s simplicity.&lt;/p&gt;
&lt;h2 id=&#34;update&#34;&gt;Update&lt;/h2&gt;
&lt;p&gt;One annoyance is that helm will override the hydra help echo after a few seconds. However, hydra now has &lt;a href=&#34;http://oremacs.com/2015/02/04/pre-hydra-post/&#34;&gt;:pre and :post&lt;/a&gt; which allow
you to, for example, change the color of the cursor when you&amp;rsquo;re in the hydra to make it clear even after the echo disappears.&lt;/p&gt;
&lt;p&gt;Hydra has also added the &lt;a href=&#34;http://oremacs.com/2015/02/05/amaranth-hydra/&#34;&gt;new color amaranth&lt;/a&gt; that will change the default behaviour so that only blue heads (keys that are specified by the user to exit) will leave the hydra. This means that pressing unbound keys in the hydra won&amp;rsquo;t exit the hydra. This may be the preferred behaviour for some.&lt;/p&gt;
 </description>
    </item>
    
    <item>
      <title>Why I One-Space</title>
      <link>https://pir-hana.cafe/posts/why-i-onespace/</link>
      <pubDate>Sun, 21 Sep 2014 23:46:00 -0400</pubDate>
      
      <guid>https://pir-hana.cafe/posts/why-i-onespace/</guid>
      <description>&lt;h2 id=&#34;2020-update&#34;&gt;2020 Update&lt;/h2&gt;
&lt;p&gt;Zealotry aside, two-spacing is superior from a parsing perspective. As far as effort, you can just add a keybinding to insert a period plus two spaces to make the effort the same. I may start doing this at some point and two-space future writing. I think it would be too much effort to convert existing code/writing or to try to two-space when working with others who don&amp;rsquo;t. In the end one-spacing vs. two-spacing really doesn&amp;rsquo;t matter all that much. Instead of reading this article, I suggest reading one of Steve Losh&amp;rsquo;s excellent posts on Common Lisp.&lt;/p&gt;
&lt;h2 id=&#34;why-i-two-space&#34;&gt;&amp;ldquo;Why I Two-Space&amp;rdquo;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;http://stevelosh.com/blog/2012/10/why-i-two-space/&#34;&gt;Steve Losh&amp;rsquo;s
article&lt;/a&gt; on using two spaces after a sentence continues to pop up,
going mostly unchallenged it would seem. I personally fail to see any
reason to use two spaces that isn&amp;rsquo;t completely subjective and find his
arguments otherwise to be self-defeating.&lt;/p&gt;
&lt;h2 id=&#34;his-arguments-for-two-spaces&#34;&gt;His Arguments for Two Spaces&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;It looks better when using a monospaced font.&lt;/li&gt;
&lt;li&gt;It gives the user more &amp;ldquo;power&amp;rdquo;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;two-spacing-is-pretty&#34;&gt;Two-Spacing is Pretty&lt;/h2&gt;
&lt;p&gt;This is entirely subjective. I use monospaced fonts all the time and
still think two spaces in between a sentence looks hideous.&lt;/p&gt;
&lt;h2 id=&#34;two-spacing-gives-more-power&#34;&gt;Two-Spacing Gives More Power?&lt;/h2&gt;
&lt;p&gt;Okay so what about the non-trivial argument? Well, it seems to be the
same as the argument he says is not convincing (less effort). His
specific example for &amp;ldquo;power&amp;rdquo; only applies to vim users and only to some
of them.&lt;/p&gt;
&lt;p&gt;This is what happens when I type &lt;code&gt;das&lt;/code&gt; in vim using his example.&lt;/p&gt;
&lt;p&gt;Before with cursor above &lt;code&gt;t&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Bob started speaking. Hello, Mr. Smi[t]h! How are you today?
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After &lt;code&gt;das&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Bob started speaking. How are you today?
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It ends up looking exactly how I want. This is because I&amp;rsquo;m using reedes&#39;
excellent
&lt;a href=&#34;https://github.com/reedes/vim-textobj-sentence&#34;&gt;textobj-sentence&lt;/a&gt;
plugin that makes vim&amp;rsquo;s &lt;code&gt;as&lt;/code&gt; and &lt;code&gt;is&lt;/code&gt; smarter. It even allows for adding
custom abbreviations to ignore. As Losh says, we can have our cake and
eat it too!&lt;/p&gt;
&lt;p&gt;Granted, this plugin didn&amp;rsquo;t exist at the time of the article&amp;rsquo;s writing
(though the idea isn&amp;rsquo;t exactly hard to come up with). Even if this
plugin did not currently exist, his argument is bunk. What is the
benefit of being able to do things like &lt;code&gt;das&lt;/code&gt;? If what is meant by power
is not efficiency and saving keystrokes, effort, and time, then I&amp;rsquo;ve no
clue what the point is. Count how many times I&amp;rsquo;ve used abbreviations in
this post. You don&amp;rsquo;t even have to count the number sentences to realize
the number of extra keystrokes I would have had to type to put two
spaces in between every sentence is exponentially greater than the
single extra keystroke it would have taken me to deal with that
abbreviation if I had needed to (the dot command). So even if space is
only half a percent of keystrokes typed, the number of keystrokes needed
to deal with abbreviations is even more insignificant. So much for
power.&lt;/p&gt;
&lt;p&gt;As for parsing, this is merely a hypothetical. Has he ever needed to do
that? I actually often use a script for counting sentences, and it&amp;rsquo;s
really not that difficult to deal with single spaced sentences like
textobj-sentence does. A script that chose not to deal with it would
suffer from the problem of not working with anything written by people
who don&amp;rsquo;t two-space. Unless this script needed to be absolutely perfect
at counting, there would be no need to two-space sentences. This method
of counting one-spaced sentences only fails in the rare case that a
sentence actually does end with an abbreviation.&lt;/p&gt;
&lt;h2 id=&#34;update--2015-09-08&#34;&gt;Update (2015-09-08)&lt;/h2&gt;
&lt;p&gt;Emacs users can find an equivalent of &lt;code&gt;vim-textobj-sentence&lt;/code&gt;
&lt;a href=&#34;https://github.com/noctuid/emacs-sentence-navigation&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
 </description>
    </item>
    
    <item>
      <title>Using Ranger as a Save Dialog</title>
      <link>https://pir-hana.cafe/posts/using-ranger-for-downloads/</link>
      <pubDate>Wed, 30 Apr 2014 23:25:00 -0400</pubDate>
      
      <guid>https://pir-hana.cafe/posts/using-ranger-for-downloads/</guid>
      <description>&lt;h2 id=&#34;2020-update&#34;&gt;2020 Update&lt;/h2&gt;
&lt;p&gt;Pentadactyl has been dead for years. There&amp;rsquo;s not a perfect replacement, but for this functionality, &lt;a href=&#34;https://github.com/qutebrowser/qutebrowser&#34;&gt;qutebrowser&lt;/a&gt;&amp;rsquo;s &lt;code&gt;downloads.open_dispatcher&lt;/code&gt; setting can be used, and &lt;a href=&#34;https://github.com/tridactyl/tridactyl&#34;&gt;tridactyl&lt;/a&gt; has a PR open for a &lt;code&gt;DownloadPost&lt;/code&gt; autocommand (see &lt;a href=&#34;https://github.com/tridactyl/tridactyl/issues/807&#34;&gt;the relevant issue&lt;/a&gt;; it may be implemented at the time of reading).&lt;/p&gt;
&lt;h2 id=&#34;quick-round-of-applause-for-octopress&#34;&gt;Quick Round of Applause for Octopress&lt;/h2&gt;
&lt;p&gt;Today I found the perfect excuse to start a blog when I stumbled across
&lt;a href=&#34;https://pages.github.com/&#34;&gt;github pages&lt;/a&gt; and
&lt;a href=&#34;http://octopress.org/&#34;&gt;octopress&lt;/a&gt;. It&amp;rsquo;s something I&amp;rsquo;ve been wanting
to do for a while, but I never found blogger or wordpress to be that
attractive. Finding out that I could easily host a blog on github and
write all my posts in markdown was enough to git me to do it
immediately. For a first post, I thought I&amp;rsquo;d just start with presenting
something basic I did recently to start using ranger for saving
downloads.&lt;/p&gt;
&lt;h2 id=&#34;why-ranger&#34;&gt;Why Ranger?&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/hut/ranger&#34;&gt;Ranger&lt;/a&gt; is the most efficient file
manager I have come across. It already integrates easily enough with
most other programs. The browser is an exception and one due not to any
fault of ranger. You have very little choice in general when it comes to
saving files using most GUI browsers. The best the default file saver
has to offer you is &lt;em&gt;&lt;code&gt;Recent Folders&lt;/code&gt;&lt;/em&gt;, rudimentary tab completion, and
the ability to open in the last directory you saved in. While it is
possible to change the file picker or file saver, none of the few
options (e.g. the GTK file picker for GNOME and the QT file picker for
KDE) are particularly sophisticated.&lt;/p&gt;
&lt;p&gt;Ranger is operated entirely with the keyboard. You can press &lt;code&gt;&#39;&#39;&lt;/code&gt; to get
to the last visited directory or &lt;code&gt;&#39;&amp;lt;key&amp;gt;&lt;/code&gt; to visit any directory you&amp;rsquo;ve
bookmarked with a letter. This makes navigating even large directory
structures fairly quick. When you don&amp;rsquo;t have a bookmark for the exact
directory you want to move a file to, you can hit &lt;code&gt;f&lt;/code&gt; and then type the
name of the directory. As soon as the keys you type correspond to a
unique directory, that directory will automatically be opened.
Alternatively, there is
&lt;a href=&#34;https://github.com/hut/ranger/wiki/Commands#visit-frequently-used-directories&#34;&gt;fasd
integration&lt;/a&gt; allowing you to jump immediately to a frequently/recently
used directory. You can even
&lt;a href=&#34;https://github.com/hut/ranger/wiki/Commands#fzf-integration&#34;&gt;create a
fzf command&lt;/a&gt; to jump to a directory with a fuzzy search (e.g. using
locate or find). Because of these features, using ranger can reduce a
lot of scrolling and clicking to a few keypresses.&lt;/p&gt;
&lt;h2 id=&#34;implementation&#34;&gt;Implementation&lt;/h2&gt;
&lt;p&gt;You can
&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Tutorial/Open%5Fand%5FSave%5FDialogs&#34;&gt;write
your own save dialog&lt;/a&gt;. I don&amp;rsquo;t know if it would be easy or even
possible to write a save dialog wrapper for ranger. Because I often want
to save without anything popping up (e.g. when saving related files that
will be moved to the same directory), I just bypass the save dialog
entirely and download everything automatically to a single folder. I
used to just open ranger in this folder later and move things, but this
led to a pileup of unorganized crap since I rarely got around to
cleaning the folder.&lt;/p&gt;
&lt;p&gt;Now I use &lt;a href=&#34;http://5digits.org/pentadactyl/&#34;&gt;pentadactyl&lt;/a&gt; to &amp;ldquo;replace&amp;rdquo;
the default save dialog with ranger. Pentadactyl already eliminates the
need for the GUI save dialog with &lt;code&gt;:w&lt;/code&gt; for saving webpages (or whatever
else the current url is) and &lt;code&gt;;s&lt;/code&gt; for download hinting. Path and file
names can be specified with tab completion as well. Other vim-oriented
browsers have similar options, but this method still isn&amp;rsquo;t nearly as
quick as using ranger. An autocommand can be used to fake ranger
integration:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-vimrc&#34; data-lang=&#34;vimrc&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b6ef&#34;&gt;au&lt;/span&gt; &lt;span style=&#34;color:#06b6ef&#34;&gt;DownloadPost&lt;/span&gt; * &lt;span style=&#34;color:#06b6ef&#34;&gt;silent&lt;/span&gt; !&lt;span style=&#34;color:#48b685&#34;&gt;/path/&lt;/span&gt;&lt;span style=&#34;color:#06b6ef&#34;&gt;to&lt;/span&gt;/&lt;span style=&#34;color:#06b6ef&#34;&gt;script&lt;/span&gt; &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;&amp;lt;file&amp;gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this in place, every time something is downloaded, pentadactyl will
pass the full path of the downloaded file to the specified script.
Making the command silent helps to ensure that pentadactyl will not
steal the focus back from ranger.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example script to open ranger with the file cut:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-shell&#34; data-lang=&#34;shell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;termite --geometry&lt;span style=&#34;color:#5bc4bf&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;600x400&amp;#34;&lt;/span&gt; -e &lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;ranger --selectfile=&amp;#34;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;$1&lt;/span&gt;&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;&amp;#34; --cmd=cut&amp;#34;&lt;/span&gt; &amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;It will look something like this (updated 2016-01-02)&lt;/em&gt;:&lt;/p&gt;
&lt;figure&gt;&lt;img src=&#34;https://pir-hana.cafe/ox-hugo/ranger_file_saver.png&#34;/&gt;
&lt;/figure&gt;

&lt;p&gt;My full script can be found
&lt;a href=&#34;https://github.com/noctuid/dotfiles/blob/master/scripts/bin/dl%5Fmove&#34;&gt;here&lt;/a&gt;
and fixes a lot of problems that can occur. For example, it uses detox
to clean up the filename and ignores files saved under &lt;code&gt;/tmp&lt;/code&gt; (happens
when using &amp;ldquo;open with&amp;rdquo;). It also supports consecutively saving files to
a temporary directory and then moving them all at once later. This is
useful for preventing a lot of popups when saving related files
(e.g. using a count or &lt;code&gt;:tabdo&lt;/code&gt;). It has an example for automatically
moving certain filetypes; I do this with torrent files. Finally, it
gives an example way to use emacsclient and dired instead of ranger
(which can open a lot quicker in some situations).&lt;/p&gt;
&lt;p&gt;The full script also prevents multiple popups that would normally happen
due to a &lt;a href=&#34;https://github.com/5digits/dactyl/issues/29&#34;&gt;pentadactyl
bug&lt;/a&gt;. The more firefox windows opened, the more ranger instances are
started. For a while, I thought this was because pentadactyl has no
&lt;a href=&#34;https://groups.google.com/forum/#!topic/pentadactyl/rwrGG4njsq8&#34;&gt;autocmd
clearing mechanism&lt;/a&gt;. Sourcing an autocommands file with &lt;code&gt;au Enter&lt;/code&gt;
won&amp;rsquo;t fix this though. This bug happens because the DownloadPost autocmd
will execute for every open window. I realized this because the
following would still execute from a private window when called from the
autocommand but not manually:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-vimrc&#34; data-lang=&#34;vimrc&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b6ef&#34;&gt;command&lt;/span&gt;! -&lt;span style=&#34;color:#06b6ef&#34;&gt;nargs&lt;/span&gt;=&lt;span style=&#34;color:#f99b15&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#06b6ef&#34;&gt;maybe&lt;/span&gt;-&lt;span style=&#34;color:#06b6ef&#34;&gt;open&lt;/span&gt;-&lt;span style=&#34;color:#06b6ef&#34;&gt;ranger&lt;/span&gt; &amp;lt;&amp;lt;&lt;span style=&#34;color:#06b6ef&#34;&gt;EOF&lt;/span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#815ba4&#34;&gt;if&lt;/span&gt; !&lt;span style=&#34;color:#06b6ef&#34;&gt;PrivateBrowsingUtils&lt;/span&gt;.&lt;span style=&#34;color:#06b6ef&#34;&gt;isWindowPrivate&lt;/span&gt;(&lt;span style=&#34;color:#06b6ef&#34;&gt;window&lt;/span&gt;)&lt;span style=&#34;color:#ef6155&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;&lt;/span&gt;    &lt;span style=&#34;color:#06b6ef&#34;&gt;silent&lt;/span&gt; !~&lt;span style=&#34;color:#48b685&#34;&gt;/bin/&lt;/span&gt;&lt;span style=&#34;color:#06b6ef&#34;&gt;ranger&lt;/span&gt;/&lt;span style=&#34;color:#06b6ef&#34;&gt;ranger_browser_fm&lt;/span&gt;.&lt;span style=&#34;color:#06b6ef&#34;&gt;sh&lt;/span&gt; &amp;lt;&lt;span style=&#34;color:#06b6ef&#34;&gt;args&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#ef6155&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#815ba4&#34;&gt;endif&lt;/span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#06b6ef&#34;&gt;EOF&lt;/span&gt;&lt;span style=&#34;color:#ef6155&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;uploads&#34;&gt;Uploads&lt;/h2&gt;
&lt;p&gt;Pentadactyl also provides a way to avoid using a GUI for selecting a
file for upload. If you can hint an upload button, pentadactyl will give
you an &lt;code&gt;Upload:&lt;/code&gt; prompt and allow you to select a file with tab
completion. Alternatively, it is possible to yank the file path in
ranger beforehand and paste this into either the pentadactyl or GUI save
dialog. As for creating a new file picker that somehow wrapped ranger, I
have no clue how difficult this would be.&lt;/p&gt;
&lt;p&gt;For some websites, I&amp;rsquo;d rather use a CLI program. For example, tumblr
also allows to &lt;a href=&#34;https://www.tumblr.com/docs/en/posting&#34;&gt;post by email&lt;/a&gt;
and even use markdown to do so. There is also
&lt;a href=&#34;https://github.com/mwunsch/tumblr&#34;&gt;tumblr-rb&lt;/a&gt;. The
&lt;a href=&#34;https://code.google.com/p/imgur-cli/&#34;&gt;imgur-cli&lt;/a&gt; python script is
useful for imgur uploads, and I&amp;rsquo;ve added a keybinding for it in ranger.
&lt;a href=&#34;https://github.com/Profpatsch/imup&#34;&gt;Imup&lt;/a&gt; is pretty good for
anonymous (no account login) uploads to different image hosts as well.
There is also &lt;a href=&#34;https://github.com/mcrapet/plowshare&#34;&gt;plowshare&lt;/a&gt; for
uploading to sites like mediafire.&lt;/p&gt;
&lt;p&gt;I have not tried the following programs, but they may also be of use.
For youtube, there are
&lt;a href=&#34;https://code.google.com/p/youtube-upload/&#34;&gt;youtube-upload&lt;/a&gt; and
&lt;a href=&#34;https://code.google.com/p/googlecl/&#34;&gt;googlecl&lt;/a&gt;. Googlecl is a lot
more popular and does a lot more than just youtube (e.g. picasa
uploads), and youtube-upload looks like it might require you to enter
your password in the command. Googlecl is also in the official arch
repos. For facebook, &lt;a href=&#34;https://github.com/dtompkins/fbcmd&#34;&gt;fbcommand&lt;/a&gt;
allows uploading photos (and multiple photos at once as an album&amp;hellip; as
does googlecl with picasa by the way).&lt;/p&gt;
 </description>
    </item>
    
  </channel>
</rss>
