6093 comments
2357 subscribers
6238 on Twitter
Subscribe! Feed reader E-mail

Rediscovering Emacs features, or what to do after you get carried away installing packages

A kid in a candy store – that’s me with M-x list-packages, EmacsWiki pages, Planet Emacsen, and other sources of Emacs goodness. Because Emacs has so much functionality and people keep adding stuff to it, it’s easy to forget about the cool goodies in configuration files and the Emacs codeverse. It’s important to practise and review, though, because there are all sorts of great keyboard shortcuts and commands that could make Emacs even better if I could just drill them into my brain.

Spaced repetition is a great technique for prioritizing and learning things. Emacs Org has an org-drill module that implements flashcards for Org headings that are tagged with :drill:. I’ve been using this to prepare for the Canadian citizenship exam, and that’s been working out well. So I started creating an emacs-drill.org file with headings for the things I’m interested in learning, such as multiple-cursor-mode and ace-jump-mode…

… And then I remembered, hey, my Emacs configuration is one big Org file (thanks to the joys of literate programming) so why don’t I just stick the :drill: tag onto the relevant snippets and run M-x org-drill there?

This might actually work out. =)

I was thinking of doing some kind of idle-timer hook, but I actually don’t mind manually triggering it. Besides, I’m experimenting with John Wiegley’s org-agenda display paired with winner-mode to save my window configuration.

Come to think of it, it might be good to add a random Emacs keybinding to the org-agenda display. I’ve installed keywiz, so I can reuse some of the code from that:

(use-package keywiz)
(defun sacha/load-keybindings ()
  "Since we don't want to have to pass through a keywiz game each time..."
  (setq keywiz-cached-commands nil)
  (do-all-symbols (sym)
    (when (and (commandp sym)
               (not (memq sym '(self-insert-command
                                digit-argument undefined))))
      (let ((keys (apply 'nconc (mapcar
                                 (lambda (key)
                                   (when (keywiz-key-press-event-p key)
                                     (list key)))
                                 (where-is-internal sym)))))
        ;;  Politically incorrect, but clearer version of the above:
        ;;    (let ((keys (delete-if-not 'keywiz-key-press-event-p
        ;;                               (where-is-internal sym))))
        (and keys
             (push (list sym keys) keywiz-cached-commands)))))))
  (sacha/load-keybindings)
  ;; Might be good to use this in org-agenda...
  (defun sacha/random-keybinding ()
    "Describe a random keybinding."
    (let* ((command (keywiz-random keywiz-cached-commands))
         (doc (and command (documentation (car command)))))
      (if command
          (concat (symbol-name (car command)) " "
                  "(" (mapconcat 'key-description (cadr command) ", ") ")"
                  (if doc
                      (concat ": " (substring doc 0 (string-match "\n" doc)))
                    ""))
"")))

… and a minor adjustment to org-agenda-custom-commands…

(defun sacha/org-agenda-with-tip (arg) (org-agenda-list arg) (let ((inhibit-read-only t)) (insert (sacha/random-keybinding) “\n”))) (setq org-agenda-custom-commands `((“a” “Agenda” sacha/org-agenda-with-tip) (“T” todo-tree “TODO”)
;; more here; see my config file
)))

… and now I see a random Emacs keybinding every time I review my to-do list.

agenda-tip

If you find yourself forgetting to revisit the nifty Emacs snippets you’ve added to your configuration, add reminders for yourself. Make yourself some flashcards with org-drill.el or flashcard.el and give that a try, or integrate reminders into your workflow. Have fun!

Short URL: http://sachachua.com/blog/p/24527
  • http://snell-pym.org.uk/alaric/ Alaric Snell-Pym

    Dangit! I’ve been performing the function of delete-indentation by laborious deleting of whitespace for YEARS! :-D

    • http://sachachua.com sachac

      I know! Me too!

    • alex

      I even wrote a macro for it! *sigh*

      • http://sachachua.com sachac

        Whenever I catch myself doing something repetitive in Emacs, I try to see if someone else has already written some code for it. Sometimes I discover that person is me. One time I was hacking together a quick function in the scratch buffer, and then I went to put it in a logical place in my ~/.emacs… where I found a version I’d already written and completely forgotten about. Ah, life.

  • sshelagh

    Fantastic idea to use org-drill in general org files.Somehow missed that idea before.

    Also this almost makes me want to go through the pain of turning my .emacs into an org file. :-)

On This Day...

  • 2012: Experience report: So much for having a virtual bookstore — As part of my experiments in entrepreneurship, I decided to try out selling used books online. I like books, and [...]
  • 2011: Get More Value from Blogging, part IV: Connecting with People — Paul Gillin invited me to do a tweetchat on the professional and personal value of blogging on March 3, 2011 [...]
  • 2010: Getting ready for a new adventure — I didn’t think about weddings when I was growing up. I didn’t clip pictures of pretty dresses or fantasize [...]
  • 2009: VA Days: Rethinking web search and virtual assistance — While preparing a 6-minute demo of the way I use del.icio.us and Ubiquity to organize my web research, I had [...]
  • 2009: VA Days: Refining web research process for virtual assistance — I do a lot of web research, and I’d like to be able to outsource that to a virtual assistant. [...]
  • 2007: Wow — Just came back from dinner with Jane Zhang and Wayne Young… Wow! What wonderful conversation! What fun! Who knew she was [...]
  • 2006: Finished my tenth speech! — I’m now eligible for the Competent Toastmaster (CTM) award! Hooray, hooray! My tenth speech was named “Cook or Die”, and I [...]
  • 2006: Sweet potato and chicken vinaigrette salad — Level up! Purple sweet potato, cubed (1 inch) Chicken breast, cubed: can be leftovers Lettuce Vinaigrette, or balsamic vinegar, olive oil, salt and pepper Put [...]
  • 2006: Good Food Box: Pear Poofery — Here’s what in the Good Food Box for this fortnight: 2 lbs purple sweet potatoes 2.5 lbs yukon gold potatoes 1 broccoli 2 lbs carrots 1 pack mushrooms 1 lb beets 1 head romaine [...]
  • 2005: Firedance — You’d expect a show called “Firedance” to have more than ten seconds of fire in it, right? And not just as [...]
  • 2004: RSS aggregator — I’m looking for an RSS aggregator (web-based or command-line) that will take a list of feeds and produce an RSS feed. [...]
  • 2004: Uh oh. — My pet arch-lich (polytrap) just killed the Oracle. I have a feeling that wasn’t supposed to happen. So far so good. [...]
  • 2004: Dudley’s dungeon — http://dudley.nicolaas.net/ Dudley’s dungeon is a daily comic about NetHack and other important things in life, set in the familiar surroundings of the [...]
  • 2003: thesis requirements — CS197. Senior Thesis / Project Presentation Schedule of defense will be on March 3. 2003 from 8:00 AM to 3:30 PM Requirements: Each group [...]
  • 2003: cs161f exemptions — The following students can choose not to take the CS161 final exam: - 1. Francisco, Mike – 95.4 (A) - 2. Sy, [...]
  • 2003: doc sarmenta has a sister.. — Clarissa. And she’s coming to the open house. A freshman? Interesting. =)
  • 2003: Mike Chua — “It’s a 16-way processor that allows you to consolidate your data center. I’m going to play with one of these!”

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!