M-x plan :: sachachua's blog http://sachachua.com/notebook/wiki/today.php Sacha Chua's blog about Emacs, personal information management, open source, and random stuff Weekly review http://sachachua.com/notebook/wiki/2008.01.13.php#anchor-2 http://sachachua.com/notebook/wiki/2008.01.13.php#anchor-2 This week was a week for catching up with coworkers. Aaron Kim got back from his vacation and took off again for another trip spreading the good news about IBM and Web 2.0 in London. Fortunately, I caught him at 120 Bloor on Monday. I also chatted with Bernie Michalik about writing (apparently, I say "Good stuff" just about every post on our team blog, The Orange Chair). And I welcomed Jen Nolan back from mat leave by treating her to lunch and thanking her for the career advice she gave me last year. =) Good times.

I've also made a lot of progress on the wiki that I'm building for a financial services company. I'm proud of the way it's shaping up: a guide for internal consultants, a guide for community core team members, and a guide for other employees using these social media tools (blogs, wikis, forums). I like the way that it's not just about how to use these tools - click this, type in that - but also how people can use the tools together to do what they want to do.

I joined another IBMer for an interview with a reporter from a major business magazine who was writing an article on these "water-cooler technologies". I'm thrilled every time I get an opportunity to tell people about some of the cool stuff we're doingbeing. And last Friday, another person got in touch with me to ask permission to quote me in the annual report of a project I love. Wow! There's something powerful about being vocal about appreciation.

On the personal side, I went to the dentist and had a lot of fun chatting with the person who scrubbed my teeth. =) It turns out that my wisdom teeth will probably need to be removed, as they're growing all funny. In other news, the glasses that I ordered from Zenni Optical have left Hong Kong and should be on their way to Canada.

More progress on the book. I've started on the chapter on taking notes, and I have about 3000 words so far. My target is 12,000 words, or about 35 pages. I plan to finish it by January 31, according to my original schedule. I'm averaging about 1000 words a day, but I should find a way to resist the temptations of Lego Star Wars DS. It'll be easier to write when J-'s distracted by other things! I have 9 writing days, if I alternate writing with editing and other things I need to do. This is doable. Fun, even. =)

(See, I'm getting the hang of this! Next step: graphs...)

W- and J- are doing fine. W-'s been cooking up a storm, and he's now baking some egg tarts. (Home-made egg tarts! I'm so spoiled.) I made up for a little of it by exercising earlier, but I really need to keep it up, considering how fun food is around here...

I was glad to have had the opportunity to talk to one of my best friends when she was feeling really really homesick. She's studying at Purdue right now, and she really misses home. Her advisor is open to her working from the Philippines, and I hope everything works out with her department.

It was fun chatting with my parents, too. W-, J-, and I are planning to fly to the Philippines for two weeks this March, and we're starting to plan what to see. I hope we're not too late to book flights to Boracay!

Oh, and I've overcontributed to my RRSP, but I haven't gone over the lifetime limit yet (whew!). Now I have to figure out the best non-registered way to save for my retirement so that I can gradually push my retirement age further and further back. (I should put together some kind of spreadsheet that calculates this for me...) I suppose I _could_ find a financial advisor, but he or she would have to be able to tell me stuff that I haven't read in the dozens of books I've read on personal finance. Good stuff, mind you, not things like "Go into daytrading" or "Pick this high-MER loaded mutual fund that'll give me plenty of commissions." Oh, and a financial advisor who's used to dealing with people who aren't panicking about debt, and who are interested in planning long-term.

Or maybe I should just learn to do everything myself, because financial planning is, after all, a lifelong skill. My books are all nicely balanced, although I had to create a slide deck to remind myself exactly how my budgeting system works. That's _probably_ a sign that it can be simplified further. It seems to work. I just have to trust it. Actually, the next step would be to use invariants (thank you, Problem Solving and Methods of Proof, and numerous other computer science and math courses!) to _prove_ that it's correct. I will explain this in another post. =)

So that's where I am in terms of work, health, book, family and friends, and money. There are lots of other stories to tell, but this is just a quick overview of where I am.

Next week: More wiki work. It would be great if I could find other people to contribute to it, as I get lots of great ideas by bouncing them off others. I also need to start on my US visa paperwork for a conference I want to attend in April, and I need to do some more work on my permanent residency application (applying for clearances everywhere I've ever lived, and following up on employment confirmation with my old department).

Life is good.

Random Emacs symbol: w3m-add-local-hook - Function: Add to the buffer-local value of HOOK the function FUNCTION.

]]>
Sun, 13 Jan 2008 20:32:00 EST weekly
Capturing Notes with Remember http://sachachua.com/notebook/wiki/2008.01.13.php#anchor-1 http://sachachua.com/notebook/wiki/2008.01.13.php#anchor-1 Ideas come from everywhere. While reading this blog, you might come across interesting snippets that you'd like to save. While writing code, you might be hit by an idea for something you want to do with the program. While on a phone call, you might need to write down what you need to prepare for a meeting the next day.

