6200 comments
2357 subscribers
Follow me on Twitter (@sachac)
Subscribe! Feed reader E-mail

Reading these posts, you can probably tell that I really, really like the Emacs text editor.

View my Emacs configuration.

Check out Planet Emacsen to read other Emacs geeks’ blogs. For all things Emacs, check out the EmacsWiki.

On this page:

Using Emacs Org for grocery lists and batch cooking

We like preparing our meals in bulk. Buying groceries and cooking up a storm on the weekends means that we can grab quick and healthy lunches from the fridge or freezer, enjoy a variety of dinners during the week, and focus on other things that we want to do in the evenings.

I was looking for a menu planner and grocery list maker to help us plan and execute these batch cooking sessions more efficiently. In particular, I wanted something that could sort the ingredients for preparation, too. I like preparing ingredients for all the different recipes before I start cooking. If several recipes call for garlic, I might as well chop a lot of garlic in one session instead of breaking out the chopping board for each recipe.

I tried several menu planning and grocery list apps, but I wasn’t happy with any of the ones I came across. I like using Emacs for as much as possible, so I figured that I should give it a try. Here’s what I did and how it worked out.

I created an Org file for my recipes. In this plain-text outline, I created sections for my plan, shopping list, preparation tasks, and recipes. Under recipes, I created TODO items and scheduled them. Here’s an example entry:

** TODO Colorful bulgur salad
   SCHEDULED: <2012-06-19 Tue>

http://allrecipes.com/recipe/colorful-bulgur-salad/

| 1/2 cup        | bulgur wheat     |                    | [[Colorful bulgur salad]] |
| 1/2 cup        | chicken broth    |                    | [[Colorful bulgur salad]] |
| 1 small        | cucumber         | seeded and chopped | [[Colorful bulgur salad]] |
| 1              | tomato           | chopped            | [[Colorful bulgur salad]] |
| 1              | carrot           | shredded           | [[Colorful bulgur salad]] |
| 3              | green onions     | thinly sliced      | [[Colorful bulgur salad]] |
| 3 tablespoons  | fresh lime juice |                    | [[Colorful bulgur salad]] |
| 3/4 tablespoon | chili powder     |                    | [[Colorful bulgur salad]] |
| 1 pinch        | garlic powder    |                    | [[Colorful bulgur salad]] |

I reformatted each recipe to fit this format, with columns for quantity, type, preparation, and recipe link. After I chose several recipes, I copied the ingredient lists into my preparation section and my shopping section. In the shopping section, I deleted the lines for ingredients I already had or could skip. I used org-table-sort-lines to sort the table by the second column, which gave me this list:

