emacs/var/elfeed/db/data/ee/eee8d5355b0ca369a30b3616d68619f385f6c777
2022-01-03 12:49:32 -06:00

49 lines
3.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>The more I move to VC<sup id="fnref:1"><a class="footnote" href="https://www.manueluberti.eu/feed#fn:1" rel="footnote">1</a></sup>, the more I end up relying on <kbd>M-!</kbd>
(<code class="language-plaintext highlighter-rouge">shell-command</code>). Admittedly, this is a tool Ive hardly ever used before, but
since VC lacks many features covered by Magit, sometimes I need to interact with
the power of Git straight from the command line.</p>
<p>One of the best things about Magit is that I dont have to remember the many Git
options to use it every day. Through transient menus, Magit makes Git a matter
of few key strokes. On the other hand, from time to time I find myself on remote
machines where Magit is not available, so it does not hurt to have a better
understanding of the basic Git operations at my disposal.</p>
<p>However, typing them all out every single time is not the kind of pleasant
activity a lazy Emacs user enjoys. Juri Linkov shared this little trick on
<code class="language-plaintext highlighter-rouge">emacs-devel</code><sup id="fnref:2"><a class="footnote" href="https://www.manueluberti.eu/feed#fn:2" rel="footnote">2</a></sup>:</p>
<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">defun</span> <span class="nv">mu-minibuffer-complete-history</span> <span class="p">()</span>
<span class="s">"Complete minibuffer history."</span>
<span class="p">(</span><span class="nv">interactive</span><span class="p">)</span>
<span class="p">(</span><span class="nv">completion-in-region</span> <span class="p">(</span><span class="nv">minibuffer--completion-prompt-end</span><span class="p">)</span> <span class="p">(</span><span class="nv">point-max</span><span class="p">)</span>
<span class="p">(</span><span class="nb">symbol-value</span> <span class="nv">minibuffer-history-variable</span><span class="p">)</span>
<span class="no">nil</span><span class="p">))</span>
</code></pre></div></div>
<p>Juri also suggested to bind it to <kbd>C-TAB</kbd> in <code class="language-plaintext highlighter-rouge">minibuffer-local-map</code>
which, coincidentally, is the same key binding I have to manually complete with
Company outside of the minibuffer.</p>
<p>What Juris code does is popping up a <code class="language-plaintext highlighter-rouge">*Completions*</code> buffer with the history of
the commands used in the minibuffer. I only use it with <code class="language-plaintext highlighter-rouge">shell-command</code>, but try
it with <kbd>C-x C-f</kbd> for fun.</p>
<p>I leave it as a small exercise for the reader to understand how to switch from
the minibuffer to the <code class="language-plaintext highlighter-rouge">*Completions*</code> buffer and vice versa. Tip: <kbd>C-h
m</kbd> is your friend.</p>
<h3 id="notes">Notes</h3>
<div class="footnotes">
<ol>
<li id="fn:1">
<p>See <a href="https://www.manueluberti.eu/emacs/2021/11/27/vc/">A job for VC</a> and
<a href="https://www.manueluberti.eu/emacs/2021/12/05/vc-rebasing/">Rebasing with
VC</a>. <a class="reversefootnote" href="https://www.manueluberti.eu/feed#fnref:1">↩</a></p>
</li>
<li id="fn:2">
<p>See <a href="https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg00802.html" target="_blank">History completion</a>. <a class="reversefootnote" href="https://www.manueluberti.eu/feed#fnref:2">↩</a></p>
</li>
</ol>
</div>