How do you take notes now? Do you jot your notes on a scrap of paper or into a leather notebook? Do you copy and paste what you're looking at into a plain text file or document? Do you scribble things into a personal digital assistant?

I've tried different note-taking strategies: colorful mindmaps, outlined text files, even voice recordings. I felt frustrated every time I had to write down whose e-mail or which webpage prompted the note (shouldn't the computer do that automatically?), but I was even more frustrated when I'd come across a note and not remember why I wrote it.

Remember changed all that for me. The key ideas behind Remember are that you should be able to write notes with minimal distraction, and that as the context should be automatically picked up so that you don't have to write it down. If you're writing a note based on a mail message, Remember will pick up the details of the message and create a hyperlink so that you can view the original message when reviewing your notes. If you're working on a file, Remember will link to it so that you can jump back to it. If you're browsing a web page (in Emacs, of course), Remember will remember the title and URL, so that you can go back to the page when you want to clarify something in your notes. And after you save the note, you'll be back in the same environment you were: no need to switch applications and no need to remember different keyboard shortcuts.

You might think that Remember's only worth it if you do _everything_ in Emacs. For me, it worked the other way around. I started by using Remember to take notes in Planner, a personal information manager available for Emacs. As I got accustomed to the way Remember and Planner just automatically hyperlinked to whatever I was looking at, I thought: Why doesn't my mail client do this? Why doesn't my web browser do this? Why doesn't my chat client do this? So I ended up reading through the manuals, figuring out how to do all these things in Emacs—and I loved it, eventually doing most of my work (and play!) within an Emacs frame. Although I use other applications now, like Lotus Notes for work mail and Mozilla Firefox for browsing, I still switch back to Emacs for my notes.

In this section, you'll learn how to set up Remember and take quick notes in Emacs. We'll start by configuring Remember to save your notes to a file, and how to configure Remember to save to different places depending on the content. You'll also learn how to quickly search your notes file for entries.

You can also integrate Remember into other note-taking systems in Emacs. The sections that cover those systems will also show you how to configure Remember to save your notes there.

Setting Up Remember

Remember is a separate package, which you can download from https://gna.org/projects/remember-el . As of this writing, the latest stable release is Remember 1.9. Download the latest version and unpack it into your ~/elisp directory. You should end up with a new directory, ~/elisp/remember-1.9 .

To configure Remember to save to plain text files, add this code to your ~/.emacs and evaluate it:

(add-to-list 'load-path "~/elisp/remember-1.9") ;; (1)
(require 'remember-autoloads)
(setq remember-data-file "~/notes.txt")  ;; (2)
(global-set-key (kbd "C-c r") 'remember) ;; (3)

(defun wicked/remember-review-file ()
 "Open `remember-data-file'."
 (interactive)
 (find-file-other-window remember-data-file))
(global-set-key (kbd "C-c r") 'wicked/remember-review-file) ;; (4)
  • 1: Change this to the directory that contains remember.el
  • 2: Notes will be saved to this file. You can change this if you want; just keep in mind that this section refers to ~/notes.txt.
  • 3: C-c r (remember) is a handy shortcut key for remember. You can also bind it to other shortcut keys such as F9 r.
  • 4: This shortcut makes it easy to check your remembered notes.

After you've configured Remember, try it out by typing C-c r (remember). Your Emacs frame will be split in two, and one of the windows will be a *Remember* buffer. Type your note. The first line will be the headline, and the rest of the buffer will be the body of the note. If you call C-c r (remember) from a file, the filename will automatically be included at the end of the buffer. Type C-c C-c (remember-buffer) to save the note.

Try it now by typing C-c r (remember) to bring up the buffer, typing in a short note, and using C-c c (remember-buffer) to save it. If you open ~/notes.txt to review your note, you'll find something like this:

 ** Sat Jan 12 14:43:02 2008 (Your headline goes here)

 Your note body goes here

 /home/sacha/.emacs

You can even save yourself some copying and pasting. Mark a region of text and use C-u C-c r (remember). The selected text will be included in the buffer, so all you have to do is comment on it.

Make a habit of typing C-c C-r or C-u C-c C-r (remember) when you need to remember something. Type C-c C-c (remember-buffer) to get back to work, knowing that your notes have been safely saved in your ~/notes.txt file.

Reviewing Your Notes

Use C-c R (wicked/remember-review-file) to check your notes, or open ~/notes.txt yourself.

To search your notes, use C-c R (wicked/remember-review-file) to open the file, then use C-s (isearch-forward) to search for words interactively, or use M-x occur to find all lines containing a word.

You may notice that the default format that Remember uses is an outline format that is compatible with Org and Allout, both of which have powerful outline-editing tools. I prefer Org's outline-editing commands, and you'll learn about them in the "Outline Notes with Org" section. Here's a quick summary.

First, you need to switch the buffer to Org mode by typing M-x org-mode. To automatically open your notes file in Org mode, add

-*- mode: org -*-

to the first line of your ~/notes.txt. Then, when you open your ~/notes.txt file, it will be in Org mode.

You can quickly collapse or expand all the outline entries by pressing S-TAB (org-shifttab). To collapse or expand a single entry, move the point to the headline (the line beginning with *, **, or any number of asterisks), then press TAB (org-cycle). To move an entry up or down, move the point to the headline and press S-UP (org-shiftup) or S-DOWN (org-shiftdown). To demote or promote a heading, press M-RIGHT (org-metaright) or M-LEFT (org-metaleft).

You can treat ~/notes.txt as your inbox, and keep your organized notes in another file or groups of files. Cut and paste the text between the files to clear your inbox, and use M-x grep to search multiple files. Alternatively, you can keep all of your notes in one large text file, and use C-s (isearch-forward) and M-x occur to search for information.

Now you know the basics of remembering information, saving it into a file, and reviewing the file. By default, Remember annotates your notes with a filename, if you were looking at a file when you called C-c r (remember). As you learn more about Emacs, you may want to configure Remember to add more intelligent annotations and other text to the Remember buffer. The more work Remember does for you, the less work you have to do!

Enabling annotation functions

The easiest way to get Remember to automatically understand mail messages, Web pages, info files, BBDB contact records, and other sources of information in Emacs is to use either Org or Planner. To learn how to integrate Remember with either Org or Planner, read the section on "Outline Your Notes with Org" and "Writing Your Journal with Planner".

You can also define your own annotation functions. When you call C-c r (remember) from a buffer, Remember goes through each of the functions in remember-annotation-functions, and it uses the first non-nil value returned.

For example, you may work with many temporary buffers that don't have filenames. To create an annotation function that adds buffer names, add the following code to your ~/.emacs after the basic Remember configuration code:

(eval-after-load 'remember
  '(progn
    (add-to-list 'remember-annotation-functions 'buffer-name t)))

This adds buffer-name to the end of the annotation list, making it a last resort.

What if you want line numbers included with the filename or buffer name? You could replace the previous code with this:

(defun wicked/remember-line-numbers-and-file-names ()
 "Return FILENAME line NUMBER."
 (save-restriction
  (widen)
   (format " %s line %d"
    (or (buffer-file-name) (buffer-name))
    (line-number-at-pos))))
(eval-after-load 'remember
  '(progn
     (add-to-list 'remember-annotation-functions
                  'wicked/remember-line-numbers-and-file-names)))

With that code, C-c r (remember) will automatically pick up the line number from your file or buffer.

By default, Remember saves your notes to a plain-text file, so you'll have to open the files manually. The command M-x ffap or find-find-file-at-point may be convenient. If you want hyperlinks that you can visit easily, consider saving your notes in an Org or Planner file instead.

Now you've got context. What else can you do with the Remember buffer?

Adding Other Text to the Remember Buffer

Remember has plenty of hooks that let you modify the behavior. For example, you might want to insert a random tagline or fortune-cookie saying whenever you create a note. This is a fun way to encourage yourself to write more, because then there's a little surprise every time you open a Remember buffer.

Here is a totally small-scale way to use random lines from a text file. Let's say that you have a text file made up of movie quotes, taglines, knock-knock jokes, or short fortune-cookie sayings. When I wrote this code, I used Japanese/English sentence pairs about cats, because I was studying Japanese. You can use whatever tickles your fancy, as long as this text file (~/taglines.txt) has one line per saying.

(defun wicked/random-tagline (&optional file)
  "Return a random tagline."
  (with-current-buffer (find-file-noselect (or file "~/taglines.txt"))
    (goto-char (random (point-max)))
    (let ((string
           (buffer-substring (line-beginning-position)
                             (line-end-position))))
      string)))

(eval-after-load 'remember
  '(progn
     (defadvice remember (after wicked activate)
       "Add random tagline."
       (save-excursion
         (goto-char (point-max))
         (insert "\n\n" (wicked/random-tagline) "\n\n")))))

If you want multi-line sayings, look into the Emacs fortune cookie package, and replace wicked/random-tagline with a function that returns a random string.

This code modifies the behavior of C-c r (remember) by inserting a random tagline after the buffer has been prepared. You can use the same idea to insert a timestamp noting you started, a template figuring or modify the text in other ways.

Saving to Different Places

You can also change how Remember saves its notes. For example, if you want all of the notes that contain the word ":EMACS:" or ":WORK:" to go into separate files, you can add this code to your ~/.emacs:

(defvar wicked/remember-keywords
  '((":EMACS:" . "~/emacs.txt")
    (":WORK:" . "~/work.txt"))
  "*List of (REGEXP . FILENAME).
If an entry matches REGEXP, it will be storied in FILENAME.
The first regular expression that matches is used.")
(eval-after-load 'remember
  '(progn
     (defadvice remember-region (around wicked activate)
       "Save notes matching `wicked/remember-keywords' elsewhere."
       (let* ((b (or beg (min (point) (or (mark) (point-min)))))
	      (e (or end (max (point) (or (mark) (point-max)))))
	      (string (buffer-substring-no-properties b e))
	      (done nil)
	      (keywords wicked/remember-keywords))
	 (while keywords
	   (when (string-match (caar keywords) string)
	     (let ((remember-data-file (cdar keywords)))
	       ad-do-it)
	     (setq keywords nil done t))
	   (setq keywords (cdr keywords)))
	 (unless done
	   ad-do-it)))))

You can even configure Remember to use different handler functions. This chapter covers several note-taking systems for Emacs, and you may want to use Remember to save to more than one note-taking system. For example, you can set up C-c r p to start a Remember buffer that saves to Planner, and C-c r o to start a Remember buffer that saves to Org. Here's the code for your ~/.emacs:

(defun wicked/remember-to-org ()
  "Remember to Org."
  (let ((remember-annotation-functions   ;; (1)
	 (cons 'org-remember-annotation
	       remember-annotation-functions)))
    (remember)
    (set (make-variable-buffer-local
	  'remember-handler-functions)
	 '(org-remember-handler))))      ;; (2)

(defun wicked/remember-to-planner ()
  "Remember to Planner."
  (let ((remember-annotation-functions   ;; (3)
	 (append planner-annotation-functions
		 remember-annotation-functions)))
    (remember)
    (set (make-variable-buffer-local
	  'remember-handler-functions)
	 '(remember-planner-append))))      ;; (4)

(global-unset-key (kbd "C-c r"))  ;; (5)
(global-set-key (kbd "C-c r o") 'wicked/remember-to-org)
(global-set-key (kbd "C-c r p") 'wicked/remember-to-planner)
  • 1: We need to make sure that Org-compatible links are created.
  • 2: This makes C-c C-c save the note to the Org file.
  • 3: Planner uses a list of annotation functions, so we add all of them to the beginning of the list.
  • 4: This makes C-c C-c save the note to the Planner page.
  • 5: We need to unset keyboard shortcuts before we can set longer keyboard shortcuts that start with the same sequence.

To learn more about configuring Remember with the different note-taking systems, read on!

On Technorati: , , ,

Random Emacs symbol: compilation-find-file - Function: Find a buffer for file FILENAME.

]]>
wickedcoolemacs book emacs remember Sun, 13 Jan 2008 15:24:00 EST
Book triage http://sachachua.com/notebook/wiki/2008.01.07.php#anchor-2 http://sachachua.com/notebook/wiki/2008.01.07.php#anchor-2 Okay. 31 books. 15 days. Plus all the writing I still need to do. I may have made a bit of a miscalculation. No problem, it's the library, I can always renew or request books.

The only books I probably won't be able to renew are

  • Open an Online Business in 10 Days
  • Money Can Buy Happiness
  • The Mid-Career Success Guide
  • Make Your Contacts Count (2nd ed)
  • How to Photograph Absolutely Everything

(Yes, I wander all over...)

I can do that. =)

One of these days, I'm going to revise my OPAC reminder script to also automatically deactivate all of my requests once I go over a certain number of books... ;)

On Technorati:

Random Emacs symbol: table-narrow-cell - Command: Narrow the current cell by N columns and shrink the cell horizontally.

]]>
reading Mon, 07 Jan 2008 21:21:00 EST
January - Chapter 7: Taking Notes http://sachachua.com/notebook/wiki/2008.01.07.php#anchor-1 http://sachachua.com/notebook/wiki/2008.01.07.php#anchor-1 For January 2008, my assignment is to write a chapter on taking notes with Emacs. Here are the blog posts that I plan to write, each around 1000-2000 words long. This should give me plenty of material to edit, if I don't go mad first. ;)

 - [ ] Keeping Notes in Emacs
       Structured vs Unstructured (outline, free-form)
       Flat vs Hyperlinked
       Private vs Public
       File structure (one file, daily, snippets)
 - [ ] Outline Notes with Org, Blorg
 - [ ] Daily Notes with Planner
 - [ ] Hyperlinked Notes and Muse
 - [ ] Publishing Muse
 - [ ] Publishing Planner, RSS
 - [ ] Remember: quick note entry
 - [ ] Snippets with Howm
 - [ ] Blogging from Emacs - Wordpress, LJ, Blogger,Muse-Blosxom, EmacsAtomAPI
 - [ ] Encrypted Notes (full file, segments) - MOSTLY WRITTEN

I find that thinking of a book as a collection of articles works out well for me. Starting with a rough outline like this, I'll write 2000-word articles of the kind that I'd write for Linux Journal or LinuxWorld, and then I'd put them into my outline and add transitions. After I write all the pieces, then I can write the introduction and the wrap-up sections.

Slowly getting the hang of this writing thing... =)

On Technorati: , ,

Random Emacs symbol: message-narrow-to-headers-or-head - Function: Narrow the buffer to the head of the message.

]]>
emacs writing wickedcoolemacs Mon, 07 Jan 2008 21:11:00 EST
Teachable moments http://sachachua.com/notebook/wiki/2008.01.06.php#anchor-1 http://sachachua.com/notebook/wiki/2008.01.06.php#anchor-1 J- was getting frustrated by the game of chess she was playing with her dad. She couldn't see any good moves. Her pieces were all tangled up, and she didn't know what to do.

It's interesting watching another human being learn how to think strategically. She's not quite there yet, as she has a hard time thinking of what her dad's response would be. I remember being like that, and I remember the chess drills I did in order to learn how to see ahead.

So instead of writing the blog post that I meant to write today, I took some time to teach her. No, I didn't coach her during the game. Instead, we wiped the board clean and I set out some pieces for one of the simplest drills, King and Rook vs King. I'd shown her this before. She'd successfully completed it with some coaching. It would be good for reinforcing the idea of thinking ahead.

She was moving the pieces somewhat randomly (although legally, of course). So I started counting to 50 moves, the limit on end-game dilly-dallying in tournament play. When I was getting close to 50, she We reached a draw during the first drill. Then I showed her how she needed to decide which side of the board she would force my king to stay on, and how that rook could keep my king there, then drive it backwards once it had the support of her king.

We did another drill, with plenty of sound effects. "I'm going to get you!" I exclaimed as my solitary king pursued her rook, step by step. She squealed and moved her rook to the other side. "Uh oh," I said when my king had nowhere to go but in front of hers. "Noooo!", I cried as her rook forced mine against the board. She checkmated my king with a little prompting.

We went back and forth a few times before she caught on that she needed to sometimes "waste" a move. When she could checkmate my king with no prompting, I reinforced the idea ("Pick which side of the board you're going to squish my king against, and focus on forcing my king back") and replaced her rook with a queen. I showed her how a queen can checkmate faster than a rook. She checkmated me handily, and finished the session thrilled with what she could do.

Why am I telling this story? I think it hints at why and how I teach. A lot of what I'm doing right now can be considered teaching, even though it looks different: my social media consulting with IBM, the book that I'm writing on Emacs... But I'm not teaching facts or procedures. I care about shaping attitude and so that I can unlock potential. I talk to people about blogging and bookmarking because I want to influence their attitude towards collaboration, and because I want to see what they'll do (so that I can learn from them too!). I talk about Emacs, but what's important to me is the "if I can tweak this, what else can I do with it?" kind of feeling that will unlock the rest of Emacs for other people.

But how do you teach culture?

On Technorati:

Random Emacs symbol: bbdb-records - Function: Return a list of all bbdb records; read in and parse the db if necessary.

]]>
teaching Sun, 06 Jan 2008 21:52:00 EST
zomg, another chapter up! http://sachachua.com/notebook/wiki/2008.01.05.php#anchor-1 http://sachachua.com/notebook/wiki/2008.01.05.php#anchor-1 I've finished the first draft of Chapter 8: Taming Your Tasks. PDF ODT DOC. Whee!

The feedback I'm looking for right now is:

  • Does the chapter flow properly, or would it make better sense rearranged?
  • Does it cover all the things a basic chapter on task management should cover? (I know, the Planner thing's a bit sparse... My original 'budget' for this chapter was 35 pages!)
  • Does it include at least one or things that make you go "Hmm, that's interesting"?
  • Is it missing some of your favorite hacks or coolest features?

Fiddly bits like formatting will wait for the second pass.

If you leave your feedback as comments on this post, I'm less likely to lose it in all the mail that's piling up in my inbox! =)

On Technorati: , , , ,

Random Emacs symbol: widget-specify-secret - Function: Replace text in FIELD with value of `:secret', if non-nil.

]]>
wickedcoolemacs emacs org planner writing Sat, 05 Jan 2008 14:55:00 EST
Tagging in Org - plus bonus code for timeclocks and tags! http://sachachua.com/notebook/wiki/2008.01.04.php#anchor-1 http://sachachua.com/notebook/wiki/2008.01.04.php#anchor-1 The section on projects introduced tags as a way to differentiate active and inactive projects. In this section, you'll learn more about tags and how you can use them to filter your task list.

What's a tag, anyway? In Org, tags are keywords at the end of headlines. Each tag can contain letters, numbers, and the symbols '_' and '@'. Tags begin and end with colons, and a single colon separates multiple tags. For example, you could have headlines like this:

 * Personal                                     :PERSONAL:
 ** TODO Buy milk                               :@ERRANDS:
 ** TODO Call Mom                               :@PHONE:
 ** TODO Send letters                           :@ERRANDS:
 * Work                                         :WORK:
 ** TODO Call John about report                 :@PHONE:JOHN:
 ** TODO Prepare for presentation on Monday
 ** TODO Call Mary about the presentation       :@PHONE:URGENT:MARY:

One way to use tags is to filter your task list by priority. For example, you may want to focus on your urgent tasks first without getting distracted by other items on your task list. Another way to use tags is to keep track of the context of your tasks as suggested in GTD. By doing similar tasks together, you might be able to work more efficiently. For example, if you're on the phone at the office, it may be a good idea to do all of your work-related phone calls. If you're going to go to the post office, you might want to drop by the supermarket on your way back. You can use tags to categorize your headlines any way you want.

Tags can take advantage of the outline structure. For example, although the tasks "Buy milk", "Call Mom", and "Send letters" have one tag each, they also inherit the "PERSONAL" tag from the parent headline. A tag search for "PERSONAL" would display all three tasks. To customize this behavior, look at the documentation for the variables org-use-tag-inheritance and org-tags-match-list-sublevels.

Tags can help you organize and filter your task list. In this section, you'll learn how to add tags to your headlines, view tagged items in your Org file and in your agenda, and define custom agenda views. You'll also learn about custom tag searches and other interesting things you can do once you've tagged your headlines.

Adding tags

You can edit your ~/organizer.org file and add tags manually by typing in :tagname: at the end of the headline. You can also add tags by typing C-c C-c (org-ctrl-c-ctrl-c) when the point is on a headline. Use M-TAB (complete-symbol) to complete a tag based on all the tags used in the current file. If Alt-TAB is not processed by Emacs, you can use ESC-TAB instead.

Separate multiple tags with a single colon, like this: (:@PHONE:URGENT:). The beginning and ending colons are optional when using C-c C-c (org-ctrl-c-ctrl-c), because the function will automatically add them.

If you add certain tags frequently, you can set up single-key shortcuts. For example, if you frequently tag tasks as "URGENT", you may want to define a shortcut (at least until your life gets under control). You can assign shortcuts globally by adding this code to your ~/.emacs and evaluating it:

   (setq org-tag-alist '(("URGENT" . ?u)
                         ("@PHONE" . ?p)
                         ("@ERRANDS" . ?e)))

You can also set this on a per-file basis by adding the following line to the beginning of your file:

 #+TAGS: URGENT(u) @PHONE(p) @ERRANDS(e)

You can then use these C-c C-c (org-ctrl-c-ctrl-c) to enter these single-key shortcuts, ending it with RET. If you are assigning a single tag, type C-c C-c C-c (org-ctrl-c-ctrl-c, next change exits) to make it even faster by skipping the RET.

If you use single-key shortcuts, you'll need another way to enter tags that start with the shortcut key. You can type them in manually, or you can use C-c C-c (org-ctrl-c-ctrl-c) and type TAB to enter in any tag.

To remove a tag, you could use C-c C-c (org-ctrl-c-ctrl-c) again, or delete it manually. To remove all tags, use C-c C-c (org-ctrl-c-ctrl-c) and press SPC.

Viewing tagged items

Whether you want to view tagged headlines by themselves or in the context of your other headlines, tasks, and notes, Org has some nifty tagging features for you.

Agenda view

To view tagged headlines by themselves, use C-c a m (org-agenda, org-tags-view) and specify the search tag. For example, you can view your urgent tasks by specifying "URGENT". Note that this command displays the top headlines matching that tag, whether they're tasks or not. For example, if you searched for "WORK", you would just get the "* Work" headline. To view tagged tasks, use C-c a M (org-agenda, org-tags-view with a prefix argument). This shows only the tasks that have that tag.

To search for a combination of tags, you can combine tags like this:

WORK&@PHONE           only your work phone calls
PERSONAL-@ERRANDS     personal tasks, but without errands
JOHN|MARY             Anything tagged with "JOHN" or "MARY"
                      For example, if you're going to have a meeting with both of them

If you check certain lists often, you might want to create a custom agenda command for them. In the section on Projects, you configured custom agenda commands for active and inactive projects by adding the following code in your ~/.emacs:

(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)
        ("m" tags "PROJECT&MAYBE" nil)
        ("a" "My agenda"
         ((org-agenda-list)
          (tags "PROJECT-MAYBE-DONE")))
        ;; ... put your other custom commands here
       ))

You can use the same idea to create quick custom views for your other tagged tasks. For example, to create custom views for your urgent work tasks and your phone calls, modify the org-agenda-custom-commands setting in your ~/.emacs to be like this:

(setq org-agenda-custom-commands
      '(("u" todo "WORK&URGENT" nil)               ;; (1)
        ("c" todo "WORK&@PHONE" nil)               ;; (2)
        ("h" todo "PERSONAL-@ERRANDS" nil)         ;; (3)
        ("p" tags "PROJECT-MAYBE-DONE" nil)        ;; (4)
        ("m" tags "PROJECT&MAYBE" nil)
        ("a" "My agenda"
         ((org-agenda-list)
          (tags-todo "URGENT")                     ;; (5)
          (tags "PROJECT-MAYBE-DONE")))            ;; (6)
        ;; ... put your other custom commands here
       ))
  • (1) "u" is for "urgent", "todo" specifies that TODO headlines are to be shown, "WORK&URGENT" is the query string, and the last item means that there aren't any options
  • (2) "c" is for "call"
  • (3) "h" is for "home"
  • (4) The second item here is "tags" instead of "todo", which means that the highest-level matching headlines should be shown whether or not they're tasks.
  • (5) This is how to add a tag search for tasks into a custom agenda command.
  • (6) This is how to add a tag search for headlines into a custom agenda command.

Sometimes you'll want to see more context instead of just a list of headlines. You can jump from your Org agenda to the corresponding headline by pressing RET (org-agenda-switch-to) on the entry. You can also quickly browse through the headlines in another window by pressing f (org-agenda-follow-mode) while in the Org agenda view, then moving your point to the different lines. These commands work with the summary in the Org agenda view.

If you want to show only matching headlines in your ~/organizer.org file, you can use Org's sparse tree search commands.

In your agenda file

A sparse tree shows only the matching headlines in the context of the headlines above them. This is useful when you want to see your tasks within your outline structure. All other headlines are collapsed so that they're easy to skip. To do a sparse tree search, type C-c \ (org-tags-sparse-tree). You can then expand and collapse subtrees with the TAB (org-cycle) command. To limit the search to only task headlines, type C-u C-c \ (org-tags-sparse-tree with a prefix).

Other cool things you can do with tags

And if you ever want to know how much time you spent on urgent tasks, you can call the following function from your organizer.org file with:

M-x wicked/org-calculate-tag-time RET URGENT RET

to see something like this:

Time: 98:44 (98 hours and 44 minutes)

You can call it with a prefix in order to be prompted for a start time (inclusive) and end time (exclusive).

Here's the code to add to your ~/.emacs:

(defun wicked/org-calculate-tag-time (matcher &optional ts te)
  "Return the total minutes clocked in headlines matching MATCHER.
MATCHER is a string or a Lisp form to be evaluated, testing if a
given set of tags qualifies a headline for inclusion. TS and TE
are time start (inclusive) and time end (exclusive). Call with a
prefix to be prompted for TS and TE.

For example, to see how much time you spent on tasks tagged as
URGENT, call M-x wicked/org-calculate-tag-time RET URGENT RET. To
see how much time you spent on tasks tagged as URGENT today, call
C-u M-x wicked/org-calculate-tag-time RET URGENT RET . RET +1 RET."
  (interactive (list
		(read-string "Tag query: ")
		(if current-prefix-arg (org-read-date))
		(if current-prefix-arg (org-read-date))))
  ;; Convert strings to proper arguments
  (if (stringp matcher) (setq matcher (cdr (org-make-tags-matcher matcher))))
  (if (stringp ts)
      (setq ts (time-to-seconds (apply 'encode-time (org-parse-time-string ts)))))
  (if (stringp te)
      (setq te (time-to-seconds (apply 'encode-time (org-parse-time-string te)))))
  (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
		     (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
		     (org-re
		      "\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:]_@:]+:\\)?[ \t]*$")))
	 (case-fold-search nil)
         lspos
	 tags tags-list tags-alist (llast 0) rtn level category i txt p
	 marker entry priority (total 0))
    (save-excursion
      (org-clock-sum ts te)
      (goto-char (point-min))
      (while (re-search-forward re nil t)
	(catch :skip
	  (setq tags (if (match-end 4) (match-string 4)))
	  (goto-char (setq lspos (1+ (match-beginning 0))))
	  (setq level (org-reduced-level (funcall outline-level))
		category (org-get-category))
	  (setq i llast llast level)
	  ;; remove tag lists from same and sublevels
	  (while (>= i level)
	    (when (setq entry (assoc i tags-alist))
	      (setq tags-alist (delete entry tags-alist)))
	    (setq i (1- i)))
	  ;; add the nex tags
	  (when tags
	    (setq tags (mapcar 'downcase (org-split-string tags ":"))
		  tags-alist
		  (cons (cons level tags) tags-alist)))
	  ;; compile tags for current headline
	  (setq tags-list
		(if org-use-tag-inheritance
		    (apply 'append (mapcar 'cdr tags-alist))
		  tags))
	  (when (and (eval matcher)
		     (or (not org-agenda-skip-archived-trees)
			 (not (member org-archive-tag tags-list))))
	    ;; Get the time for the headline at point
	    (goto-char (line-beginning-position))
	    (setq total (+ total (or (get-text-property (1+ (point)) :org-clock-minutes) 0)))
	    ;; if we are to skip sublevels, jump to end of subtree
	    (org-end-of-subtree t)))))
    (if (interactive-p)
	(let* ((h (/ total 60))
	       (m (- total (* 60 h))))
	  (message "Time: %d:%02d (%d hours and %d minutes)" h m h m)))
    total))

Now you can slice and dice your timeclock records any way you want, thanks to tags!

Random Emacs symbol: cc-imenu-java-generic-expression - Variable: Imenu generic expression for Java mode. See `imenu-generic-expression'.

On Technorati: , ,

]]>
wickedcoolemacs org emacs Fri, 04 Jan 2008 22:57:00 EST