| 1 bag              | chicken legs and thighs |                                                        | [[Arroz caldo]] |
| 2 small or 1 large | cucumber                | chopped                                                | [[Gazpacho]] |
| 1 small            | cucumber                | seeded and chopped                                     | [[Colorful bulgur salad]] |
| 3                  | green onions            | thinly sliced                                          | [[Colorful bulgur salad]] |
| 1                  | red onion               | cut into 1" pieces                                     | [[Shrimp kebabs]] |
| 1 pound            | shrimp                  | peeled and deveined                                    | [[Shrimp kebabs]] |
| 6 - 8              | tomatoes                | chopped (Roma or plum are best; Don't lose the juice!) | [[Gazpacho]] |
| 1                  | zucchini                | seeded and cut into 1" pieces                          | [[Shrimp kebabs]] |

It wasn’t sorted by aisle, but that was easy to do when I copied the list onto a recycled envelope. If I find myself using this a lot, I might write an Emacs Lisp function to gather the tables and sort the rows by aisle.

Anyway, shopping list in hand, we picked up our groceries in about ten minutes last Saturday. The next day, I looked at my prep list:

|                    | basil                                  | chopped                                                | [[Gazpacho]]              |
| 1/2 cup            | bulgur wheat                           |                                                        | [[Colorful bulgur salad]] |
| 1 tbsp             | butter                                 |                                                        | [[Bubble and squeak]]     |
| 2 tbsp             | canola or peanut oil                   |                                                        | [[Teriyaki tofu]]         |
| 1                  | carrot                                 | shredded                                               | [[Colorful bulgur salad]] |
| 1/2 cup            | chicken broth                          |                                                        | [[Colorful bulgur salad]] |
| 1 bag              | chicken legs and thighs                | separated                                              | [[Arroz caldo]]           |
| 3/4 tablespoon     | chili powder                           |                                                        | [[Colorful bulgur salad]] |
| 1/4 cup            | cider vinegar                          |                                                        | [[Teriyaki tofu]]         |
| 1 can              | corned beef                            |                                                        | [[Bubble and squeak]]     |
| 3 tbsp             | cornstarch                             |                                                        | [[Teriyaki tofu]]         |
| 1 tbsp             | cornstarch                             |                                                        | [[Teriyaki tofu]]         |
| 1 small            | cucumber                               | seeded and chopped                                     | [[Colorful bulgur salad]] |
| 2 small or 1 large | cucumber                               | chopped                                                | [[Gazpacho]]              |
| 1 lb               | firm tofu                              | drained                                                | [[Teriyaki tofu]]         |
|                    | fresh ground black pepper              |                                                        | [[Gazpacho]]              |
| 3 tablespoons      | fresh lime juice                       |                                                        | [[Colorful bulgur salad]] |
| 3 cloves           | garlic                                 | chopped                                                | [[Arroz caldo]]           |
| 1 clove            | garlic                                 | minced                                                 | [[Teriyaki tofu]]         |
| 2 cloves           | garlic                                 | diced                                                  | [[Gazpacho]]              |
| 1 tablespoon       | garlic                                 | minced                                                 | [[Shrimp kebabs]]         |
| 1 pinch            | garlic powder                          |                                                        | [[Colorful bulgur salad]] |
|                    | glutinous rice                         |                                                        | [[Arroz caldo]]           |
| 1 tsp ginger       | grated or minced                       |                                                        | [[Teriyaki tofu]]         |
|                    | green onions                           | chopped                                                | [[Arroz caldo]]           |
| 3                  | green onions                           | thinly sliced                                          | [[Colorful bulgur salad]] |
|                    | leftover vegetables (cabbage, carrots) |                                                        | [[Bubble and squeak]]     |
| 1                  | lemon                                  | juice of                                               | [[Gazpacho]]              |
| 2 teaspoons        | lemon juice                            |                                                        | [[Shrimp kebabs]]         |
| 1/4 cup            | olive oil                              |                                                        | [[Shrimp kebabs]]         |
| 1                  | onion                                  | thinly sliced                                          | [[Bubble and squeak]]     |
| 1/2 large          | onion                                  | chopped finely       (red is a nice alternative)       | [[Gazpacho]]              |
| 1/2 large          | onion                                  | chopped in 1/4 inch chunks                             | [[Gazpacho]]              |
| pinch              | parsley                                | finely chopped                                         | [[Shrimp kebabs]]         |
| 1/4 tsp            | pepper                                 |                                                        | [[Teriyaki tofu]]         |
| 1/4 teaspoon       | pepper                                 |                                                        | [[Shrimp kebabs]]         |
| 3 cups             | potatoes                               | mashed                                                 | [[Bubble and squeak]]     |
| 1                  | red onion                              | cut into 1" pieces                                     | [[Shrimp kebabs]]         |
|                    | salt (preferably sea salt)             |                                                        | [[Gazpacho]]              |
| 1 tsp              | sesame oil                             |                                                        | [[Teriyaki tofu]]         |
| 1 pound            | shrimp                                 | peeled and deveined                                    | [[Shrimp kebabs]]         |
|                    | soy sauce                              |                                                        | [[Arroz caldo]]           |
| 1/2 cup            | soy sauce                              |                                                        | [[Teriyaki tofu]]         |
| 1                  | tomato                                 | chopped                                                | [[Colorful bulgur salad]] |
| 6 - 8              | tomatoes                               | chopped (Roma or plum are best; Don't lose the juice!) | [[Gazpacho]]              |
|                    | virgin olive oil                       |                                                        | [[Gazpacho]]              |
| 1/2 cup            | white sugar                            |                                                        | [[Teriyaki tofu]]         |
| 1                  | zucchini                               | seeded and cut into 1" pieces                          | [[Shrimp kebabs]]         |

Sorting the list by ingredient made it easy to go through the groups of ingredients and prepare them all, and the links to the recipes made it easy to look up next steps. I planned the order of doing them. First, I prepared the bulgur wheat because that needed an hour to soak. I saved the chicken legs for the end because they were messy, and I saved the onions for later as well because they always make me cry. I cut and chopped and food-processed my way through stacks of vegetables, covering the kitchen table with bowls.

With all the ingredients prepared, I washed the utensils and put things away. That freed up counter space for cooking. I reordered the recipes so that it was easy to see what to work on next, and I started cooking.

The entire cooking sprint took me 5 hours and 42 minutes, which was a lot of cooking but well worth it. With that and the meals we’d prepared over the past few weeks, our freezer’s stuffed to capacity. Four tidy stacks of identical food containers, then odds and ends crammed into the spaces! By golly.

I really liked planning this batch cooking session in Emacs. Org tables made things easy to sort, and the hyperlinks let me look up recipes and notes quickly.

I could probably make this even better by:

  • rigging up my foot pedal to scroll up and down through food.org
  • copying in the recipe steps so that I can take advantage of that scrolling
  • figuring out how to use Org Babel to automatically compile the ingredient tables for the named recipes

Now if only someone would write M-x wash-dishes

Short URL: http://sachachua.com/blog/p/23504

Things that I’ve used Emacs for

Emacs can do a ton thanks to the code that people have contributed over the decades. Here’s a list of things I’ve used Emacs for, although I’m sure I’ve still missed a few!

  • Taking notes
    • Storing reference information
    • Publishing blog posts
  • Programming / coding
    • Rails
    • PHP / Drupal
    • Java
    • Javascript
    • HTML / HAML / ERB
    • CSS / Sass
    • Emacs Lisp
    • Ruby
    • Perl
    • SQL
    • Bash scripts
  • Managing my to-do list
  • Timing tasks
  • Managing my finances
  • Studying
    • Dictionary (Japanese)
    • Flashcards
      • With random fortunes displayed for correct answers
      • With random images displayed for correct answers (cute kittens!)
    • Example sentences lookup (Japanese)
    • Random example sentence added to blog posts (Japanese)
  • Brainstorming, outlining, and mindmapping
  • Handling my mail
    • Doing mail merges or file merges
    • Tracking correspondence
    • Personalizing greetings and signatures
  • Managing contacts
  • Writing research papers
  • Managing my bibliography
  • Making presentations
    • Planning presentations
    • Delivering dynamic presentations (with executable code!)
    • Using speech synthesis to remind myself about what’s coming in the next “slide”
  • Reading documentation
  • Analyzing my blog and my writing
  • Running a shell
  • Searching files
  • Cleaning up, filtering, or transforming text
    • String and regexp replacement
    • Keyboard macros
    • Custom Emacs Lisp functions
  • Editing files on a remote server
  • Editing files inside an archive
  • Reviowing and making text notes about images and other files
  • Chatting on IRC
  • Chatting on instant messengers
  • Checking the calendar
  • Playing Nethack
  • Playing dunnet and snake
  • Browsing the Web
  • Posting to Twitter and other status update sites
    • Rigging up my to-do list to automatically publish task data to an internal status update site
  • Calculating expressions
  • Using a spreadsheet
  • Exploring directories
  • Renaming, deleting, or moving files
  • Drawing ASCII art
  • Reading news
  • Comparing files or revisions
  • Typing in Japanese or Latin
  • Reviewing similar files
  • Synthesizing speech – “reading” books, technical manual, mail, etc.
  • Learning more about Emacs
    • Random symbols and commands
    • Documentation
    • Source code
  • ROT13 and Morse code encryption/decryption
  • Editing GPG-encrypted files
  • Practising typing
  • Opening spreadsheets and other files downloaded from the Web
  • Taking screenshots (mostly of Nethack games)
  • Analyzing web logs and other files
  • Calculating days between two dates
  • Sending text messages
  • Analyzing source code
  • Interacting with APIs
  • Doing weekly, monthly, and yearly reviews
  • Versioning my files
  • Expanding text snippets
  • Drafting a book
    • Tracking my progress
  • Editing files as root
  • Compiling and running programs
  • Editing text from the browser
Short URL: http://sachachua.com/blog/p/23471

Literate programming and my Emacs configuration file

Inspired by the Emacs Starter Kit and the literate programming features in org-babel, I reviewed and organized my Emacs configuration. I’m looking forward to adding more notes to my configuration as I explore!

Literate programming is the idea that you should write first and program second, and that you can interweave the program into your explanation. Nifty.

Here’s my Emacs configuration. Share yours! =)

Short URL: http://sachachua.com/blog/p/23472

Where I am in terms of Emacs

Now that I have more control over the tools I use, I use Emacs for more of my planning. I’m back to using Org Mode to manage my task list (hooray!), and it has grown by leaps and bounds. I’m looking forward to getting even deeper into it.

Here’s where I am in terms of Emacs

I’m still on Microsoft Windows 7 because I like some of the drawing programs that I can’t get to run on Linux, so my Emacs experience is less than ideal but still okay. It’s one of the first applications I start after a reboot, and I keep Emacs open almost all the time. I’ve pinned Emacs to my task bar (right-click on the icon and pin it) and moved it to the first slot, so Win+1 gets me back to Emacs.

When I’m at my client site, I use the laptop they provided to do work, and I use a wiki page to manage and publish my task list. I use Emacs during the early morning, the evening, weekends, and personal days.

I use org-capture to quickly capture tasks and notes. Here are some of the templates I use:

(setq org-capture-templates
      '(("t" "Tasks" entry
         (file+headline "~/personal/organizer.org" "Tasks")
         "* TODO %?
SCHEDULED: %^t")
        ("q" "Quick task" entry
         (file+headline "~/personal/organizer.org" "Tasks")
         "* TODO %^{Task}
SCHEDULED: %^t"
         :immediate-finish t)
        ;; other entries go here
        ("r" "Notes" entry
         (file+datetree "~/personal/organizer.org" "Inbox")
         "* %?\n\n%i\n"
         :clock-in :clock-resume)))

