How do you take notes now? Do you jot your notes on a scrap of paper or into a leather notebook? Do you copy and paste what you're looking at into a plain text file or document? Do you scribble things into a personal digital assistant?
I've tried different note-taking strategies: colorful mindmaps, outlined text files, even voice recordings. I felt frustrated every time I had to write down whose e-mail or which webpage prompted the note (shouldn't the computer do that automatically?), but I was even more frustrated when I'd come across a note and not remember why I wrote it.
Remember changed all that for me. The key ideas behind Remember are that you should be able to write notes with minimal distraction, and that as the context should be automatically picked up so that you don't have to write it down. If you're writing a note based on a mail message, Remember will pick up the details of the message and create a hyperlink so that you can view the original message when reviewing your notes. If you're working on a file, Remember will link to it so that you can jump back to it. If you're browsing a web page (in Emacs, of course), Remember will remember the title and URL, so that you can go back to the page when you want to clarify something in your notes. And after you save the note, you'll be back in the same environment you were: no need to switch applications and no need to remember different keyboard shortcuts.
You might think that Remember's only worth it if you do _everything_ in Emacs. For me, it worked the other way around. I started by using Remember to take notes in Planner, a personal information manager available for Emacs. As I got accustomed to the way Remember and Planner just automatically hyperlinked to whatever I was looking at, I thought: Why doesn't my mail client do this? Why doesn't my web browser do this? Why doesn't my chat client do this? So I ended up reading through the manuals, figuring out how to do all these things in Emacs—and I loved it, eventually doing most of my work (and play!) within an Emacs frame. Although I use other applications now, like Lotus Notes for work mail and Mozilla Firefox for browsing, I still switch back to Emacs for my notes.
In this section, you'll learn how to set up Remember and take quick notes in Emacs. We'll start by configuring Remember to save your notes to a file, and how to configure Remember to save to different places depending on the content. You'll also learn how to quickly search your notes file for entries.
You can also integrate Remember into other note-taking systems in Emacs. The sections that cover those systems will also show you how to configure Remember to save your notes there.
Remember is a separate package, which you can download from https://gna.org/projects/remember-el . As of this writing, the latest stable release is Remember 1.9. Download the latest version and unpack it into your ~/elisp directory. You should end up with a new directory, ~/elisp/remember-1.9 .
To configure Remember to save to plain text files, add this code to your ~/.emacs and evaluate it:
(add-to-list 'load-path "~/elisp/remember-1.9") ;; (1) (require 'remember-autoloads) (setq remember-data-file "~/notes.txt") ;; (2) (global-set-key (kbd "C-c r") 'remember) ;; (3) (defun wicked/remember-review-file () "Open `remember-data-file'." (interactive) (find-file-other-window remember-data-file)) (global-set-key (kbd "C-c r") 'wicked/remember-review-file) ;; (4)
After you've configured Remember, try it out by typing C-c r (remember). Your Emacs frame will be split in two, and one of the windows will be a *Remember* buffer. Type your note. The first line will be the headline, and the rest of the buffer will be the body of the note. If you call C-c r (remember) from a file, the filename will automatically be included at the end of the buffer. Type C-c C-c (remember-buffer) to save the note.
Try it now by typing C-c r (remember) to bring up the buffer, typing in a short note, and using C-c c (remember-buffer) to save it. If you open ~/notes.txt to review your note, you'll find something like this:
** Sat Jan 12 14:43:02 2008 (Your headline goes here) Your note body goes here /home/sacha/.emacs
You can even save yourself some copying and pasting. Mark a region of text and use C-u C-c r (remember). The selected text will be included in the buffer, so all you have to do is comment on it.
Make a habit of typing C-c C-r or C-u C-c C-r (remember) when you need to remember something. Type C-c C-c (remember-buffer) to get back to work, knowing that your notes have been safely saved in your ~/notes.txt file.
Use C-c R (wicked/remember-review-file) to check your notes, or open ~/notes.txt yourself.
To search your notes, use C-c R (wicked/remember-review-file) to open the file, then use C-s (isearch-forward) to search for words interactively, or use M-x occur to find all lines containing a word.
You may notice that the default format that Remember uses is an outline format that is compatible with Org and Allout, both of which have powerful outline-editing tools. I prefer Org's outline-editing commands, and you'll learn about them in the "Outline Notes with Org" section. Here's a quick summary.
First, you need to switch the buffer to Org mode by typing M-x org-mode. To automatically open your notes file in Org mode, add
-*- mode: org -*-
to the first line of your ~/notes.txt. Then, when you open your ~/notes.txt file, it will be in Org mode.
You can quickly collapse or expand all the outline entries by pressing S-TAB (org-shifttab). To collapse or expand a single entry, move the point to the headline (the line beginning with *, **, or any number of asterisks), then press TAB (org-cycle). To move an entry up or down, move the point to the headline and press S-UP (org-shiftup) or S-DOWN (org-shiftdown). To demote or promote a heading, press M-RIGHT (org-metaright) or M-LEFT (org-metaleft).
You can treat ~/notes.txt as your inbox, and keep your organized notes in another file or groups of files. Cut and paste the text between the files to clear your inbox, and use M-x grep to search multiple files. Alternatively, you can keep all of your notes in one large text file, and use C-s (isearch-forward) and M-x occur to search for information.
Now you know the basics of remembering information, saving it into a file, and reviewing the file. By default, Remember annotates your notes with a filename, if you were looking at a file when you called C-c r (remember). As you learn more about Emacs, you may want to configure Remember to add more intelligent annotations and other text to the Remember buffer. The more work Remember does for you, the less work you have to do!
The easiest way to get Remember to automatically understand mail messages, Web pages, info files, BBDB contact records, and other sources of information in Emacs is to use either Org or Planner. To learn how to integrate Remember with either Org or Planner, read the section on "Outline Your Notes with Org" and "Writing Your Journal with Planner".
You can also define your own annotation functions. When you call C-c r (remember) from a buffer, Remember goes through each of the functions in remember-annotation-functions, and it uses the first non-nil value returned.
For example, you may work with many temporary buffers that don't have filenames. To create an annotation function that adds buffer names, add the following code to your ~/.emacs after the basic Remember configuration code:
(eval-after-load 'remember
'(progn
(add-to-list 'remember-annotation-functions 'buffer-name t)))
This adds buffer-name to the end of the annotation list, making it a last resort.
What if you want line numbers included with the filename or buffer name? You could replace the previous code with this:
(defun wicked/remember-line-numbers-and-file-names ()
"Return FILENAME line NUMBER."
(save-restriction
(widen)
(format " %s line %d"
(or (buffer-file-name) (buffer-name))
(line-number-at-pos))))
(eval-after-load 'remember
'(progn
(add-to-list 'remember-annotation-functions
'wicked/remember-line-numbers-and-file-names)))
With that code, C-c r (remember) will automatically pick up the line number from your file or buffer.
By default, Remember saves your notes to a plain-text file, so you'll have to open the files manually. The command M-x ffap or find-find-file-at-point may be convenient. If you want hyperlinks that you can visit easily, consider saving your notes in an Org or Planner file instead.
Now you've got context. What else can you do with the Remember buffer?
Remember has plenty of hooks that let you modify the behavior. For example, you might want to insert a random tagline or fortune-cookie saying whenever you create a note. This is a fun way to encourage yourself to write more, because then there's a little surprise every time you open a Remember buffer.
Here is a totally small-scale way to use random lines from a text file. Let's say that you have a text file made up of movie quotes, taglines, knock-knock jokes, or short fortune-cookie sayings. When I wrote this code, I used Japanese/English sentence pairs about cats, because I was studying Japanese. You can use whatever tickles your fancy, as long as this text file (~/taglines.txt) has one line per saying.
(defun wicked/random-tagline (&optional file)
"Return a random tagline."
(with-current-buffer (find-file-noselect (or file "~/taglines.txt"))
(goto-char (random (point-max)))
(let ((string
(buffer-substring (line-beginning-position)
(line-end-position))))
string)))
(eval-after-load 'remember
'(progn
(defadvice remember (after wicked activate)
"Add random tagline."
(save-excursion
(goto-char (point-max))
(insert "\n\n" (wicked/random-tagline) "\n\n")))))
If you want multi-line sayings, look into the Emacs fortune cookie package, and replace wicked/random-tagline with a function that returns a random string.
This code modifies the behavior of C-c r (remember) by inserting a random tagline after the buffer has been prepared. You can use the same idea to insert a timestamp noting you started, a template figuring or modify the text in other ways.
You can also change how Remember saves its notes. For example, if you want all of the notes that contain the word ":EMACS:" or ":WORK:" to go into separate files, you can add this code to your ~/.emacs:
(defvar wicked/remember-keywords
'((":EMACS:" . "~/emacs.txt")
(":WORK:" . "~/work.txt"))
"*List of (REGEXP . FILENAME).
If an entry matches REGEXP, it will be storied in FILENAME.
The first regular expression that matches is used.")
(eval-after-load 'remember
'(progn
(defadvice remember-region (around wicked activate)
"Save notes matching `wicked/remember-keywords' elsewhere."
(let* ((b (or beg (min (point) (or (mark) (point-min)))))
(e (or end (max (point) (or (mark) (point-max)))))
(string (buffer-substring-no-properties b e))
(done nil)
(keywords wicked/remember-keywords))
(while keywords
(when (string-match (caar keywords) string)
(let ((remember-data-file (cdar keywords)))
ad-do-it)
(setq keywords nil done t))
(setq keywords (cdr keywords)))
(unless done
ad-do-it)))))
You can even configure Remember to use different handler functions. This chapter covers several note-taking systems for Emacs, and you may want to use Remember to save to more than one note-taking system. For example, you can set up C-c r p to start a Remember buffer that saves to Planner, and C-c r o to start a Remember buffer that saves to Org. Here's the code for your ~/.emacs:
(defun wicked/remember-to-org ()
"Remember to Org."
(let ((remember-annotation-functions ;; (1)
(cons 'org-remember-annotation
remember-annotation-functions)))
(remember)
(set (make-variable-buffer-local
'remember-handler-functions)
'(org-remember-handler)))) ;; (2)
(defun wicked/remember-to-planner ()
"Remember to Planner."
(let ((remember-annotation-functions ;; (3)
(append planner-annotation-functions
remember-annotation-functions)))
(remember)
(set (make-variable-buffer-local
'remember-handler-functions)
'(remember-planner-append)))) ;; (4)
(global-unset-key (kbd "C-c r")) ;; (5)
(global-set-key (kbd "C-c r o") 'wicked/remember-to-org)
(global-set-key (kbd "C-c r p") 'wicked/remember-to-planner)
To learn more about configuring Remember with the different note-taking systems, read on!
On Technorati: wickedcoolemacs, book, emacs, remember
Random Emacs symbol: compilation-find-file - Function: Find a buffer for file FILENAME.
]]>
- [ ] Keeping Notes in Emacs
Structured vs Unstructured (outline, free-form)
Flat vs Hyperlinked
Private vs Public
File structure (one file, daily, snippets)
- [ ] Outline Notes with Org, Blorg
- [ ] Daily Notes with Planner
- [ ] Hyperlinked Notes and Muse
- [ ] Publishing Muse
- [ ] Publishing Planner, RSS
- [ ] Remember: quick note entry
- [ ] Snippets with Howm
- [ ] Blogging from Emacs - Wordpress, LJ, Blogger,Muse-Blosxom, EmacsAtomAPI
- [ ] Encrypted Notes (full file, segments) - MOSTLY WRITTEN
I find that thinking of a book as a collection of articles works out well for me. Starting with a rough outline like this, I'll write 2000-word articles of the kind that I'd write for Linux Journal or LinuxWorld, and then I'd put them into my outline and add transitions. After I write all the pieces, then I can write the introduction and the wrap-up sections.
Slowly getting the hang of this writing thing... =)
On Technorati: emacs, writing, wickedcoolemacs
Random Emacs symbol: message-narrow-to-headers-or-head - Function: Narrow the buffer to the head of the message.
]]>The feedback I'm looking for right now is:
Fiddly bits like formatting will wait for the second pass.
If you leave your feedback as comments on this post, I'm less likely to lose it in all the mail that's piling up in my inbox! =)
On Technorati: wickedcoolemacs, emacs, org, planner, writing
Random Emacs symbol: widget-specify-secret - Function: Replace text in FIELD with value of `:secret', if non-nil.
]]>What's a tag, anyway? In Org, tags are keywords at the end of headlines. Each tag can contain letters, numbers, and the symbols '_' and '@'. Tags begin and end with colons, and a single colon separates multiple tags. For example, you could have headlines like this:
* Personal :PERSONAL: ** TODO Buy milk :@ERRANDS: ** TODO Call Mom :@PHONE: ** TODO Send letters :@ERRANDS: * Work :WORK: ** TODO Call John about report :@PHONE:JOHN: ** TODO Prepare for presentation on Monday ** TODO Call Mary about the presentation :@PHONE:URGENT:MARY:
One way to use tags is to filter your task list by priority. For example, you may want to focus on your urgent tasks first without getting distracted by other items on your task list. Another way to use tags is to keep track of the context of your tasks as suggested in GTD. By doing similar tasks together, you might be able to work more efficiently. For example, if you're on the phone at the office, it may be a good idea to do all of your work-related phone calls. If you're going to go to the post office, you might want to drop by the supermarket on your way back. You can use tags to categorize your headlines any way you want.
Tags can take advantage of the outline structure. For example, although the tasks "Buy milk", "Call Mom", and "Send letters" have one tag each, they also inherit the "PERSONAL" tag from the parent headline. A tag search for "PERSONAL" would display all three tasks. To customize this behavior, look at the documentation for the variables org-use-tag-inheritance and org-tags-match-list-sublevels.
Tags can help you organize and filter your task list. In this section, you'll learn how to add tags to your headlines, view tagged items in your Org file and in your agenda, and define custom agenda views. You'll also learn about custom tag searches and other interesting things you can do once you've tagged your headlines.
You can edit your ~/organizer.org file and add tags manually by typing in :tagname: at the end of the headline. You can also add tags by typing C-c C-c (org-ctrl-c-ctrl-c) when the point is on a headline. Use M-TAB (complete-symbol) to complete a tag based on all the tags used in the current file. If Alt-TAB is not processed by Emacs, you can use ESC-TAB instead.
Separate multiple tags with a single colon, like this: (:@PHONE:URGENT:). The beginning and ending colons are optional when using C-c C-c (org-ctrl-c-ctrl-c), because the function will automatically add them.
If you add certain tags frequently, you can set up single-key shortcuts. For example, if you frequently tag tasks as "URGENT", you may want to define a shortcut (at least until your life gets under control). You can assign shortcuts globally by adding this code to your ~/.emacs and evaluating it:
(setq org-tag-alist '(("URGENT" . ?u)
("@PHONE" . ?p)
("@ERRANDS" . ?e)))
You can also set this on a per-file basis by adding the following line to the beginning of your file:
#+TAGS: URGENT(u) @PHONE(p) @ERRANDS(e)
You can then use these C-c C-c (org-ctrl-c-ctrl-c) to enter these single-key shortcuts, ending it with RET. If you are assigning a single tag, type C-c C-c C-c (org-ctrl-c-ctrl-c, next change exits) to make it even faster by skipping the RET.
If you use single-key shortcuts, you'll need another way to enter tags that start with the shortcut key. You can type them in manually, or you can use C-c C-c (org-ctrl-c-ctrl-c) and type TAB to enter in any tag.
To remove a tag, you could use C-c C-c (org-ctrl-c-ctrl-c) again, or delete it manually. To remove all tags, use C-c C-c (org-ctrl-c-ctrl-c) and press SPC.
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.
To view tagged headlines by themselves, use C-c a m (org-agenda, org-tags-view) and specify the search tag. For example, you can view your urgent tasks by specifying "URGENT". Note that this command displays the top headlines matching that tag, whether they're tasks or not. For example, if you searched for "WORK", you would just get the "* Work" headline. To view tagged tasks, use C-c a M (org-agenda, org-tags-view with a prefix argument). This shows only the tasks that have that tag.
To search for a combination of tags, you can combine tags like this:
WORK&@PHONE only your work phone calls
PERSONAL-@ERRANDS personal tasks, but without errands
JOHN|MARY Anything tagged with "JOHN" or "MARY"
For example, if you're going to have a meeting with both of them
If you check certain lists often, you might want to create a custom agenda command for them. In the section on Projects, you configured custom agenda commands for active and inactive projects by adding the following code in your ~/.emacs:
(setq org-agenda-custom-commands
'(("p" tags "PROJECT-MAYBE-DONE" nil)
("m" tags "PROJECT&MAYBE" nil)
("a" "My agenda"
((org-agenda-list)
(tags "PROJECT-MAYBE-DONE")))
;; ... put your other custom commands here
))
You can use the same idea to create quick custom views for your other tagged tasks. For example, to create custom views for your urgent work tasks and your phone calls, modify the org-agenda-custom-commands setting in your ~/.emacs to be like this:
(setq org-agenda-custom-commands
'(("u" todo "WORK&URGENT" nil) ;; (1)
("c" todo "WORK&@PHONE" nil) ;; (2)
("h" todo "PERSONAL-@ERRANDS" nil) ;; (3)
("p" tags "PROJECT-MAYBE-DONE" nil) ;; (4)
("m" tags "PROJECT&MAYBE" nil)
("a" "My agenda"
((org-agenda-list)
(tags-todo "URGENT") ;; (5)
(tags "PROJECT-MAYBE-DONE"))) ;; (6)
;; ... put your other custom commands here
))
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.
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).
And if you ever want to know how much time you spent on urgent tasks, you can call the following function from your organizer.org file with:
M-x wicked/org-calculate-tag-time RET URGENT RET
to see something like this:
Time: 98:44 (98 hours and 44 minutes)
You can call it with a prefix in order to be prompted for a start time (inclusive) and end time (exclusive).
Here's the code to add to your ~/.emacs:
(defun wicked/org-calculate-tag-time (matcher &optional ts te)
"Return the total minutes clocked in headlines matching MATCHER.
MATCHER is a string or a Lisp form to be evaluated, testing if a
given set of tags qualifies a headline for inclusion. TS and TE
are time start (inclusive) and time end (exclusive). Call with a
prefix to be prompted for TS and TE.
For example, to see how much time you spent on tasks tagged as
URGENT, call M-x wicked/org-calculate-tag-time RET URGENT RET. To
see how much time you spent on tasks tagged as URGENT today, call
C-u M-x wicked/org-calculate-tag-time RET URGENT RET . RET +1 RET."
(interactive (list
(read-string "Tag query: ")
(if current-prefix-arg (org-read-date))
(if current-prefix-arg (org-read-date))))
;; Convert strings to proper arguments
(if (stringp matcher) (setq matcher (cdr (org-make-tags-matcher matcher))))
(if (stringp ts)
(setq ts (time-to-seconds (apply 'encode-time (org-parse-time-string ts)))))
(if (stringp te)
(setq te (time-to-seconds (apply 'encode-time (org-parse-time-string te)))))
(let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
(mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
(org-re
"\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:]_@:]+:\\)?[ \t]*$")))
(case-fold-search nil)
lspos
tags tags-list tags-alist (llast 0) rtn level category i txt p
marker entry priority (total 0))
(save-excursion
(org-clock-sum ts te)
(goto-char (point-min))
(while (re-search-forward re nil t)
(catch :skip
(setq tags (if (match-end 4) (match-string 4)))
(goto-char (setq lspos (1+ (match-beginning 0))))
(setq level (org-reduced-level (funcall outline-level))
category (org-get-category))
(setq i llast llast level)
;; remove tag lists from same and sublevels
(while (>= i level)
(when (setq entry (assoc i tags-alist))
(setq tags-alist (delete entry tags-alist)))
(setq i (1- i)))
;; add the nex tags
(when tags
(setq tags (mapcar 'downcase (org-split-string tags ":"))
tags-alist
(cons (cons level tags) tags-alist)))
;; compile tags for current headline
(setq tags-list
(if org-use-tag-inheritance
(apply 'append (mapcar 'cdr tags-alist))
tags))
(when (and (eval matcher)
(or (not org-agenda-skip-archived-trees)
(not (member org-archive-tag tags-list))))
;; Get the time for the headline at point
(goto-char (line-beginning-position))
(setq total (+ total (or (get-text-property (1+ (point)) :org-clock-minutes) 0)))
;; if we are to skip sublevels, jump to end of subtree
(org-end-of-subtree t)))))
(if (interactive-p)
(let* ((h (/ total 60))
(m (- total (* 60 h))))
(message "Time: %d:%02d (%d hours and %d minutes)" h m h m)))
total))
Now you can slice and dice your timeclock records any way you want, thanks to tags!
Random Emacs symbol: cc-imenu-java-generic-expression - Variable: Imenu generic expression for Java mode. See `imenu-generic-expression'.
On Technorati: wickedcoolemacs, org, emacs
]]>This program looks complicated, but it really isn't. In fact, I could have probably done something just as powerful with keyboard macros, not writing a single line of code. But the code was easy to write, and I figured that I'd keep it around just in case I needed to do something like this again.
After a little bit of manual tweaking, I got all the entries into http://sachachua.com/wp/ .
The ability to write short programs quickly and interactively has not only saved me so much time, but it's also made it possible for me to even _think_ of doing some things. =) I could probably have written the same snippets in Perl or Ruby, but being able to combine manual editing and automated operations in the text editor made it just so much faster. I really like being able to scan back and forth in buffers easily in Emacs, instead of thinking in terms of file streams as in other programming languages.
If you work with lots of text, I definitely recommend learning Emacs Lisp, or whatever language your editor can be programmed in. I started by reading other people's source code and the Emacs Lisp Intro and Emacs Lisp info files. I reread them countless times, picking up a little more each time I went through. Now Emacs Lisp is one of the first things I turn to whenever I want to save time doing something complex and repetitive on the computer, such as adding everyone's pictures to a wiki page. (That's a story for next time!)
Emacs is awesome stuff. More than 20 years old, it's the most advanced program I've ever used. What makes it special? It's _definitely_ optimized for the power user, and it provides so many reasons to become one.
Random Emacs symbol: gnus-summary-goto-last-article - Command: Go to the previously read article.