Cheat productively in Emacs 0

Posted by sjs
on Tuesday, August 21

By now you may have heard about cheat, the command line cheat sheet collection that’s completely open to editing, wiki style. A couple of weeks ago I posted cheat.el which allows one to cheat from within Emacs. There’s an update. However, before I get to cheat.el there’s a small detour.

Cheat is not just about Ruby! A few examples of cheats available are:

  • bash and zsh
  • $EDITOR (if you happen to like e, TextMate, vi, emacs, RadRails, ...)
  • GNU screen
  • Version control (darcs, svn, git)
  • Firebug
  • Markdown and Textile
  • Oracle and MySQL
  • Regular expressions
  • and of course Ruby, Rails, Capistrano, etc.

As of today, Aug-21 2007, the count is at 166 cheat sheets so there’s probably something there that you’ll want to look up from the command line or Emacs sometime. That’s enough stroking cheat’s ego, but there seems to be a notion that cheat is only for Ruby stuff and that’s really not the case.

So what’s new in this version of cheat.el? Completion! The only thing that bothered me about cheating in Emacs was the lack of completion. It now has completion, thus it is now perfect. :) In all likeliness this won’t be the last release, but I can’t really foresee adding anything else to it in the near future. Enjoy!

Download it now: cheat.el

For any newcomers, just drop this into ~/.emacs.d, ~/.elisp, or any directory in your load-path and then (require 'cheat). For more info check the original article for a rundown on the cheat commands.

Cheat from Emacs 5

Posted by sjs
on Friday, August 10

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).

Update #2 [2007.08.10]: Editing cheats and diffs have been implemented.

Update #3 [2007.08.21]: I added completion to cheat.el. The file linked on this page is still the latest version.

We all know and love cheat. Now you can cheat without leaving Emacs (and without using a shell in Emacs).

Just save cheat.el in ~/.emacs.d and then (require 'cheat) in your ~/.emacs. I also bind C-z C-c to cheat, you may want to do something similar.

You can’t do everything you can do with cheat on the command line yet, and for most of the commands the cheat command itself is used. Now you can do everything the command line client does from within Emacs, though you may need to revert to using cheat-command (described below).

Here’s the rundown:

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).

  • cheat – Lookup a cheat sheet interactively (cheat <name>)
  • cheat-sheets – List all cheat sheets (cheat sheets)
  • cheat-recent – List recently added cheat sheets (cheat recent)
  • cheat-versions – List versions of a cheat sheet interactively (cheat <name> --versions)
  • cheat-clear-cache – Clear all cached sheets.
  • cheat-add-current-buffer – Add a new cheat using the specified name and the contents of the current buffer as the body. (cheat <name> --add)
  • cheat-edit – Retrieve a fresh copy of the named cheat and display the body in a buffer for editing.
  • cheat-save-current-buffer – Save the current cheat buffer, which should be named *cheat-<name>*.
  • cheat-diff – Show the diff between the current version and the given version of the named cheat. If the version given is of the form m:n then show the diff between versions m and n. (cheat <name> --diff <version>)
  • cheat-command – Pass any arguments you want to cheat interactively.

(Added) I may add support for --diff and --edit in the future.

Please do send me your patches so everyone can benefit from them.

Cheating at life in general 0

Posted by sjs
on Wednesday, May 16

NB: My definition of life is slightly skewed by my being somewhat of a geek

Luckily no one in the real world cares if you cheat. Most of life is open-book, but for the times when you just need to find something quick the answer, of course, is to cheat profusely.

I’ve only checked out a few of the cheat sheets but they are of high quality and their wiki-like nature means if they suck and you have time you can help out. I was very pleased to find that there are a number of zsh cheats already.

They certainly know the way to my heart! Ruby, Rails, TextMate*, vim*, zsh, screen. That’ll do snake. That’ll do.

* There are cheats for emacs, jEdit, and e too if TextMate and/or vim don’t tickle your fancy