The Org agenda helps me check what I need to do. I have it set up to display the time grid so that I get a relative sense of where things are. I use a 2-day view so that tomorrow is in my peripheral vision.

Here are some things I want to explore:

  • Improve the integration of Org and my self-tracking system at quantifiedawesome.com
  • Use Org for blog posts with images (I don’t quite trust it yet, although I’ve used it before)
  • Take notes in Org Contacts instead of stuffing notes into BBDB
  • Read the Org Mode mailing list and Planet Emacsen more often to get inspiration, maybe contribute patches
  • Get MobileOrg working for me smoothly on my Android – need to get the hang of the workflow
  • Use Org’s literate programming support to annotate my Emacs configuration
Short URL: http://sachachua.com/blog/p/23348

Org-mode and habits

Org Mode is a personal information manager for the Emacs text editor. People have contributed a ton of useful features to it over the years, and the development shows no sign of slowing down. One of the features I’ve been playing around with is the ability to track habits.

Org habits are recurring tasks. For example, everyday, I want to:

  • take my vitamins
  • capture a quick note about the day, and
  • plan the next day

Every week, I want to:

  • talk to my mom
  • check the org-mode mailing list
  • write a weekly review and plan the next week
  • clear and reorganize my belt bag
  • clear my inbox
  • write a bunch of blog posts
  • back up my computer

