Category Archives: org

Transcript: Emacs chat with John Wiegley

This post is long, so if you’re reading this on the main page, go to http://sachachua.com/blog/2012/07/transcript-emacs-chat-john-wiegley/ to view the full transcript!

Here’s the video.

You can also download the MP3.
[Read more →]

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

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!

Mailing non-Emacs users your Org notes

Andras uses Emacs Org-mode to take notes during meetings, and wanted to know how to share those notes (including tables) with colleagues afterwards. Here are some tips for sharing Org notes with non-Org people.

You can copy the information as plain text. If you don’t have too much Org markup, you can copy and paste the text into your mail message. To get tables and other segments to line up nicely, make sure you format the text with a monospace font such as Courier New or Lucida Console.

You can export the information to HTML and then copy it into your message. Export the entire file with M-x org-export or export a region with M-x org-export-region-as-html. Save it to a file, open that file in your browser, then copy and paste the information. If you find yourself working with the same files often, consider using Org’s publishing support to simplify the creation of related HTML files.

You can also publish your notes on an internal or external blog. I post many of my notes on my blog (including this one!) using org2blog.el. If you publish your posts on a blog, you can send people a link, update your post with new information, and share your post with others.

Hope that helps!

More MobileOrg hacking on the Android

I’ve gotten IBM’s permission to contribute my changes back to the MobileOrg project, yay! (Disclaimer: I’m doing this as myself and not as an employee of IBM, and all the usual disclaimers apply.) Code and issue-tracking at https://github.com/sachac/mobileorg-android.

Before and after:

editbefore[1] image

There are still bugs to work out, but whee!

New note-taking workflow with Emacs Org-mode

The new workflow looks like it works better for me. Or rather, it’s an old workflow with new tools. Now, instead of using Windows Live Writer or ScribeFire to post my notes directly to my blog, I’m back to using M-x remember and Emacs, keeping a superset of my notes in text files and publishing selected parts of it.

  • The new workflow
    • M-x remember saves quick notes into a large text file (~/personal/organizer.org), possibly with tags, with diagrams inserted later.
    • I regularly review and file items into the appropriate sections of ~/personal/outline.org.
    • I post selected items to my blog using C-u M-x org2blog-post-subtree, scheduling them by adding a timestamp or using the C-c C-s (org-schedule) command.

    I sometimes use Microsoft OneNote on my new tablet to take notes during meetings, but it’s easy enough to convert my handwriting to text and paste it into my Org-mode file. I still have to think of a better way to refer to images while keeping my file manageable, but a filename is probably okay.

  • A worked example

    This is being composed in a M-x remember window. (Well, remember is bound to C-c r on my system, so it’s easy to invoke).

    After I finish braindumping, I’ll use C-c C-c to save it somewhere.

    I may schedule the post immediately (C-c s (org-schedule) and then C-u M-x org2blog-post-subtree), or tag it for later review. (:toblog: – ready to go, but not scheduled? :rough: – needs more thinking?)

    When I review the items, I’ll copy this into the Geek – Emacs section of my outline.org.

    It feels nice having my notes in plain text, and being able to organize it in more than just chronological order…

  • The history

    From 2001 to about 2006, I kept an Emacs Planner wiki with all of my notes in it. Emacs Remember let me write notes that were automatically hyperlinked to whatever I was looking at, and I added code to Planner that made it easy for me to file the notes both chronologically and topically. Planner rocked. I loved being able to easily hyperlink between topics, and the wiki structure kept pages a mostly manageable size. (My public Planner files are still on the Net, but I need to regenerate the index or enable directory lists so that they’re usable.)

    When I moved to WordPress as a blogging platform in order to make it easier for people to leave comments, I hacked around with RSS to import my posts from Planner into WordPress (ex: http://sachachua.com/blog/2002/). Moving to WordPress meant a change in my workflow. I now had two places to store my notes: Planner and my blog.

    I tried Emacs Org because I liked the way it organized information. In Planner, we’d been struggling with elegant ways to manage tasks and notes that needed to be accessed in multiple contexts. The approach we had taken in Planner was to make copies of the information, but Org had a cleaner way to do it using different views. It was intriguing.

    When I started working at IBM, however, my information workflow diverged. I shifted to using a web-based to-do list and Lotus Notes, posting on an internal blog and an external one, and managing multiple sources and repositories of information.

    I wanted to go back to keeping my notes in plain text, encrypted if necessary, and to have a place where I could keep notes that might not be publishable. I still had to manage multiple computers, but synchronizing systems like Dropbox or SpiderOak got rid of some of the hassles I’d encountered with git. When I found out about org2blog thanks to a test link from punchagan, I modified the code to work with subtrees instead of new buffers, and that solved the blog publishing part of it.