<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>sacha chua :: enterprise 2.0 consultant, storyteller, geek &#187; org</title>
	<atom:link href="http://sachachua.com/wp/category/org/feed/" rel="self" type="application/rss+xml" />
	<link>http://sachachua.com/wp</link>
	<description>I help people connect through blogs, wikis, other Web 2.0 tools. I'm also writing a book about Emacs.</description>
	<pubDate>Sat, 06 Sep 2008 03:47:23 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Emacs: Smarter interactive prompts with Org remember templates</title>
		<link>http://sachachua.com/wp/2008/07/20/emacs-smarter-interactive-prompts-with-org-remember-templates/</link>
		<comments>http://sachachua.com/wp/2008/07/20/emacs-smarter-interactive-prompts-with-org-remember-templates/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 15:46:46 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[org]]></category>

		<category><![CDATA[remember]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/2008/07/20/emacs-smarter-interactive-prompts-with-org-remember-templates/</guid>
		<description><![CDATA[Paul Lussier wanted to know how to interactively prompt for a value and use that value multiple times in org-remember-templates. His example is:

(setq org-link-abbrev-alist
      '(("RT" . "https://rt/Ticket/Display.html?id=")))

(setq org-remember-templates
      '(("Tasks" ?t "* TODO %?\n  %i\n  %a"         [...]]]></description>
			<content:encoded><![CDATA[<p>Paul Lussier wanted to know how to interactively prompt for a value and use that value multiple times in org-remember-templates. His example is:</p>
<pre>
(setq org-link-abbrev-alist
      '(("RT" . "https://rt/Ticket/Display.html?id=")))

(setq org-remember-templates
      '(("Tasks" ?t "* TODO %?\n  %i\n  %a"            "~/organizer.org")
        ("Appts" ?a "* Appointment: %?\n%^T\n%i\n  %a" "~/organizer.org")
        ("RT"    ?R "* [[RT:%^{Number}][%^{Number}/%^{Description}]]" "~/org/rt.org")))
</pre>
<p>The version of Org on my system prompts for Number twice. We want to store the value in an associative list somewhere so that if Org encounters another prompt with the same text, it&#039;ll use the stored value. Here&#039;s a diff that&#039;ll do the trick.</p>
<pre>
diff -u /home/sachac/elisp/org/org.el /tmp/buffer-content-4571Oz1
--- /home/sachac/elisp/org/org.el	2008-07-20 11:28:54.000000000 -0400
+++ /tmp/buffer-content-4571Oz1	2008-07-20 11:42:06.000000000 -0400
@@ -12822,38 +12822,52 @@
 	    (org-set-local 'org-remember-default-headline headline))
 	;; Interactive template entries
 	(goto-char (point-min))
-	(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([guUtT]\\)?" nil t)
-	  (setq char (if (match-end 3) (match-string 3))
-		prompt (if (match-end 2) (match-string 2)))
-	  (goto-char (match-beginning 0))
-	  (replace-match "")
-	  (cond
-	   ((member char '("G" "g"))
-	    (let* ((org-last-tags-completion-table
-		    (org-global-tags-completion-table
-		     (if (equal char "G") (org-agenda-files) (and file (list file)))))
-		   (org-add-colon-after-tag-completion t)
-		   (ins (completing-read
-			 (if prompt (concat prompt ": ") "Tags: ")
-			 'org-tags-completion-function nil nil nil
-			 'org-tags-history)))
-	      (setq ins (mapconcat 'identity
-				  (org-split-string ins (org-re "[^[:alnum:]]+"))
-				  ":"))
-	      (when (string-match "\\S-" ins)
+	(let (interactive-entries lookup)
+	  (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([guUtT]\\)?" nil t)
+	    (setq char (if (match-end 3) (match-string 3))
+		  prompt (if (match-end 2) (match-string 2))
+		  lookup (assoc prompt interactive-entries))
+	    (goto-char (match-beginning 0))
+	    (replace-match "")
+	    (cond
+	     ((member char '("G" "g"))
+	      (let* ((org-last-tags-completion-table
+		      (org-global-tags-completion-table
+		       (if (equal char "G") (org-agenda-files) (and file (list file)))))
+		     (org-add-colon-after-tag-completion t)
+		     (ins (if lookup
+			      (cdr lookup)
+			    (completing-read
+			     (if prompt (concat prompt ": ") "Tags: ")
+			     'org-tags-completion-function nil nil nil
+			     'org-tags-history))))
+		(if (null lookup)
+		    (setq interactive-entries (cons (cons prompt ins) interactive-entries)))
+		(setq ins (mapconcat 'identity
+				     (org-split-string ins (org-re "[^[:alnum:]]+"))
+				     ":"))
+		(when (string-match "\\S-" ins)
 		(or (equal (char-before) ?:) (insert ":"))
 		(insert ins)
 		(or (equal (char-after) ?:) (insert ":")))))
-	   (char
-	    (setq org-time-was-given (equal (upcase char) char))
-	    (setq time (org-read-date (equal (upcase char) "U") t nil
-				      prompt))
-	    (org-insert-time-stamp time org-time-was-given
-				   (member char '("u" "U"))
-				   nil nil (list org-end-time-was-given)))
-	   (t
-	    (insert (read-string
-		     (if prompt (concat prompt ": ") "Enter string"))))))
+	     (char
+	      (setq org-time-was-given (equal (upcase char) char))
+	      (setq time (if lookup (cdr lookup) (org-read-date (equal (upcase char) "U") t nil
+								prompt)))
+	      (if (null lookup)
+		  (setq interactive-entries (cons (cons prompt time) interactive-entries))
+		(org-insert-time-stamp time org-time-was-given
+				       (member char '("u" "U"))
+				       nil nil (list org-end-time-was-given))))
+	     (t
+	      (let ((text
+		     (if lookup
+			 (cdr lookup)
+		       (read-string
+			(if prompt (concat prompt ": ") "Enter string")))))
+		(insert (or text ""))
+		(if (null lookup)
+		    (setq interactive-entries (cons (cons prompt text) interactive-entries))))))))
 	(goto-char (point-min))
 	(if (re-search-forward "%\\?" nil t)
 	    (replace-match "")
</pre>
<p>Have fun!</p>

<!-- start wp-tags-to-technorati 0.95 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/07/20/emacs-smarter-interactive-prompts-with-org-remember-templates/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Outlining Your Notes with Org</title>
		<link>http://sachachua.com/wp/2008/01/18/outlining-your-notes-with-org/</link>
		<comments>http://sachachua.com/wp/2008/01/18/outlining-your-notes-with-org/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 01:44:35 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[notetaking]]></category>

		<category><![CDATA[org]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/2008/01/18/outlining-your-notes-with-org/</guid>
		<description><![CDATA[Large documents are almost impossible to write without outlines.&#160; There&#039;s just too much to fit in your head. Outlines help you work with a structure, so that you can see the big picture and how sections fit together. Outlines are also surprisingly useful when brainstorming. You can work with varying levels of detail, starting with [...]]]></description>
			<content:encoded><![CDATA[<p>Large documents are almost impossible to write without outlines.&#160; There&#039;s just too much to fit in your head. Outlines help you work with a structure, so that you can see the big picture and how sections fit together. Outlines are also surprisingly useful when brainstorming. You can work with varying levels of detail, starting with a high-level overview and successively refining it, or starting with the details and then letting the structure emerge as you organize those details into groups. </p>
<p>Emacs has one of the most powerful outline editors I&#039;ve come across. Although word processors like Microsoft Word and OpenOffice.org Writer support outlines too, Emacs has a gazillion keyboard shortcuts, and once you get the hang of them, you&#039;ll want them in other applications as well. In addition, working in Emacs tends to force you to focus on the content instead of spending time fiddling with the formatting. Whether you&#039;re writing personal notes or working on a document that&#039;s due tomorrow, this is a good thing. </p>
<p>In this section, you&#039;ll learn how to outline a document using Org. You&#039;ll be able to create headings, sub-headings, and text notes. You&#039;ll also learn how to manage outline items by promoting, demoting, and rearranging them. </p>
<h3>Understanding Org </h3>
<p>Org is primarily a personal information manager that keeps track of your tasks and schedule, and you&#039;ll learn more about those features in chapters 8 and 9. However, Org also has powerful outline-management tools, which is why I recommend it to people who want to write and organize outlined notes. </p>
<p>The structure of an Org file is simple: a plain text file with headlines, text, and some additional information such as tags and timestamps. A headline is any line that stars with a series of asterisks. The more asterisks there are, the deeper the headline is. A second-level headline is the child of the first-level headline before it, and so on. For example: </p>
<pre>* This is a first-level headline
Some text under that headline
** This is a second-level headline
Some more text here
*** This is a third-level headline
*** This is another third-level headline
** This is a second-level headline</pre>
<p>Because Org uses plain text, it&#039;s easy to back up or process using scripts. Org&#039;s sophistication comes from keyboard shortcuts that allow you to quickly manipulate headlines, hide and show outline subtrees, and search for information. </p>
<p>GNU Emacs 22 includes Org. To automatically enable Org mode for all files with the .org extension, add the following to your ~/.emacs: </p>
<pre>(require 'org)
(add-to-list 'auto-mode-alist '(&quot;\\.org$&quot; . org-mode))</pre>
<p>To change to org-mode manually, use M-x org-mode while viewing a file. To enable Org on a per-file basis, add </p>
<pre>*- mode: org -*- </pre>
<p>to the first line of the files that you would like to associate with Org. </p>
<h3>Working with Outlines</h3>
<p>You can keep your notes in more than one Org file, but let&#039;s start by creating ~/notes.org. Open ~/notes.org, which will automatically be associated with Org Mode. Type in the general structure of your document. You can type in something like this: </p>
<pre> * Introduction
 * ...</pre>
<p>You can also use M-RET (org-meta-return) to create a new headline at the same level as the one above it, or a first-level headline if the document doesn&#039;t have headlines yet. </p>
<p>Create different sections for your work. For example, a thesis might be divided into introduction, review of related literature, description of study, methodology, results and analysis, and conclusions and recommendations. You can type in the starting asterisks yourself, or you can use M-RET (org-meta-return) to create headings one after the other. </p>
<p>Now that you have the basic structure, start refining it. Go to the first section and use a command like C-o (open-line) to create blank space. Add another headline, but this time, make it a second-level headline under the first. You can do that by either typing in two asterisks or by using M-RET (org-meta-return, which calls org-insert-heading) and then M-right (org-metaright, which calls org-do-demote). Then use M-RET (org-meta-return; org-insert-heading) for the other items, or type them in yourself. Repeat this for other sections, and go into as much detail as you want. </p>
<p>What if you want to reorganize your outline? For example, what if you realized you&#039;d accidentally put your conclusions before the introduction? You could either cut and paste it using Emacs shortcuts, or you can use Org&#039;s outline management functions. The following keyboard shortcuts are handy: </p>
<table cellspacing="0" cellpadding="6" rules="groups" border="2" frame="hsides">
<colgroup><col align="left" /><col align="left" /><col align="left" /><col align="left" /></colgroup>
<tbody>
<tr>
<td>Action</td>
<td>Command</td>
<td>Shortcut</td>
<td>Alternative</td>
</tr>
<tr>
<td>Move a subtree up</td>
<td>org-metaup / org-move-subtree-up</td>
<td>M-up</td>
<td>C-c C-x u</td>
</tr>
<tr>
<td>Move a subtree down</td>
<td>org-metadown / org-move-subtree-down</td>
<td>M-down</td>
<td>C-c C-x d</td>
</tr>
<tr>
<td>Demote a subtree</td>
<td>org-shiftmetaright / org-demote-subtree</td>
<td>S-M-right</td>
<td>C-c C-x r</td>
</tr>
<tr>
<td>Promote a subtree</td>
<td>org-shiftmetaleft / org-promote-subtree</td>
<td>S-M-left</td>
<td>C-c C-x l</td>
</tr>
<tr>
<td>Demote a headline</td>
<td>org-metaright / org-do-demote</td>
<td>M-right</td>
<td>C-c C-x &lt;right&gt;</td>
</tr>
<tr>
<td>Promote a headline</td>
<td>org-metaleft / org-do-promote</td>
<td>M-left</td>
<td>C-c C-x &lt;left&gt;</td>
</tr>
<tr>
<td>Collapse or expand a subtree</td>
<td>org-cycle (while on headline)</td>
<td>TAB</td>
<td>&#160;</td>
</tr>
<tr>
<td>Collapse or expand everything</td>
<td>org-shifttab (org-cycle)</td>
<td>S-TAB</td>
<td>C-u TAB</td>
</tr>
</tbody>
</table>
<p>Use these commands to help you reorganize your outline as you create a skeleton for your document. These commands make it easy to change your mind about the content or order of sections. You might find it easier to sketch a rough outline first, then gradually fill in more and more detail. On the other hand, you might find it easier to pick one section and keep drilling it down until you have headlines some seven levels deep. When you reach that point, all you need to do is add punctuation and words like &quot;and&quot; or &quot;but&quot; between every other outline item, and you&#039;re done! </p>
<p>Well, no, not likely. You&#039;ll probably get stuck somewhere, so here are some tips for keeping yourself going when you&#039;re working on a large document in Org: brainstorming and getting a sense of your progress. </p>
<h3>Brainstorming </h3>
<p>Brainstorming is a great way to break your writer&#039;s block or to generate lots of possibilities. The key idea is to come up with as many ideas as you can, and write them all down before you start evaluating them. </p>
<p>I usually switch to paper for mindmapping and brainstorming because paper helps me think in a more colorful and non-linear way. However, it can be hard to manage large mindmaps on paper, because you can&#039;t reorganize nodes easily. Despite its text-heavy interface, Org is one of the best mindmapping tools I&#039;ve come across. Because it&#039;s built into Emacs, everything can be done through keyboard shortcuts. </p>
<p>When you&#039;re brainstorming, you might like working from two different directions. Sometimes it&#039;s easier to start with an outline and to add more and more detail. Other times, you may want to jot quick ideas and then organize them into groups that make sense. Org provides support for both ways of working. </p>
<p>Brainstorming bottom-up is similar to David Allen&#039;s Getting Things Done method in that separating collection from organization is a good idea. That is, get the ideas out of your head first before you spend time trying to figure out the best way to organize them. To get things out of your head quickly, collect your ideas by using the M-RET (org-meta-return) to create a new heading, typing in your idea, and using M-RET (org-meta-return) to create the next heading. Do this as many times as needed. </p>
<p>One way to encourage yourself to brainstorm lots of ideas is to give yourself a quota. Charles Cave described this technique in an <a href="http://members.optusnet.com.au/~charles57/GTD/Natural_Project_Planning.html">article on org-mode</a>, and it&#039;s a great way to use structure to prompt creativity. Simply start by adding a number of empty headings (say, 20), then work towards filling that quota. For example, you might start with ten blanks for ideas, then gradually fill them in like this: </p>
<pre>* Things that make me happy
** Curling up with a good book
** Watching a brilliant sunset
** Giving or getting a big warm hug
** Writing a cool piece of Emacs code
**
**
**
**
**
**</pre>
<p>When all of your ideas are in Org, start organizing them. This is where you move ideas around using M-S-up (org-shiftmetaup) and M-S-down (org-shift-metadown), which call org-move-subtree-up and org-move-subtree-down. This is also a good time to use headings to group things together. </p>
<h3>Getting a Sense of Progress </h3>
<p>You&#039;ve brainstormed. You&#039;ve started writing your notes. And if you&#039;re working on a large document, you might lose steam at some point along the way. For example, while working on this book, I often find myself intimidated by just how much there is to write about Emacs. It helps to have a sense of progress such as the number of words written or the number of sections completed. To see a word count that updates every second, add this code to your ~/.emacs: </p>
<pre>(defvar count-words-buffer
  nil
  &quot;*Number of words in the buffer.&quot;)

(defun wicked/update-wc ()
  (interactive)
  (setq count-words-buffer (number-to-string (count-words-buffer)))
  (force-mode-line-update))

; only setup timer once
(unless count-words-buffer
  ;; seed count-words-paragraph
  ;; create timer to keep count-words-paragraph updated
  (run-with-idle-timer 1 t 'wicked/update-wc))

;; add count words paragraph the mode line
(unless (memq 'count-words-buffer global-mode-string)
  (add-to-list 'global-mode-string &quot;words: &quot; t)
  (add-to-list 'global-mode-string 'count-words-buffer t)) 

;; count number of words in current paragraph
(defun count-words-buffer ()
  &quot;Count the number of words in the current paragraph.&quot;
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (let ((count 0))
      (while (not (eobp))
	(forward-word 1)
        (setq count (1+ count)))
      count)))</pre>
<p>The best way I&#039;ve found to track my progress in terms of sections is to use a checklist. For example, the collapsed view for this section looks like this: </p>
<pre>** Outline Notes with Org [7/9]    ;; (1)
*** [X] Outlining Your Notes...    ;; (2)
*** [X] Understanding Org...
*** [X] Working with Outlines...
*** [X] Brainstorming...
*** [ ] Getting a Sense of Progress... ;; (3)
*** [X] Searching Your Notes...
*** [X] Hyperlinks...
*** [X] Publishing Your Notes...
*** [ ] Integrating Remember with Org</pre>
</p>
<ul>
<li>(1): [7/9] shows that I&#039;ve completed 7 of 9 parts. </li>
<li>(2): [X] indicates finished parts. </li>
<li>(3): [ ] indicates parts I still need to do. </li>
</ul>
<p>This is based on the checklist feature in Org. However, the standard feature works only with lists like this: </p>
<pre>*** Items [1/3]
- [X] Item 1
- [ ] Item 2
- [ ] Item 3</pre>
<p>Add the following code to your ~/.emacs in order to make the function work with headlines: </p>
<pre>(defun wicked/org-update-checkbox-count (&amp;optional all)
  &quot;Update the checkbox statistics in the current section.
This will find all statistic cookies like [57%] and [6/12] and update
them with the current numbers.  With optional prefix argument ALL,
do this for the whole buffer.&quot;
  (interactive &quot;P&quot;)
  (save-excursion
    (let* ((buffer-invisibility-spec (org-inhibit-invisibility))
	   (beg (condition-case nil
		    (progn (outline-back-to-heading) (point))
		  (error (point-min))))
	   (end (move-marker
		 (make-marker)
		 (progn (or (outline-get-next-sibling) ;; (1)
			    (goto-char (point-max)))
			(point))))
	   (re &quot;\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)&quot;)
	   (re-box
	    &quot;^[ \t]*\\(*+\\|[-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)&quot;)
	   b1 e1 f1 c-on c-off lim (cstat 0))
      (when all
	(goto-char (point-min))
	(or (outline-get-next-sibling) (goto-char (point-max))) ;; (2)
	(setq beg (point) end (point-max)))
      (goto-char beg)
      (while (re-search-forward re end t)
	(setq cstat (1+ cstat)
	      b1 (match-beginning 0)
	      e1 (match-end 0)
	      f1 (match-beginning 1)
	      lim (cond
		   ((org-on-heading-p)
		    (or (outline-get-next-sibling) ;; (3)
			(goto-char (point-max)))
		    (point))
		   ((org-at-item-p) (org-end-of-item) (point))
		   (t nil))
	      c-on 0 c-off 0)
	(goto-char e1)
	(when lim
	  (while (re-search-forward re-box lim t)
	    (if (member (match-string 2) '(&quot;[ ]&quot; &quot;[-]&quot;))
		(setq c-off (1+ c-off))
	      (setq c-on (1+ c-on))))
	  (goto-char b1)
	  (insert (if f1
		      (format &quot;[%d%%]&quot; (/ (* 100 c-on)
					  (max 1 (+ c-on c-off))))
		    (format &quot;[%d/%d]&quot; c-on (+ c-on c-off))))
	  (and (looking-at &quot;\\[.*?\\]&quot;)
	       (replace-match &quot;&quot;))))
      (when (interactive-p)
	(message &quot;Checkbox statistics updated %s (%d places)&quot;
		 (if all &quot;in entire file&quot; &quot;in current outline entry&quot;)
		 cstat)))))
(defadvice org-update-checkbox-count (around wicked activate)
  &quot;Fix the built-in checkbox count to understand headlines.&quot;
  (setq ad-return-value
	(wicked/org-update-checkbox-count (ad-get-arg 1))))</pre>
<p>Now add [ ] or [X] to the lower-level headlines you want to track. Add [/] to the end of the higher-level headline containing those headlines. Type C-c # (org-update-checkbox-count) to update the count for the current headline, or C-u C-c C-# (org-update-checkbox-count) to update all checkbox counts in the whole buffer. </p>
<p>If you want to see the percentage of completed items, use [%] instead of [/]. I find 7/9 to be easier to understand than 71%, but fractions might work better for other cases. </p>
<p>Okay, you&#039;ve written a lot. How do you find information again? </p>
<h3>Searching Your Notes </h3>
<p>When you&#039;re writing your notes, you might need to refer to something you&#039;ve written. You may find it helpful to split your screen in two with C-x 3 (split-window-horizontally) or C-x 2 (split-window-vertically). To switch to another window, type C-x o (other-window) or click on the window. To return to just one window, use C-x 1 (delete-other-windows) to focus on just the current window, or C-x 0 (delete-window) to get rid of the current window. </p>
<p>Now that you&#039;ve split your screen, how do you quickly search through your notes? C-s (isearch-forward) and C-r (isearch-backward) are two of the most useful Emacs keyboard shortcuts you&#039;ll ever learn. Use them to not only interactively search your Org file, but also to quickly jump to sections. For example, I often search for headlines by typing * and the first word. Org searches collapsed sections, so you don&#039;t need to open everything before searching. </p>
<p>To search using Org&#039;s outline structure, use C-c / r (org-sparse-tree, regexp), which will show only entries matching a regular expression. For more information about regular expressions, read the Emacs info manual entry on Regexps. Here are a few examples: </p>
<table cellspacing="0" cellpadding="2" width="400" border="0">
<tbody>
<tr>
<td valign="top" width="200"><strong>To find</strong></td>
<td valign="top" width="200"><strong>Search for</strong></td>
</tr>
<tr>
<td valign="top" width="200">All entries containing &quot;cat&quot;</td>
<td valign="top" width="200">cat</td>
</tr>
<tr>
<td valign="top" width="200">All entries that contain &quot;cat&quot; as a word by itself (example: &quot;cat,&quot; but not &quot;catch&quot;)</td>
<td valign="top" width="200">\&lt;cat\&gt;</td>
</tr>
<tr>
<td valign="top" width="200">All entries that contain 2006, 2007, or 2008</td>
<td valign="top" width="200">200[678]</td>
</tr>
</tbody>
</table>
<h3>Hyperlinks </h3>
<p>If you find yourself frequently searching for some sections, you might want to create hyperlinks to them. For example, if you&#039;re using one file for all of your project notes instead of splitting it up into one file per project, then you probably want a list of projects at the beginning of the file so that you can jump to each project quickly. </p>
<p>You can also use hyperlinks to keep track of your current working position. For example, if you&#039;re working on a long document and you want to keep your place, create a link anchor like &lt;&lt;TODO&gt;&gt; at the point where you&#039;re editing, and add a link like [[TODO]] at the beginning of your file. </p>
<p>You can create a hyperlink to a text search by putting the keywords between two pairs of square brackets, like this: </p>
</p>
<pre>  See [[things that make me happy]] </pre>
</p>
<p>You can open the link by moving the point to the link and typing C-c C-o (org-open-at-point). You can also click on the link to open it. Org will then search for text matching the query. If Org doesn&#039;t find an exact match, it tries to match similar text, such as &quot;Things that make me really really happy&quot;. </p>
<p>If you find that the link does not go where you want it to go, you can limit the text search. For example, if you want to link to a headline and you know the headline will be unique, you can add an asterisk at the beginning of the link text in order to limit the search to headlines. For example, given the following text: </p>
</p>
<pre>In this file, I'll write notes on the things that make me happy. (1)
If I ever need a spot of cheering up, I'll know just what to do! 

** Things that make me happy (2)
*** ...

Example
Link 1: [[things that make me happy]] 

Link 2: [[*things that make me happy]] </pre>
</p>
<p>Link 1 would lead to (1), and Link 2 would lead to (2). </p>
<p>To define a link anchor, put the text in double angled brackets like this: </p>
</p>
<pre>&lt;&lt;things that make me happy&gt;&gt; </pre>
</p>
<p>A link like [[things that make me happy]] would then link to that instead of other occurances of the text. </p>
<p>You can define keywords that will be automatically hyperlinked throughout the file by using radio targets. For example, if you&#039;re writing a jargon-filled document and you frequently need to refer to the definitions, it may help to make a glossary of terms such as &quot;regexp&quot; and &quot;radio target&quot;, and then define them in a glossary section at the end of the file, like this: </p>
</p>
<pre>*** glossary
&lt;&lt;&lt;radio target&gt;&gt;&gt; A word or phrase that is automatically hyperlinked whenever it appears.
&lt;&lt;&lt;regexp&gt;&gt;&gt; A regular expression. See the Emacs info manual. </pre>
<p>Radio targets are automatically enabled when an Org file is opened in Emacs. If you&#039;ve just added a radio target, enable it by moving the point to the anchor and pressing C-c C-c (org-ctrl-c-ctrl-c). This turns all instances of the text into hyperlinks that point to the radio target. </p>
<h3>Publishing Your Notes </h3>
<p>You can keep your notes as a plain text file, or you can publish them as HTML or LaTeX. HTML seems to be the easiest way to let non-Emacs users read your notes, as a large text file without pretty colors can be hard to read. </p>
<p>To export a file to any of the formats that Org understands by default, type C-c C-e (org-export). You can then type &#039;h&#039; (org-export-as-html) to export it as HTML for websites. You can also type &#039;l&#039; (org-export-as-latex) to export it to LaTeX, a scientific typesetting language, which can then be published as PDF or PS. Another way to convert it to PDF is to export it as HTML, open it in OpenOffice.org Writer, and use the Export to PDF feature. You can also open HTML documents in other popular word processors to convert them to other supported formats. </p>
<p>By default, Org exports all the content in the current file. To limit it only to the visible content, use C-c C-e v (org-export-visible) followed by either &#039;h&#039; for HTML or &#039;l&#039; for LaTeX. </p>
<p>If you share your notes, you may want to export an HTML version every time you save an Org file. Here is a quick and dirty way to publish all Org files to HTML every time you save them: </p>
<pre>(defun wicked/org-publish-files-maybe ()
  &quot;Publish this file.&quot;
  (org-export-as-html-batch)
  nil)
(add-hook 'org-mode-hook  ;; (1)
 (lambda ()
  (add-hook (make-local-variable 'write-file-functions) ;; (2)
            'wicked/org-publish-files-maybe)))</pre>
</p>
<ul>
<li>(1) Every time a buffer is set to Org mode&#8230; </li>
<li>(2) Add a function that publishes the file every time that file is saved. </li>
</ul>
<p>What if most of your files are private, but you want to publish only a few of them? To control this, let&#039;s add a new special keyword &quot;#+PUBLISH&quot; to the beginning of the files that you want to be automatically published. Replace the previous code in your ~/.emacs with this: </p>
<pre>(defun wicked/org-publish-files-maybe ()
  &quot;Publish this file if it contains the #+PUBLISH: keyword&quot;
  (save-excursion
   (save-restriction
    (widen)
    (goto-char (point-min))
    (when (re-search-forward
           &quot;^#?[ \t]*\\+\\(PUBLISH\\)&quot;
           nil t)
     (org-export-as-html-batch)
     nil))))

(add-hook 'org-mode-hook
 (lambda ()
  (add-hook (make-local-variable 'write-file-functions)
            'wicked/org-publish-files-maybe)))</pre>
<p>and add #+PUBLISH on a line by itself to your ~/notes.org file, like this: </p>
<pre> #+PUBLISH
 * Things that make me happy</pre>
<p>When you save any Org file that contains the keyword, the corresponding HTML page will also be created. You can then use a program like rsync or scp to copy the file to a webserver, or you can copy it to a shared directory. </p>
<h3>Integrating Remember with Org </h3>
<p>You can use Remember to collect notes that you will later integrate into your outline. Add the following code to your ~/.emacs to set it up: </p>
<pre>(global-set-key (kbd &quot;C-c r&quot;) 'remember)    ;; (1)
(add-hook 'remember-mode-hook 'org-remember-apply-template) ;; (2)
(setq org-remember-templates
      '((?n &quot;* %U %?\n\n  %i\n  %a&quot; &quot;~/notes.org&quot;)))  ;; (3)
(setq remember-annotation-functions '(org-remember-annotation)) ;; (4)
(setq remember-handler-functions '(org-remember-handler)) ;; (5)</pre>
<ul>
<li>1: Handy keyboard shortcut for (r)emember </li>
<li>2: Creates a template for (n)otes </li>
<li>3: Create a note template which saves the note to ~/notes.org, or whichever Org file you want to use </li>
<li>4: Creates org-compatible context links </li>
<li>5: Saves remembered notes to an Org file </li>
</ul>
<p>With this code, you can type C-c r n (remember, Notes template) to pop up a buffer (usually containing a link to whatever you were looking at), write your note, and type C-c C-c (remember-buffer) to save the note and close the buffer. </p>
<p>You can use this to store snippets in your notes file, or to quickly capture an idea that comes up when you&#039;re doing something else.</p>
<p>Now you know how to sketch an outline, reorganize it, fill it in, brainstorm, stay motivated, and publish your notes. I look forward to reading what you have to share!</p>

<!-- start wp-tags-to-technorati 0.95 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/01/18/outlining-your-notes-with-org/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Capturing Notes with Remember</title>
		<link>http://sachachua.com/wp/2008/01/13/capturing-notes-with-remember/</link>
		<comments>http://sachachua.com/wp/2008/01/13/capturing-notes-with-remember/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 20:24:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[book]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[org]]></category>

		<category><![CDATA[planner]]></category>

		<category><![CDATA[remember]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2008.01.13.php#anchor-1</guid>
		<description><![CDATA[<p>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.</p>

<p>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?</p>

<p>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.</p>

<p>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.</p>

<p>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&#8212;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.</p>

<p>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.</p>

<p>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.</p>

<h4>Setting Up Remember</h4>

<p class="first">Remember is a separate package, which you can download from <a href="https://gna.org/projects/remember-el">https://gna.org/projects/remember-el</a> . 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 .</p>

<p>To configure Remember to save to plain text files, add this code to your ~/.emacs and evaluate it:</p>

<pre class="example">
(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)
</pre>

<ul>
<li>1: Change this to the directory that contains remember.el</li>
<li>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.</li>
<li>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.</li>
<li>4: This shortcut makes it easy to check your remembered notes.</li>
</ul>

<p>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.</p>

<p>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:</p>

<pre class="example">
 ** Sat Jan 12 14:43:02 2008 (Your headline goes here)

 Your note body goes here

 /home/sacha/.emacs
</pre>

<p>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.</p>

<p>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.</p>


<h4>Reviewing Your Notes</h4>

<p class="first">Use C-c R (wicked/remember-review-file) to check your notes, or open ~/notes.txt yourself.</p>

<p>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.</p>

<p>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.</p>

<p>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</p>

<pre class="example">
-*- mode: org -*-
</pre>

<p>to the first line of your ~/notes.txt. Then, when you open your ~/notes.txt file, it will be in Org mode.</p>

<p>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).</p>

<p>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.</p>

<p>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!</p>


<h4>Enabling annotation functions</h4>

<p class="first">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".</p>

<p>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.</p>

<p>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:</p>

<pre class="example">
(eval-after-load 'remember
  '(progn
    (add-to-list 'remember-annotation-functions 'buffer-name t)))
</pre>

<p>This adds buffer-name to the end of the annotation list, making it a last resort.</p>

<p>What if you want line numbers included with the filename or buffer name? You could replace the previous code with this:</p>

<pre class="example">
(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)))
</pre>

<p>With that code, C-c r (remember) will automatically pick up the line number from your file or buffer.</p>

<p>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.</p>

<p>Now you've got context. What else can you do with the Remember buffer?</p>


<h4>Adding Other Text to the Remember Buffer</h4>

<p class="first">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.</p>

<p>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.</p>

<pre class="example">
(defun wicked/random-tagline (&#038;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")))))
</pre>

<p>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.</p>

<p>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.</p>


<h4>Saving to Different Places</h4>

<p class="first">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:</p>

<pre class="example">
(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)))))
</pre>

<p>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:</p>

<pre class="example">
(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)
</pre>

<ul>
<li>1: We need to make sure that Org-compatible links are created.</li>
<li>2: This makes C-c C-c save the note to the Org file.</li>
<li>3: Planner uses a list of annotation functions, so we add all of them to the beginning of the list.</li>
<li>4: This makes C-c C-c save the note to the Planner page.</li>
<li>5: We need to unset keyboard shortcuts before we can set longer keyboard shortcuts that start with the same sequence.</li>
</ul>

<p>To learn more about configuring Remember with the different note-taking systems, read on!</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/wickedcoolemacs" rel="tag">wickedcoolemacs</a>, <a href="http://www.technorati.com/tag/book" rel="tag">book</a>, <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/remember" rel="tag">remember</a></p>

<p>Random Emacs symbol: compilation-find-file - Function: Find a buffer for file FILENAME.</p>


]]></description>
			<content:encoded><![CDATA[<p>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.</p>

<p>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?</p>

<p>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.</p>

<p>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. 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.</p>

<p>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.</p>

<p>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.</p>

<p>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.</p>

<h4>Setting Up Remember</h4>
<p class="first">Remember is a separate package, which you can download from <a href="https://gna.org/projects/remember-el">https://gna.org/projects/remember-el</a> . 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 .</p>

<p>To configure Remember to save to plain text files, add this code to your ~/.emacs and evaluate it:
<pre class="example">
(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)</pre>
<pre class="example">;; Not (global-set-key (kbd "C-c r")... as originally written... Thanks for catching that, Seth!</pre></p>
<ul>
	<li>1: Change this to the directory that contains remember.el</li>
	<li>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.</li>
	<li>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.</li>
	<li>4: This shortcut makes it easy to check your remembered notes.</li>
</ul>
<p>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.</p>

<p>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:
<pre class="example">
 ** Sat Jan 12 14:43:02 2008 (Your headline goes here)

 Your note body goes here

 /home/sacha/.emacs</pre>
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.</p>

<p>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.</p>
<h4>Reviewing Your Notes</h4>
<p class="first">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.</p>

<p>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.</p>

<p>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
<pre class="example">
-*- mode: org -*-</pre>
to the first line of your ~/notes.txt. Then, when you open your ~/notes.txt file, it will be in Org mode.</p>

<p>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).</p>

<p>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.</p>

<p>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!</p>
<h4>Enabling annotation functions</h4>
<p class="first">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".</p>

<p>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.</p>

<p>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:
<pre class="example">
(eval-after-load 'remember
  '(progn
    (add-to-list 'remember-annotation-functions 'buffer-name t)))</pre>
This adds buffer-name to the end of the annotation list, making it a last resort.</p>

<p>What if you want line numbers included with the filename or buffer name? You could replace the previous code with this:
<pre class="example">
(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)))</pre>
With that code, C-c r (remember) will automatically pick up the line number from your file or buffer.</p>

<p>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.</p>

<p>Now you've got context. What else can you do with the Remember buffer?</p>
<h4>Adding Other Text to the Remember Buffer</h4>
<p class="first">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.</p>

<p>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.
<pre class="example">
(defun wicked/random-tagline (&amp;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")))))</pre>
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.</p>

<p>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 the time you started, use a template, or modify the text in other ways.</p>

<h4>Saving to Different Places</h4>
<p class="first">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:</p>

<pre class="example">
(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)))))</pre>
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:
<pre class="example">
(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)</pre>
<ul>
	<li>1: We need to make sure that Org-compatible links are created.</li>
	<li>2: This makes C-c C-c save the note to the Org file.</li>
	<li>3: Planner uses a list of annotation functions, so we add all of them to the beginning of the list.</li>
	<li>4: This makes C-c C-c save the note to the Planner page.</li>
	<li>5: We need to unset keyboard shortcuts before we can set longer keyboard shortcuts that start with the same sequence.</li>
</ul>
To learn more about configuring Remember with the different note-taking systems, read the sections for those systems.

<p>On Technorati: <a href="http://www.technorati.com/tag/wickedcoolemacs" rel="tag">wickedcoolemacs</a>, <a href="http://www.technorati.com/tag/book" rel="tag">book</a>, <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/remember" rel="tag">remember</a></p>

<p>Random Emacs symbol: compilation-find-file - Function: Find a buffer for file FILENAME.</p>]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/01/13/capturing-notes-with-remember/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Writing plans for the chapter on managing notes</title>
		<link>http://sachachua.com/wp/2008/01/09/writing-plans-for-the-chapter-on-managing-notes/</link>
		<comments>http://sachachua.com/wp/2008/01/09/writing-plans-for-the-chapter-on-managing-notes/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 02:05:19 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[org]]></category>

		<category><![CDATA[planner]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<category><![CDATA[writing]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/2008/01/09/writing-plans-for-the-chapter-on-managing-notes/</guid>
		<description><![CDATA[- [ ] Keeping Notes in Emacs
Structured vs Unstructured (outline, free-form)
Flat vs Hyperlinked
Private vs Public
File structure (one file, daily, snippets)
In this section, you&#039;ll learn about the different kinds of notes you take, and you will be able to choose one or two Emacs modules to start learning.
- [ ] Capture and retrieve - Remember, search
Getting [...]]]></description>
			<content:encoded><![CDATA[<p>- [ ] Keeping Notes in Emacs<br />
Structured vs Unstructured (outline, free-form)<br />
Flat vs Hyperlinked<br />
Private vs Public<br />
File structure (one file, daily, snippets)</p>
<p>In this section, you&#039;ll learn about the different kinds of notes you take, and you will be able to choose one or two Emacs modules to start learning.</p>
<p>- [ ] Capture and retrieve - Remember, search</p>
<p>Getting the ideas out of your head and into your note-taking system; searching your notes (basic), searching your notes (specific)</p>
<p>Wicked cool code: Remembering to different note-taking systems, searching different note-taking systems</p>
<p>- [ ] Outline Notes with Org, Blorg</p>
<p>In this section, you&#039;ll learn how to keep outlined notes using Org.Â  You&#039;ll be able to create headings, sub-headings, and text notes. You&#039;ll also learn how to manage outline items by promoting, demoting, and rearranging them. These basic editing commands are covered in the Emacs Org manual, so I&#039;ll just give a brief summary..</p>
<p>You&#039;ll also get tips on how to capture text quickly (M-x remember, dabbrev), work with large outline files (split windows are useful), and search your notes efficiently (searching headings or text).</p>
<p>Lastly, you&#039;ll learn how to publish your Org file as HTML or LaTeX.</p>
<p>Wicked cool code would be: searching, how to import to and export from Freemind, a graphical mind-mapping program.</p>
<p>- [ ] Daily Notes with Planner</p>
<p>In this section, you&#039;ll learn how to write a day-based journal using Planner. In addition to free-form notes on the page, you&#039;ll also be able to keep semi-structured notes typed in manually or captured using Remember. You&#039;ll also learn how to publish the resulting pages as HTML and RSS, and how to customize the output.</p>
<p>Wicked cool code would be: searching notes and displaying matching headlines, private notes, publishing note headlines, and publishing a note index.</p>
<p>- [ ] Hyperlinked Notes with Muse</p>
<p>In this section, you&#039;ll learn how to create a personal wiki using Muse.Â  You&#039;ll learn how to create pages, link to pages, and publish your wiki.</p>
<p>Wicked cool code: Capturing notes to specific pages using Remember and keyword matches, private pages, publishing pages when you save them.</p>
<p>- [ ] Snippets with Howm</p>
<p>In this section, you&#039;ll learn how to manage random snippets of information using Howm.</p>
<p>- [ ] Blogging from Emacs - Wordpress, LJ, Blogger,Muse-Blosxom, EmacsAtomAPI</p>
<p>In this section, you&#039;ll learn how to use Emacs as a blogging client for many popular platforms. This is mainly for keeping other blogs in sync, although I&#039;ll also talk about the possibility of using planner-rss + something like Feedwordpress.</p>
<p>- [ ] Encrypted Notes (full file, segments) - MOSTLY WRITTEN</p>
<p>In this section, you&#039;ll learn how to encrypt your notes. Actually, this will probably be split up into the different tools&#8230;</p>

<!-- start wp-tags-to-technorati 0.95 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/01/09/writing-plans-for-the-chapter-on-managing-notes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tagging in Org - plus bonus code for timeclocks and tags!</title>
		<link>http://sachachua.com/wp/2008/01/04/tagging-in-org-plus-bonus-code-for-timeclocks-and-tags/</link>
		<comments>http://sachachua.com/wp/2008/01/04/tagging-in-org-plus-bonus-code-for-timeclocks-and-tags/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 03:57:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[org]]></category>

		<category><![CDATA[wickedcool]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2008.01.04.php#anchor-1</guid>
		<description><![CDATA[<p>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.</p>

<p>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:</p>

<pre class="example">
 * 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:
</pre>

<p>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.</p>

<p>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.</p>

<p>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.</p>

<h4>Adding tags</h4>

<p class="first">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.</p>

<p>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.</p>

<p>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:</p>

<pre class="example">
   (setq org-tag-alist '(("URGENT" . ?u)
                         ("@PHONE" . ?p)
                         ("@ERRANDS" . ?e)))
</pre>

<p>You can also set this on a per-file basis by adding the following line
to the beginning of your file:</p>

<pre class="example">
 #+TAGS: URGENT(u) @PHONE(p) @ERRANDS(e)
</pre>

<p>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.</p>

<p>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.</p>

<p>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.</p>


<h4>Viewing tagged items</h4>

<p class="first">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.</p>

<h5>Agenda view</h5>

<p>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.</p>

<p>To search for a combination of tags, you can combine tags like this:</p>

<pre class="example">
WORK&#038;@PHONE           only your work phone calls
PERSONAL-@ERRANDS     personal tasks, but without errands
JOHN&#124;MARY             Anything tagged with "JOHN" or "MARY"
                      For example, if you're going to have a meeting with both of them
</pre>

<p>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:</p>

<pre class="example">
(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)
        ("m" tags "PROJECT&#038;MAYBE" nil)
        ("a" "My agenda"
         ((org-agenda-list)
          (tags "PROJECT-MAYBE-DONE")))
        ;; ... put your other custom commands here
       ))
</pre>

<p>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:</p>

<pre class="example">
(setq org-agenda-custom-commands
      '(("u" todo "WORK&#038;URGENT" nil)               ;; (1)
        ("c" todo "WORK&#038;@PHONE" nil)               ;; (2)
        ("h" todo "PERSONAL-@ERRANDS" nil)         ;; (3)
        ("p" tags "PROJECT-MAYBE-DONE" nil)        ;; (4)
        ("m" tags "PROJECT&#038;MAYBE" nil)
        ("a" "My agenda"
         ((org-agenda-list)
          (tags-todo "URGENT")                     ;; (5)
          (tags "PROJECT-MAYBE-DONE")))            ;; (6)
        ;; ... put your other custom commands here
       ))
</pre>

<ul>
<li>(1) "u" is for "urgent", "todo" specifies that TODO headlines are to be shown, "WORK&#038;URGENT" is the query string, and the last item means that there aren't any options</li>
<li>(2) "c" is for "call"</li>
<li>(3) "h" is for "home"</li>
<li>(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.</li>
<li>(5) This is how to add a tag search for tasks into a custom agenda command.</li>
<li>(6) This is how to add a tag search for headlines into a custom agenda command.</li>
</ul>

<p>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.</p>

<p>If you want to show only matching headlines in your ~/organizer.org
file, you can use Org's sparse tree search commands.</p>


<h5>In your agenda file</h5>

<p>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).</p>



<h4>Other cool things you can do with tags</h4>

<p class="first">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:</p>

<pre class="example">
M-x wicked/org-calculate-tag-time RET URGENT RET
</pre>

<p>to see something like this:</p>

<pre class="example">
Time: 98:44 (98 hours and 44 minutes)
</pre>

<p>You can call it with a prefix in order to be prompted for a start time
(inclusive) and end time (exclusive).</p>

<p>Here's the code to add to your ~/.emacs:</p>

<pre class="example">
(defun wicked/org-calculate-tag-time (matcher &#038;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 " *\\(\\&#60;\\("
		     (mapconcat 'regexp-quote org-todo-keywords-1 "\\&#124;")
		     (org-re
		      "\\&#62;\\)\\)? *\\(.*?\\)\\(:[[: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 (&#62;= 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))
</pre>

<p>Now you can slice and dice your timeclock records any way you want, thanks to tags!</p>

<p>Random Emacs symbol: cc-imenu-java-generic-expression - Variable: Imenu generic expression for Java mode.  See `imenu-generic-expression'.</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/wickedcoolemacs" rel="tag">wickedcoolemacs</a>, <a href="http://www.technorati.com/tag/org" rel="tag">org</a>, <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a></p>


]]></description>
			<content:encoded><![CDATA[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:
<pre class="example">
 * 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:</pre>
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.
<h4>Adding tags</h4>
<p class="first">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:
<pre class="example">
   (setq org-tag-alist '(("URGENT" . ?u)
                         ("@PHONE" . ?p)
                         ("@ERRANDS" . ?e)))</pre>
You can also set this on a per-file basis by adding the following line
to the beginning of your file:
<pre class="example">
 #+TAGS: URGENT(u) @PHONE(p) @ERRANDS(e)</pre>
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.
<h4>Viewing tagged items</h4>
</p><p class="first">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.
<h5>Agenda view</h5>
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:
<pre class="example">
WORK&amp;@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</pre>
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:
<pre class="example">
(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)
        ("m" tags "PROJECT&amp;MAYBE" nil)
        ("a" "My agenda"
         ((org-agenda-list)
          (tags "PROJECT-MAYBE-DONE")))
        ;; ... put your other custom commands here
       ))</pre>
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:
<pre class="example">
(setq org-agenda-custom-commands
      '(("u" todo "WORK&amp;URGENT" nil)               ;; (1)
        ("c" todo "WORK&amp;@PHONE" nil)               ;; (2)
        ("h" todo "PERSONAL-@ERRANDS" nil)         ;; (3)
        ("p" tags "PROJECT-MAYBE-DONE" nil)        ;; (4)
        ("m" tags "PROJECT&amp;MAYBE" nil)
        ("a" "My agenda"
         ((org-agenda-list)
          (tags-todo "URGENT")                     ;; (5)
          (tags "PROJECT-MAYBE-DONE")))            ;; (6)
        ;; ... put your other custom commands here
       ))</pre>
<ul>
	<li>(1) "u" is for "urgent", "todo" specifies that TODO headlines are to be shown, "WORK&amp;URGENT" is the query string, and the last item means that there aren't any options</li>
	<li>(2) "c" is for "call"</li>
	<li>(3) "h" is for "home"</li>
	<li>(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.</li>
	<li>(5) This is how to add a tag search for tasks into a custom agenda command.</li>
	<li>(6) This is how to add a tag search for headlines into a custom agenda command.</li>
</ul>
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.
<h5>In your agenda file</h5>
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).
<h4>Other cool things you can do with tags</h4>
</p><p class="first">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:
<pre class="example">
M-x wicked/org-calculate-tag-time RET URGENT RET</pre>
to see something like this:
<pre class="example">
Time: 98:44 (98 hours and 44 minutes)</pre>
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:
<pre class="example">
(defun wicked/org-calculate-tag-time (matcher &amp;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 " *\\(\\&lt;\\("
		     (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
		     (org-re
		      "\\&gt;\\)\\)? *\\(.*?\\)\\(:[[: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 (&gt;= 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))</pre>
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: <a href="http://www.technorati.com/tag/wickedcoolemacs" rel="tag">wickedcoolemacs</a>, <a href="http://www.technorati.com/tag/org" rel="tag">org</a>, <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a></p>]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/01/04/tagging-in-org-plus-bonus-code-for-timeclocks-and-tags/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Projects in Emacs Org</title>
		<link>http://sachachua.com/wp/2008/01/02/projects-in-emacs-org/</link>
		<comments>http://sachachua.com/wp/2008/01/02/projects-in-emacs-org/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 01:41:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[org]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2008.01.02.php#anchor-1</guid>
		<description><![CDATA[<h4>Introduction</h4>

<p class="first">Organizing your tasks into projects can help you plan ahead, track
your progress, and stay motivated. Working from a project list allows
you to plan your day or week instead of just reacting to other
people's requests. Keeping your projects and tasks in Org makes it
easier for you to review your completed tasks and plan the next step.
If you include some text describing why you want to do the project and
what your intended outcome is, this can help you stay motivated
throughout a long project.</p>

<p>Projects can take a single day or several years. They can be large
projects involving lots of other people and resources, or small
projects that you do on your own. Projects may involve a handful of
separate steps or a hundred things you need to do in order to achieve
your goal. The important thing is that there is more than one step.
If you organize your task list so that related tasks are together,
then you'll find it easier to get a sense of where you are, where
you're going, and what you need to do next.</p>

<p>In this section, you will learn how to:</p>

<ul>
<li>Create projects,</li>
<li>Organize your tasks into projects,</li>
<li>Review your ongoing projects, and</li>
<li>Mark projects as finished.</li>
</ul>

<p>I'll assume that you're using Emacs 22, and that you've set up Org
using an ~/organizer.org agenda file and the basic configuration
suggested in either "Org and GTD" or "Org as a Day Planner." I'll also
assume that you're familiar with switching between the Org agenda view
and the Org organizer file, and that you're comfortable navigating
around Emacs.</p>

<p>The examples I'll use focus on yearly goals. You might also have
short-term projects or long-term plans. Feel free to adapt the
examples as needed.</p>

<p>Open your ~/organizer.org file. If you've collected your tasks as
suggested in the previous sections on Using Org as a Day Planner or
Using Org for GTD, your ~/organizer.org file might look something like
this:</p>

<pre class="example">
 * Inbox
 ** TODO Read Emacs Lisp intro
 ** TODO Write yearly review
 ** TODO Exercise
 ** TODO Browse the Emacs Wiki
</pre>

<p>Create new top-level headings for this year's goals or the projects
that you're working on.  You can create a top-level heading by
typing * and the heading, like this:</p>

<pre class="example">
 * Learn more about Emacs
 * Go on vacation
 ...
 * Inbox
 ** TODO Read Emacs manual
 ...
</pre>

<p>It's a good idea to add the projects to the beginning of the file
(before your Inbox) because M-x remember adds new tasks or notes to
the end of the file. If the last major heading as * Inbox, then the
tasks and notes are automatically added to it. If the last major
heading is a project, the tasks and notes may get misfiled.</p>

<h5>What are your projects?</h5>

<h5>Yearly goals? I've got twenty-year plans!</h5>

<p>If you're a top-down planner, you'll find it easy to list your
projects. In fact, you might have a ten- or even twenty-year plan
already written down. You'll find this section straightforward,
because you're already used to planning in terms of projects.
Go ahead and adapt the examples to your long-term plans.</p>


<h5>Yearly goals? I live day by day!</h5>

<p>If you're a bottom-up planner, you might be giving me a weird look
right now. "Yearly goals? I'm lucky if I can figure out how to get
through the next day!" This section will also show you how to find the
recurring themes in your task list and organize them into projects.
Give project-based planning a try for a month. If this way of thinking
doesn't work for you, Org will work just fine without projects.</p>

<p>You probably have projects, even if you can't think of any right
now. Review your ~/organizer.org file. If you haven't written down
everything you needed to do yet, go through the section on basic
configuration for your planning style (GTD or day planning). Once you
have a list of things to do, you can then review it for big tasks,
related tasks, and other project clues.</p>

<p>Read your tasks and ask yourself the following questions:</p>

<ul>
<li>*Can I do this in one sitting?* Big tasks such as "Write a book" are often projects in disguise. Use projects so that you can break them down into smaller, doable tasks.</li>
<li>*Is this related to other tasks?* Related tasks such as "Book a flight" and "Plan my itinerary" are often clues to a project like "Go on vacation". Use projects so that you can review related tasks together.</li>
<li>*Why am I doing this?* When you think about the reason why you're doing something, you'll often find a bigger project. For example, if one of your tasks is "Set up an automatic retirement savings plan", then the question "Why am I doing this?" may lead you to the project "Plan for retirement". Use projects to help you think of other ways to move towards that goal.</li>
</ul>


<p>Big tasks need to be broken down into smaller tasks anyway, and
organizing them into projects will help you make them more
manageable. You may not want to organize all of your other tasks into
projects. If you can pick some major themes to focus on, though, then
you'll be able to see how the different things you do are related to
each other, and you'll be able to think of other ways to work on those
projects. If you're starting out with project-based thinking, maybe
you can pick three to five projects and try to do a little work on
each of them every day.</p>


<p>If you still don't identify any projects, that's okay. You can use Org
as a straightforward task list. Jump ahead to the section on "Tags",
as you'll probably find that useful.</p>

<p>On the other hand, if this step turns up plenty of projects, resist
the temptation to over-correct and end up with hundreds of projects. I
find that more than 7 active projects gets hard to manage. Pick a few
main themes that you'd like to work on, and make everthing else
something you plan to do someday.</p>




<h4>Project tasks</h4>

<h5>Creating tasks</h5>

<p>Now that you have project headings, think of the next thing you need
to do in order to move those projects forward. If you've already
written down those tasks, move them under the appropriate project
heading. If not, type them in.</p>

<p>In order for a task to belong to a project, it needs to be under the
heading and at a lower level. For example, if your project heading has
one star, like this:</p>

<pre class="example">
 * Learn Emacs
</pre>

<p>then your TODO headings should have two stars, like this:</p>

<pre class="example">
 * Learn Emacs
 ** TODO Read the Emacs manual
 ** TODO Read the Emacs Lisp Intro manual (eintr)
 ** TODO Install the Emacs source code
</pre>

<p>If your tasks are not at the right level, you can add the star
manually by editing the heading. You can also use M-right and M-left
(org-metaright and org-metaleft) while on a heading in order to
promote or demote it, and you can use M-S-right and M-S-left
(org-shift-metaright and org-shift-metaleft) to promote or demote
entire subtrees.</p>

<p>To move tasks up and down within the project, you can copy and paste
the text. You can use M-Up and M-Down (org-metaup and org-metadown) to
move subtrees.</p>

<p>Think of tasks you can do within the next week in order to move each
of your projects forward.  Add next actions to all of your active
projects. Creating next actions for each of your projects makes it
easier to remember to keep moving forward.</p>


<h5>Organizing tasks</h5>

<p>If you have many tasks in a project, you may want to organize them
into sub-projects. For example, you might divide a software project
into components. If you're starting from scratch, you can create the
project structure by typing in more stars for sub-project
headings. For example:</p>

<pre class="example">
 * Learn Emacs
 ** Read mail
 *** TODO Choose a mail client
 *** TODO Install and configure the mail client
 *** TODO Send a message
 ...
 ** Browse the Web
 *** Read through the w3m documentation
 ...
</pre>

<p>You can also demote an existing project into a subproject.
Use M-S-right (org-shift-metaright) on the
current project headline in order to demote it to a sub-project. This
will also demote the tasks within the project. For example, demoting
this:</p>

<pre class="example">
 * Learn Emacs
 ** TODO Choose a mail client
 ** TODO Install and configure the mail client
 ** TODO Send a message
</pre>

<p>will result in this:</p>

<pre class="example">
 ** Learn Emacs
 *** TODO Choose a mail client
 *** TODO Install and configure the mail client
 *** TODO Send a message
</pre>

<p>Then you can change the heading and add another heading above it, like this:</p>

<pre class="example">
 * Learn Emacs
 ** Read mail
 *** TODO Choose a mail client
 *** TODO Install and configure the mail client
 *** TODO Send a message
</pre>

<p>This kind of organization is optional, but it can help you get an idea
of the overall structure of your project. Using different levels
allows you to hide and show groups of headings by pressing TAB on the
heading.</p>

<p>Now that you've created your project tasks and organized them the way
you want, it's time to actually do the work.</p>


<h5>Working on tasks</h5>

<p>If you use Org as a day planner, you may also want to schedule the
tasks onto specific days with C-c C-s (org-schedule). You can review
your daily or weekly agenda with C-c a a (org-agenda,
org-agenda-list), switching between daily and weekly views with d and
w (org-agenda-day-view and org-agenda-week-view).</p>

<p>You can work with the next actions in the same way you work with other
tasks, rescheduling them or marking them as STARTED, WAITING or DONE
with the keyboar shortcuts introduced in the previous section on Org
and GTD or Org as a Day Planner.</p>

<p>When you finish a project task, think of the next action you can do in
order to move that project forward. If you use Org as a day planner,
schedule the next action onto your calendar as well.</p>



<h4>Reviewing projects</h4>

<p class="first">You can review your projects by opening your ~/organizer.org and
browsing through the headings. S-tab (org-shifttab) changes the
visibility of headings, so you can see just the top-level headings or
all the details. You can use TAB (org-cycle) on a headline to show or
hide subtrees.</p>

<h5>Reviewing a list of projects</h5>

<p>If you have many projects, you'll want a shorter view of just your
active projects.  To make it easier to review projects, add a PROJECT
tag to all your active project headlines.  You can add a tag by
editing your ~/organizer.org and moving your cursor to the headline
and typing C-c C-c (org-ctrl-c-ctrl-c), followed by the name of the
tag (PROJECT).  You can also manually type :TAGNAME: at the end of the
headings, like this:</p>

<pre class="example">
 * Learn more about Emacs        :PROJECT:
 ** TODO Read the Emacs manual
 ** TODO Read the Emacs Lisp Intro manual (eintr)
 ...
 * Go on vacation                :PROJECT:
 ...
 * Inbox
 ...
</pre>

<p>You might classify some of your projects as someday/maybe - things
that are nice to think about, but which you aren't acting on right
now.  Tag your inactive or someday/maybe projects with PROJECT and
MAYBE. If you're editing the ~/organizer.org file, just
add :PROJECT:MAYBE: to the heading. If you're tagging it with C-c C-c
(org-ctrl-c-ctrl-c), specify PROJECT:MAYBE as the tag.</p>

<pre class="example">
 * Learn more about Emacs        :PROJECT:
 * Go on vacation                :PROJECT:MAYBE:
 ...
 * Inbox
 ** TODO Read Emacs manual
 ...
</pre>

<p>Now that you've tagged your projects, you can view just your project
headlines with a custom agenda command. Custom agenda views are a
terrific feature in Org, and you can do a lot with them if you know a
little Emacs Lisp. Here's what you need to add to your ~/.emacs in
order to get a list of your active projects and your someday/maybe
projects:</p>

<pre class="example">
(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)  ;; (1)
        ("m" tags "PROJECT&#038;MAYBE" nil)       ;; (2)
        ;; ... put your other custom commands here
       ))
</pre>

<ul>
<li>(1) This makes C-c a p (org-agenda, p) show your active projects.</li>
<li>(2) This makes C-c a m (org-agenda, m) show your "maybe" projects.</li>
</ul>

<p>With these two commands, you can quickly review your active and
inactive projects. To jump to a project from the agenda view, move
your cursor to the heading and press RET (org-agenda-switch-to). If
you want to scan through the projects quickly, use f
(org-agenda-follow-mode) in the agenda view to turn on follow mode,
then move to different headlines. Another window will show the
headline at point.</p>

<p>If you review your projects at least once a week, you'll find it
easier to make regular progress. If you want to combine your
weekly/daily review with your project list, you can do that with
org-agenda-custom-commands as well. Here's what you'd put in your
~/.emacs:</p>

<pre class="example">
(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)
        ("m" tags "PROJECT&#038;MAYBE" nil)
        ("a" "My agenda"                            ;; (1)
         ((org-agenda-list)                         ;; (2)
          (tags "PROJECT-MAYBE-DONE")))             ;; (3)
        ;; ... put your other custom commands here
       ))
</pre>

<ul>
<li>(1) The first argument is the shortcut key, the second is a name for the agenda view</li>
<li>(2) Your daily or weekly agenda. The d and w (org-agenda-day-view and org-agenda-week-view) shortcuts work if the point is within this section</li>
<li>(3) A list of your active projects</li>
</ul>

<p>This configures C-c a a (org-agenda, "My agenda") to display your
agenda and a list of your project headings. Again, you can press RET
(org-agenda-switch-to) to jump to a project from its heading in the
agenda view.</p>


<h5>Reviewing your stuck projects</h5>

<p>You might have forgotten to create next actions for some of your
active projects. Org can help you find projects which don't have next actions.
You can then decide if the project is complete or if it needs further action.</p>


<p>To list stuck projects, you first need to tell Org what a stuck
project is.  The following code defines a stuck project as an active
project (not tagged "maybe" or "done") that doesn't have a TODO or
STARTED action, if the body of the project doesn't contain "*lt;IGNORE&#62;". Add this to your ~/.emacs and evaluate it:</p>

<pre class="example">
(setq org-stuck-projects
      '("+PROJECT/-MAYBE-DONE" ("TODO" "STARTED") nil "\\&#60;IGNORE\\&#62;"))
</pre>

<p>Then you can use M-x org-agenda-list-stuck-projects or C-a a #
(org-agenda, org-agenda-list-stuck-projects) to show only the stuck
projects. Review this list and jump to the headlines.</p>

<p>Want to add that to your custom agenda view? Modify the org-agenda-custom-commands value in your ~/.emacs to be like this:</p>

<pre class="example">
(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)
        ("m" tags "PROJECT&#038;MAYBE" nil)
        ("a" "My agenda"
         ((org-agenda-list)
          (org-agenda-list-stuck-projects)          ;; (1)
          (tags "PROJECT-MAYBE-DONE")))
        ;; ... put your other custom commands here
       ))
</pre>

<ul>
<li>(1) It's a good idea to put it before your regular project list so that you can see what needs your attention.</li>
</ul>

<p>What about finished projects? You might want to keep them in your Org
file, but they shouldn't show up in your active and inactive project
lists. Org can keep track of those projects too.</p>


<h5>Marking projects as done</h5>

<p>If you look at the custom commands above, you'll notice the "-DONE"
specifier. "DONE" is the tag we'll use to indicate done projects.  To
tag a project as done, move the point to the project heading and type
C-c C-c (org-ctrl-c-ctrl-c). The tag prompt will default to the
current tags. Just add "DONE" and press Enter. With the custom
commands we've set up, projects tagged DONE will not show in your
active, inactive, or stuck project lists.</p>

<p>You can also add the tag manually. For example, if the project heading is</p>

<pre class="example">
 * Learn Emacs    :PROJECT:
</pre>

<p>and you're happy with your level of Emacs proficiency, then you can
mark it as done by changing it to</p>

<pre class="example">
 * Learn Emacs    :PROJECT:DONE:
</pre>

<p>If you have plenty of completed projects, your Org file might be quite
large. You can mark a subtree for archiving by typing C-c C-x C-a
(org-toggle-archive-tag). This hides it from most Org commands. You
can also archive a tree into a different file with C-c C-x C-s
(org-advertized-archive-subtree).</p>



<h4>Wrapping up</h4>

<p class="first">Now you can create projects, manage your project tasks, and review
your active, inactive, and stuck projects in Org. You know how to mark
projects as completed and how to archive them.  You've also started
using tags to dynamically generate reports from your Org file.</p>

<p>Tags can do a lot more. To find out what else you can do with tags,
read the next section on "Tagging in Org".</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/wickedcoolemacs" rel="tag">wickedcoolemacs</a>, <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/org" rel="tag">org</a></p>


]]></description>
			<content:encoded><![CDATA[<h4>Introduction</h4>

<p class="first">Organizing your tasks into projects can help you plan ahead, track
your progress, and stay motivated. Working from a project list allows
you to plan your day or week instead of just reacting to other
people's requests. Keeping your projects and tasks in Org makes it
easier for you to review your completed tasks and plan the next step.
If you include some text describing why you want to do the project and
what your intended outcome is, this can help you stay motivated
throughout a long project.</p>

<p>Projects can take a single day or several years. They can be large
projects involving lots of other people and resources, or small
projects that you do on your own. Projects may involve a handful of
separate steps or a hundred things you need to do in order to achieve
your goal. The important thing is that there is more than one step.
If you organize your task list so that related tasks are together,
then you'll find it easier to get a sense of where you are, where
you're going, and what you need to do next.</p>

<p>In this section, you will learn how to:</p>

<ul>
<li>Create projects,</li>
<li>Organize your tasks into projects,</li>
<li>Review your ongoing projects, and</li>
<li>Mark projects as finished.</li>
</ul>

<p>I'll assume that you're using Emacs 22, and that you've set up Org
using an ~/organizer.org agenda file and the basic configuration
suggested in either "Org and GTD" or "Org as a Day Planner." I'll also
assume that you're familiar with switching between the Org agenda view
and the Org organizer file, and that you're comfortable navigating
around Emacs.</p>

<p>The examples I'll use focus on yearly goals. You might also have
short-term projects or long-term plans. Feel free to adapt the
examples as needed.</p>

<p>Open your ~/organizer.org file. If you've collected your tasks as
suggested in the previous sections on Using Org as a Day Planner or
Using Org for GTD, your ~/organizer.org file might look something like
this:</p>

<pre class="example">
 * Inbox
 ** TODO Read Emacs Lisp intro
 ** TODO Write yearly review
 ** TODO Exercise
 ** TODO Browse the Emacs Wiki
</pre>

<p>Create new top-level headings for this year's goals or the projects
that you're working on.  You can create a top-level heading by
typing * and the heading, like this:</p>

<pre class="example">
 * Learn more about Emacs
 * Go on vacation
 ...
 * Inbox
 ** TODO Read Emacs manual
 ...
</pre>

<p>It's a good idea to add the projects to the beginning of the file
(before your Inbox) because M-x remember adds new tasks or notes to
the end of the file. If the last major heading as * Inbox, then the
tasks and notes are automatically added to it. If the last major
heading is a project, the tasks and notes may get misfiled.</p>

<h5>What are your projects?</h5>

<h5>Yearly goals? I've got twenty-year plans!</h5>

<p>If you're a top-down planner, you'll find it easy to list your
projects. In fact, you might have a ten- or even twenty-year plan
already written down. You'll find this section straightforward,
because you're already used to planning in terms of projects.
Go ahead and adapt the examples to your long-term plans.</p>


<h5>Yearly goals? I live day by day!</h5>

<p>If you're a bottom-up planner, you might be giving me a weird look
right now. "Yearly goals? I'm lucky if I can figure out how to get
through the next day!" This section will also show you how to find the
recurring themes in your task list and organize them into projects.
Give project-based planning a try for a month. If this way of thinking
doesn't work for you, Org will work just fine without projects.</p>

<p>You probably have projects, even if you can't think of any right
now. Review your ~/organizer.org file. If you haven't written down
everything you needed to do yet, go through the section on basic
configuration for your planning style (GTD or day planning). Once you
have a list of things to do, you can then review it for big tasks,
related tasks, and other project clues.</p>

<p>Read your tasks and ask yourself the following questions:</p>

<ul>
<li>*Can I do this in one sitting?* Big tasks such as "Write a book" are often projects in disguise. Use projects so that you can break them down into smaller, doable tasks.</li>
<li>*Is this related to other tasks?* Related tasks such as "Book a flight" and "Plan my itinerary" are often clues to a project like "Go on vacation". Use projects so that you can review related tasks together.</li>
<li>*Why am I doing this?* When you think about the reason why you're doing something, you'll often find a bigger project. For example, if one of your tasks is "Set up an automatic retirement savings plan", then the question "Why am I doing this?" may lead you to the project "Plan for retirement". Use projects to help you think of other ways to move towards that goal.</li>
</ul>


<p>Big tasks need to be broken down into smaller tasks anyway, and
organizing them into projects will help you make them more
manageable. You may not want to organize all of your other tasks into
projects. If you can pick some major themes to focus on, though, then
you'll be able to see how the different things you do are related to
each other, and you'll be able to think of other ways to work on those
projects. If you're starting out with project-based thinking, maybe
you can pick three to five projects and try to do a little work on
each of them every day.</p>


<p>If you still don't identify any projects, that's okay. You can use Org
as a straightforward task list. Jump ahead to the section on "Tags",
as you'll probably find that useful.</p>

<p>On the other hand, if this step turns up plenty of projects, resist
the temptation to over-correct and end up with hundreds of projects. I
find that more than 7 active projects gets hard to manage. Pick a few
main themes that you'd like to work on, and make everthing else
something you plan to do someday.</p>




<h4>Project tasks</h4>

<h5>Creating tasks</h5>

<p>Now that you have project headings, think of the next thing you need
to do in order to move those projects forward. If you've already
written down those tasks, move them under the appropriate project
heading. If not, type them in.</p>

<p>In order for a task to belong to a project, it needs to be under the
heading and at a lower level. For example, if your project heading has
one star, like this:</p>

<pre class="example">
 * Learn Emacs
</pre>

<p>then your TODO headings should have two stars, like this:</p>

<pre class="example">
 * Learn Emacs
 ** TODO Read the Emacs manual
 ** TODO Read the Emacs Lisp Intro manual (eintr)
 ** TODO Install the Emacs source code
</pre>

<p>If your tasks are not at the right level, you can add the star
manually by editing the heading. You can also use M-right and M-left
(org-metaright and org-metaleft) while on a heading in order to
promote or demote it, and you can use M-S-right and M-S-left
(org-shift-metaright and org-shift-metaleft) to promote or demote
entire subtrees.</p>

<p>To move tasks up and down within the project, you can copy and paste
the text. You can use M-Up and M-Down (org-metaup and org-metadown) to
move subtrees.</p>

<p>Think of tasks you can do within the next week in order to move each
of your projects forward.  Add next actions to all of your active
projects. Creating next actions for each of your projects makes it
easier to remember to keep moving forward.</p>


<h5>Organizing tasks</h5>

<p>If you have many tasks in a project, you may want to organize them
into sub-projects. For example, you might divide a software project
into components. If you're starting from scratch, you can create the
project structure by typing in more stars for sub-project
headings. For example:</p>

<pre class="example">
 * Learn Emacs
 ** Read mail
 *** TODO Choose a mail client
 *** TODO Install and configure the mail client
 *** TODO Send a message
 ...
 ** Browse the Web
 *** Read through the w3m documentation
 ...
</pre>

<p>You can also demote an existing project into a subproject.
Use M-S-right (org-shift-metaright) on the
current project headline in order to demote it to a sub-project. This
will also demote the tasks within the project. For example, demoting
this:</p>

<pre class="example">
 * Learn Emacs
 ** TODO Choose a mail client
 ** TODO Install and configure the mail client
 ** TODO Send a message
</pre>

<p>will result in this:</p>

<pre class="example">
 ** Learn Emacs
 *** TODO Choose a mail client
 *** TODO Install and configure the mail client
 *** TODO Send a message
</pre>

<p>Then you can change the heading and add another heading above it, like this:</p>

<pre class="example">
 * Learn Emacs
 ** Read mail
 *** TODO Choose a mail client
 *** TODO Install and configure the mail client
 *** TODO Send a message
</pre>

<p>This kind of organization is optional, but it can help you get an idea
of the overall structure of your project. Using different levels
allows you to hide and show groups of headings by pressing TAB on the
heading.</p>

<p>Now that you've created your project tasks and organized them the way
you want, it's time to actually do the work.</p>


<h5>Working on tasks</h5>

<p>If you use Org as a day planner, you may also want to schedule the
tasks onto specific days with C-c C-s (org-schedule). You can review
your daily or weekly agenda with C-c a a (org-agenda,
org-agenda-list), switching between daily and weekly views with d and
w (org-agenda-day-view and org-agenda-week-view).</p>

<p>You can work with the next actions in the same way you work with other
tasks, rescheduling them or marking them as STARTED, WAITING or DONE
with the keyboar shortcuts introduced in the previous section on Org
and GTD or Org as a Day Planner.</p>

<p>When you finish a project task, think of the next action you can do in
order to move that project forward. If you use Org as a day planner,
schedule the next action onto your calendar as well.</p>



<h4>Reviewing projects</h4>

<p class="first">You can review your projects by opening your ~/organizer.org and
browsing through the headings. S-tab (org-shifttab) changes the
visibility of headings, so you can see just the top-level headings or
all the details. You can use TAB (org-cycle) on a headline to show or
hide subtrees.</p>

<h5>Reviewing a list of projects</h5>

<p>If you have many projects, you'll want a shorter view of just your
active projects.  To make it easier to review projects, add a PROJECT
tag to all your active project headlines.  You can add a tag by
editing your ~/organizer.org and moving your cursor to the headline
and typing C-c C-c (org-ctrl-c-ctrl-c), followed by the name of the
tag (PROJECT).  You can also manually type :TAGNAME: at the end of the
headings, like this:</p>

<pre class="example">
 * Learn more about Emacs        :PROJECT:
 ** TODO Read the Emacs manual
 ** TODO Read the Emacs Lisp Intro manual (eintr)
 ...
 * Go on vacation                :PROJECT:
 ...
 * Inbox
 ...
</pre>

<p>You might classify some of your projects as someday/maybe - things
that are nice to think about, but which you aren't acting on right
now.  Tag your inactive or someday/maybe projects with PROJECT and
MAYBE. If you're editing the ~/organizer.org file, just
add :PROJECT:MAYBE: to the heading. If you're tagging it with C-c C-c
(org-ctrl-c-ctrl-c), specify PROJECT:MAYBE as the tag.</p>

<pre class="example">
 * Learn more about Emacs        :PROJECT:
 * Go on vacation                :PROJECT:MAYBE:
 ...
 * Inbox
 ** TODO Read Emacs manual
 ...
</pre>

<p>Now that you've tagged your projects, you can view just your project
headlines with a custom agenda command. Custom agenda views are a
terrific feature in Org, and you can do a lot with them if you know a
little Emacs Lisp. Here's what you need to add to your ~/.emacs in
order to get a list of your active projects and your someday/maybe
projects:</p>

<pre class="example">
(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)  ;; (1)
        ("m" tags "PROJECT&MAYBE" nil)       ;; (2)
        ;; ... put your other custom commands here
       ))
</pre>

<ul>
<li>(1) This makes C-c a p (org-agenda, p) show your active projects.</li>
<li>(2) This makes C-c a m (org-agenda, m) show your "maybe" projects.</li>
</ul>

<p>With these two commands, you can quickly review your active and
inactive projects. To jump to a project from the agenda view, move
your cursor to the heading and press RET (org-agenda-switch-to). If
you want to scan through the projects quickly, use f
(org-agenda-follow-mode) in the agenda view to turn on follow mode,
then move to different headlines. Another window will show the
headline at point.</p>

<p>If you review your projects at least once a week, you'll find it
easier to make regular progress. If you want to combine your
weekly/daily review with your project list, you can do that with
org-agenda-custom-commands as well. Here's what you'd put in your
~/.emacs:</p>

<pre class="example">
(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)
        ("m" tags "PROJECT&MAYBE" nil)
        ("a" "My agenda"                            ;; (1)
         ((org-agenda-list)                         ;; (2)
          (tags "PROJECT-MAYBE-DONE")))             ;; (3)
        ;; ... put your other custom commands here
       ))
</pre>

<ul>
<li>(1) The first argument is the shortcut key, the second is a name for the agenda view</li>
<li>(2) Your daily or weekly agenda. The d and w (org-agenda-day-view and org-agenda-week-view) shortcuts work if the point is within this section</li>
<li>(3) A list of your active projects</li>
</ul>

<p>This configures C-c a a (org-agenda, "My agenda") to display your
agenda and a list of your project headings. Again, you can press RET
(org-agenda-switch-to) to jump to a project from its heading in the
agenda view.</p>


<h5>Reviewing your stuck projects</h5>

<p>You might have forgotten to create next actions for some of your
active projects. Org can help you find projects which don't have next actions.
You can then decide if the project is complete or if it needs further action.</p>


<p>To list stuck projects, you first need to tell Org what a stuck
project is.  The following code defines a stuck project as an active
project (not tagged "maybe" or "done") that doesn't have a TODO or
STARTED action, if the body of the project doesn't contain "*lt;IGNORE&gt;". Add this to your ~/.emacs and evaluate it:</p>

<pre class="example">
(setq org-stuck-projects
      '("+PROJECT/-MAYBE-DONE" ("TODO" "STARTED") nil "\\&lt;IGNORE\\&gt;"))
</pre>

<p>Then you can use M-x org-agenda-list-stuck-projects or C-a a #
(org-agenda, org-agenda-list-stuck-projects) to show only the stuck
projects. Review this list and jump to the headlines.</p>

<p>Want to add that to your custom agenda view? Modify the org-agenda-custom-commands value in your ~/.emacs to be like this:</p>

<pre class="example">
(setq org-agenda-custom-commands
      '(("p" tags "PROJECT-MAYBE-DONE" nil)
        ("m" tags "PROJECT&MAYBE" nil)
        ("a" "My agenda"
         ((org-agenda-list)
          (org-agenda-list-stuck-projects)          ;; (1)
          (tags "PROJECT-MAYBE-DONE")))
        ;; ... put your other custom commands here
       ))
</pre>

<ul>
<li>(1) It's a good idea to put it before your regular project list so that you can see what needs your attention.</li>
</ul>

<p>What about finished projects? You might want to keep them in your Org
file, but they shouldn't show up in your active and inactive project
lists. Org can keep track of those projects too.</p>


<h5>Marking projects as done</h5>

<p>If you look at the custom commands above, you'll notice the "-DONE"
specifier. "DONE" is the tag we'll use to indicate done projects.  To
tag a project as done, move the point to the project heading and type
C-c C-c (org-ctrl-c-ctrl-c). The tag prompt will default to the
current tags. Just add "DONE" and press Enter. With the custom
commands we've set up, projects tagged DONE will not show in your
active, inactive, or stuck project lists.</p>

<p>You can also add the tag manually. For example, if the project heading is</p>

<pre class="example">
 * Learn Emacs    :PROJECT:
</pre>

<p>and you're happy with your level of Emacs proficiency, then you can
mark it as done by changing it to</p>

<pre class="example">
 * Learn Emacs    :PROJECT:DONE:
</pre>

<p>If you have plenty of completed projects, your Org file might be quite
large. You can mark a subtree for archiving by typing C-c C-x C-a
(org-toggle-archive-tag). This hides it from most Org commands. You
can also archive a tree into a different file with C-c C-x C-s
(org-advertized-archive-subtree).</p>



<h4>Wrapping up</h4>

<p class="first">Now you can create projects, manage your project tasks, and review
your active, inactive, and stuck projects in Org. You know how to mark
projects as completed and how to archive them.  You've also started
using tags to dynamically generate reports from your Org file.</p>

<p>Tags can do a lot more. To find out what else you can do with tags,
read the next section on "Tagging in Org".</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/wickedcoolemacs" rel="tag">wickedcoolemacs</a>, <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/org" rel="tag">org</a></p>


]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/01/02/projects-in-emacs-org/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Clocking Time with Emacs Org</title>
		<link>http://sachachua.com/wp/2007/12/30/clocking-time-with-emacs-org/</link>
		<comments>http://sachachua.com/wp/2007/12/30/clocking-time-with-emacs-org/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 00:46:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[org]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2007.12.30.php#anchor-2</guid>
		<description><![CDATA[<p>Many professionals bill clients for their time. Even if you don't, keeping track of the time you actually spend on tasks can help you improve your time estimates and check if you're spending enough time on the things that are impo