Once a month, I want to:

  • update the topical index for my blog
  • review and uninstall programs
  • balance my books and update my budget
  • review the past month and plan the next
  • check the library for new books

Org habits let me manage my task list without cluttering future days with tasks. The Org agenda view displays habits that are due today, indicating consistency with colour. In particular, it shows overdue days in red, so you can get the Seinfeld-esque pleasure/commitment-device of not breaking the chain.

Here’s a view from Sunday:

2 days-agenda (W19-W20):
Sunday     13 May 2012
               8:00...... ----------------
              10:00...... ----------------
              12:00...... ----------------
              14:00...... ----------------
              15:57...... now - - - - - - - - - - - - - - - - - - - - - - - - -
              16:00...... ----------------
              18:00...... ----------------
  organizer:  22:00...... TODO Capture a one-sentence note                                           !       
  organizer:  22:00...... TODO Plan the next day                                    ** ***** ** *****!       
  organizer:  Scheduled:  TODO Make a list of recipes I want to learn
  organizer:  Scheduled:  TODO Write a bunch of blog posts             :writing:
  organizer:  Scheduled:  TODO Set up WordPress as my backup system
Monday     14 May 2012 W20
  organizer:  Scheduled:  TODO Build Emacs interface so that I can have Org automatically switch my tasks

