Cheat from Emacs 4

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

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. Here’s the rundown:

  • 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 a cached sheet interactively, clear them all if no name is given. ( cheat --clear-cache [<name>] )
  • 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 )

I may add support for --diff and --edit in the future. Please do send me your patches so everyone can benefit from them.


Leave a response

  1. rj ryan August 10, 2007 @ 07:15 AM

    Thought you might like to know that WebSense denied me access from work because your site is in the 'Sex' category =).

  2. sjs August 10, 2007 @ 09:57 AM

    That is really strange. The only thing I could think of that is remotely sex-related on my site is: ... lame filter!

  3. jkc August 10, 2007 @ 11:22 AM

    I just tried it with emacs 22 and it can't find one of the functions: Symbol's function definition is void: string-join There must be some dependency I assume?

  4. sjs August 10, 2007 @ 11:40 AM

    That was a mistake on my part. Thanks for letting me know. I'll be sure to test code I publish with emacs -q in the future!