mirror of
https://github.com/samsonjs/blog.git
synced 2026-04-27 15:07:41 +00:00
3.2 KiB
3.2 KiB
Title: Cheat from Emacs Date: August 9, 2007 Timestamp: 1186710960 Author: sjs Tags: Emacs
Update: I had inadvertently used string-join, a function provided by something in my ~/.emacs.d. The script has been updated to work with a vanilla Emacs (23, but should work with 22 as well).
<p><em>Update #2 [2007.08.10]: Editing cheats and diffs have been implemented.</em></p>
<p><em>Update #3 [2007.08.21]: I <a href="http://web.archive.org/web/20071117195454/http://sami.samhuri.net/2007/8/21/cheat-productively-in-emacs">added completion</a> to cheat.el. The file linked on this page is still the latest version.</em></p>
<p>We all know and love <a href="http://web.archive.org/web/20071117195454/http://cheat.errtheblog.com/">cheat</a>. Now you can cheat without leaving Emacs (and without using a shell in Emacs).</p>
<p>Just save <a href="http://web.archive.org/web/20071117195454/http://sami.samhuri.net/assets/2007/8/10/cheat.el">cheat.el</a> in ~/.emacs.d and then <code>(require 'cheat)</code> in your ~/.emacs. I also bind <code>C-z C-c</code> to <code>cheat</code>, you may want to do something similar.</p>
<p><del>You can’t do everything you can do with cheat on the command line yet</del>, and for most of the commands the cheat command itself is used. <em>Now you can do everything the command line client does from within Emacs, though you may need to revert to using <code>cheat-command</code> (described below).</em></p>
<p>Here’s the rundown:</p>
<p><em>Any time you enter a cheat name there are both completion and a cheat-specific history available. Unless you are adding a new cheat. In that case you should use a new, unique name (duh).</em></p>
<ul>
<li><code>cheat</code> – Lookup a cheat sheet interactively (<code>cheat <name></code>)</li>
<li><code>cheat-sheets</code> – List all cheat sheets (<code>cheat sheets</code>)</li>
<li><code>cheat-recent</code> – List recently added cheat sheets (<code>cheat recent</code>)</li>
<li><code>cheat-versions</code> – List versions of a cheat sheet interactively (<code>cheat <name> --versions</code>)</li>
<li><code>cheat-clear-cache</code> – Clear all cached sheets.</li>
<li><code>cheat-add-current-buffer</code> – Add a new cheat using the specified name and the contents of the current buffer as the body. (<code>cheat <name> --add</code>)</li>
<li><code>cheat-edit</code> – Retrieve a fresh copy of the named cheat and display the body in a buffer for editing.</li>
<li><code>cheat-save-current-buffer</code> – Save the current cheat buffer, which should be named <code>*cheat-<name>*</code>.</li>
<li><code>cheat-diff</code> – Show the diff between the current version and the given version of the named cheat. If the version given is of the form <em>m:n</em> then show the diff between versions <em>m</em> and <em>n</em>. (<code>cheat <name> --diff <version></code>)</li>
<li><code>cheat-command</code> – Pass any arguments you want to cheat interactively.</li>
</ul>
<p><em>(Added)</em> <del>I may add support for <code>--diff</code> and <code>--edit</code> in the future.</del></p>
<p>Please do send me your patches so everyone can benefit from them.</p>