To use Org habits, customize org-modules and enable the habit module. To set something as a habit, use C-c C-x p (org-set-property) to set the STYLE property to habit. For more information, you should definitely check out the Org manual’s section on habits.

Yay Emacs and the people who contribute to it!

Short URL: http://sachachua.com/blog/p/23381

Maintaining a manual topical index for my blog using Emacs

I’ve been blogging for almost ten years. I started with notes from my university classes and snippets of open source code, and became comfortable enough to share decisions I’m puzzling through and things I’m learning about life. There’s a lot of stuff in my archive, and I want to be able to review things again.

Categories would probably make this easier, but I use categories liberally and sometimes inconsistently. I use them like tags, quick keywords that I add so that people might explore a category and bump into other posts. I probably should split it out so that I assign posts to one category and leave everything else as tags. Someday.

In the meantime, it’s easy enough to maintain a manual topical index of my blog posts, and it’s a good opportunity to review what I’ve been writing as well.

I use Emacs Org Mode to manage a large text file divided into headings. Every month, I copy a list of titles into my topical index. I hacked Org-friendly output into my WordPress theme – you can see April’s blog posts as an example (sachachua.com/blog/2012/04/?org=1). I manually organize the list items under different headings, splitting off new headings when I can see a pattern. Working with two windows viewing the same buffer makes it easy to move information around, and org-refile is handy too. I use a checklist structure so that Org can automatically update the number of posts under each heading (C-u M-x org-update-statistics-cookies). When I’m happy with the structure, I use org-publish-current-file to publish it using the settings I’ve configured. The files are in my public Dropbox folder, so they’re automatically published to the Web. It takes me about 10 minutes to add a month of posts to my index and publish the page.

I like seeing how much I’ve written about different topics, and it encourages me to write and organize more posts. Maybe the index might be handy for other people too!

Short URL: http://sachachua.com/blog/p/23343

Emacs: Telling external processes about terminal capabilities, and watching over other people’s shoulders

Justin Giancola (@elucid) wanted to use full-ack.el to search through his project files using the Ack tool, but Ack refused to run because it didn’t think his terminal had enough capabilities. A simple fix was to set the TERM variable with

(setenv "TERM" "xterm")

which told Ack that Emacs was fine with its output.

(Speaking of Ack integration – This being the Emacs world, there’s more than one way to do things. You might also want to check out ack-and-a-half.el, which is midway between ack.el and full-ack.el.)

It was interesting hanging out with someone else who used Emacs, and being able to share tips. I don’t run into many other Emacs geeks, but I sporadically hang out in the #emacs channel or browse Planet Emacsen to be inspired. It’s funny how many of the meetups I go to end up involving Emacs conversations. It’s like I have a big M-x banner hovering over my head. =) It’s awesome, actually!

Short URL: http://sachachua.com/blog/p/23114