Add New Notes

This commit is contained in:
geekard
2012-08-08 14:26:04 +08:00
commit 5ef7c20052
2374 changed files with 276187 additions and 0 deletions

View File

@@ -0,0 +1,168 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2011-09-02T18:39:42+08:00
====== Get Organized with Emacs Org-mode ======
Created Friday 02 September 2011
http://www.linuxjournal.com/article/9116
Use Emacs to create a flexible plain-text organizer and personal productivity system.
It is said that Emacs, that versatile toolbox for working with text, is more than merely a text editor—it's a lifestyle. That's not just hyperbole. In this article, I show you how to turn Emacs into a flexible personal organizer and productivity system.
I started using Emacs for programming but soon discovered that it worked well for nonprogramming writing tasks too. I began experimenting with several modes that extend Emacs for writing notes and planning projects. Though each one was useful in its own way, none of these features or modes fit my style of working. Then I discovered Org-mode.
Org-mode is a new Emacs mode developed by Carsten Dominik. It is designed for taking notes, outlining, writing, project planning, maintaining to-do lists, time management and even publishing to Web sites—all this using only Emacs and plain text.
Plain text? Why would anyone want to use plain text for doing all of the above? Plain text offers several advantages. You are not locked in to a file format or an operating system. You can edit plain-text files using any available text editor. It is easy to copy and paste plain text from and into e-mail messages. You can track changes in your document using a version control system, such as CVS or Subversion. When I am writing, I find that plain text offers one more advantage—it enables me to think better and focus on my ideas, without the distractions of a word processor.
Getting Started with Org-mode
For this article, I assume that you have Emacs installed and have some familiarity with using it. If you are not already an Emacs user, maybe Org-mode will give you a good reason to start using it. (See Resources for information on getting started with Emacs.)
Org-mode is included in GNU Emacs 22. You also can install Org-mode to work with GNU Emacs 21 and XEmacs. I used GNU Emacs 22 and Org-mode 4.42 to write this article. If you already have Emacs on your system, check whether Org-mode is available by typing the following command:
M-x org-mode
The above notation means press the meta key (Esc or Alt, depending on your setup) followed by x, followed by org-mode, and then press the Return (or Enter) key.
If Emacs displays “No Match”, it means you do not have Org-mode installed. You will need to install org-mode manually or install GNU Emacs 22. You can find precompiled binaries of GNU Emacs 22 for your Linux distribution and even for other operating systems. On Ubuntu 7.04 (Feisty Fawn), you can install GNU Emacs 22 (with Org-mode 4.56d) by running the following command:
sudo apt-get install emacs-snapshot
If you need to install Org-mode for GNU Emacs 21 or XEmacs, download the latest version from orgmode.org, and look for the manual that provides detailed installation instructions. (The Org-mode documentation includes an excellent manual with more than 100 pages and a handy reference card.) Once you have org-mode installed, run the M-x org-mode command again. If Org-mode is installed correctly, Emacs will display “(Org)” in its mode line area, and Org-mode will be active. If you are running Emacs in a graphical environment, you also should see the Org pull-down menu (Figure 1).
Figure 1. Graphical User Interface Menu for Org-mode
Although Org-mode provides a graphical menu, in this article I refer to Org-mode keyboard commands only. Once you get familiar with Org-mode keystrokes, you will find them to be more efficient than the graphical menu.
Add the following lines to your ~/.emacs file and restart Emacs:
;; Org-mode settings
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-font-lock-mode 1)
Now, if you save your org files with the .org extension, they will open up using Org-mode in Emacs. I recommend creating a directory to keep all your Org files. I use ~/notes. Although you can invoke org-mode for any text file, it's convenient to have them in one directory.
Outlining and Writing
Outlining is an effective technique for organizing thoughts, taking notes or writing articles. Emacs has a built-in outline-mode that stores text as entries. Each entry has a headline and a body. Entries can be nested to create a tree of hierarchical information. Emacs uses asterisks (stars) to denote the hierarchy of an outline tree. Lines that do not begin with a star are considered to be the body of the headline above it. In the following example, ** Apples is a headline. Apples are red is the body for the Apples headline.
* Fruit
** Apples
Apples are red
** Oranges
Oranges are orange
*Vegetables
Branches of a tree can be folded and hidden from view to make it easier to navigate the tree and work on specific parts of the tree. When a headline is folded, its body and subtree (all branches) are hidden from view, and the headline is displayed ending with ellipses (three dots).
Outline Structure
Org-mode is based on Emacs' outlinemode, but it makes working with outlines much easier. Place the cursor on a headline. Using the Tab key, you can expand the headline to show its branches and body. Using Shift-Tab does the same for the entire document (Figures 2–4).
Figure 2. Outline Overview
Figure 3. Outline Partially Expanded
Figure 4. Outline Fully Expanded
Org-mode provides useful keystrokes for modifying the outline structure. To promote a heading by one level, place the cursor on the heading, and use the keystroke M-left (meta and left arrow keys together). To demote a heading by one level use M-right. You can promote an entire subtree with M-Shift-left (Meta, Shift and left arrow keys together) and demote it with M-Shift-right.
Plain Lists
Sometimes you may need to add a plain list within the body of a subtree that is not part of the tree structure of the document. To add an unordered plain list, start the line with - or +. To make Org-mode add a - or + at the start of subsequent list items automatically, use M-Return to insert the next list item. To add an ordered list, start the line with 1., and to make Org-mode number subsequent items automatically, use M-Return to insert the next list item. Add an item in the middle of an ordered list, and Org-mode automatically renumbers the list items. You can mix ordered and unordered lists too. Want to add check boxes to a plain list? Start the list item with -[ ]. You can toggle the check box using C-c C-c, which displays the check box as [X] (Figure 5).
Figure 5. Plain Lists
Hyperlinks
Org-mode recognizes URLs and turns them into clickable links. If Emacs knows your default Web browser, clicking on URLs in Org-mode opens up the link in your default Web browser. Org-mode supports other types of external links, including links to files and images (Figure 6).
Figure 6. Hyperlinks
Tables
Org-mode includes a table editor that makes it possible to format tables in plain ASCII text. Using | as a column separator, Org-mode automatically reformats the plain-text table to realign columns or add new rows. Use Tab to move to the next cell and Shift-Tab to move to the previous cell. Org-mode helpfully right-aligns numbers. You can do spreadsheet calculations in these plain-text tables by inserting formulae within cells (Figure 7).
Figure 7. Plain-Text Tables
These are just a few examples of how Org-mode makes it easy to write and format in plain text. But Org-mode's most impressive features are those that enable you to organize and track tasks.
Tags
You can assign tags to any headline. Tags are simply letters or numbers preceded and followed by a colon. For example, :RED: could be a tag. You can associate multiple tags with a single headline as in :RED:GREEN:. Tags are added to the end of a headline. To add a tag to a headline, place the cursor on the headline and type C-c C-c. Org-mode will prompt you for a tag.
Org-mode creates a dynamic list of all tags in the file. If you already have tags in a file and want to tag a headline, Org-mode presents a list of already-entered tags. After typing C-c C-c on a headline, use the up and down arrow keys to see other tags in use.
Figure 8. Tags
Tags can be used to set up a system of labels to relate and group information spread out across an Org file. You could use tags to mark the activity type, such as :CODE: and :CALL:. If you are coordinating tasks with others, you could use colleagues' names as tags.
Work Flow and To-Do Lists
In Org-mode you can create a to-do list in the same file that you are using to write notes or outline a project. This has the advantage of placing the task in the context of the entire project. To mark a headline as a to-do item, start the headline with the word TODO. You can do this more quickly by placing the cursor on the headline and typing in C-c C-t. This adds the label TODO to the start of the headline for you. The same command can be used to toggle the TODO to DONE when you complete the task. Use the command once again, and Org-mode removes DONE from the headline.
TODO and DONE are the standard work-flow states in Org-mode, but it's possible to configure your own work flow, either globally for all Org-mode files or a custom one for each file. For example, if you wanted to set up a custom work flow, such as TODO --> TEST --> DONE, add the following to the top of your Org file:
#+SEQ_TODO: TODO TEST DONE
Priorities
Once you create tasks, you will need to prioritize them. Org-mode supports three priority levels: A, B and C. A is the highest priority. Priority for a task can be set by adding [#A] to a headline. The command C-c also can be used to set priorities. Figure 9 shows an example of a task list using tags, a custom to-do work flow and priorities.
Figure 9. Tags, Custom To-Do Work Flow and Priorities
Tags, custom work flows and priorities, make Org-mode flexible enough for many different uses. It's easy to develop a custom organization system that suits a project. Each Org file can use a different system.
Timestamps
To associate an event or a meeting with a date in Org-mode, use a plain timestamp. You can insert a plain timestamp in headlines or the body of an entry with C-c. You also can specify date ranges. Org-mode provides special timestamps useful for scheduling and tracking tasks. To set a reminder to start working on an entry on a certain date, precede the timestamp with the label SCHEDULED. If an entry is to be completed by a certain date, precede the timestamp with the label DEADLINE. You also can use Org-mode for tracking time spent on each task. This is done by using the CLOCK label preceding the timestamp. Org-mode has keyboard commands to make it easy to insert timestamps and timestamp labels.
Example
Figure 10 shows a fictional example that illustrates some of Org-mode's planning and scheduling features. This Org file uses a custom to-do work flow, which is specified at the top of the file. Task are marked with work-flow states. Major project phases are outlined some with scheduled or deadline dates. Tags are used for marking activity type and team member responsibilities. Dates and times are marked for meetings. A clock timestamp is used to track time spent on a meeting. The “On-site Meetings” entry uses a date range because it spans multiple days. High and low priority markers help prioritize tasks. Folded away from view are the project proposal, meeting minutes, reports and a budget spreadsheet. Everything related to a project can be kept in one file.
Figure 10. Project Planning with Org-mode
Tag Searches
Since Org files can get large, Org-mode provides mechanisms to generate different views of an Org file showing only the information you are interested in. In Figure 10, if you want to search for all entries with the tag PAT, use the command C-c \ and type in PAT (Figure 11).
Figure 11. Tag Searches
Agenda Views
Org-mode's Agenda feature offers other views, such as a list of all to-do items or an agenda-like display of entries and their dates. First, you need to add your Org file to your Org agenda by using the command C-c [. Then, type C-c a to be presented with options for different views. For example, to see a to-do list of the fictional project shown in Figure 10, type C-c a t (Figure 12). You also can generate views based on tags (Figure 13).
Figure 12. Agenda To-Do List
Figure 13. Agenda Tag List
Exporting and Publishing
Org-mode files are readable, and you can copy and paste the text directly from the Org file into e-mail messages or other documents. You also can export from Org-mode to other file formats. To export an Org file to a formatted ASCII text file with a contents page and automatically numbered headings, use the command M-x org-export-as-ascii. Org-mode generates a file with the same name as the Org file, but with a .txt extension. To export as HTML, use the command M-x org-export-as-html, and Org-mode creates a file with a .html extension. The HTML version will have a hyperlinked contents page, numbered headings, formatted tables, hyperlinks and images, if any (Figure 14).
Figure 14. Org File Exported to HTML Format
Conclusion
I have covered only some of the features Org-mode offers using a single Org file as an example, but there is more to Org-mode. You can maintain multiple Org files and generate agenda views or to-do lists across Org files. Entries can be archived. Org-mode also includes a publishing system to generate a set of interlinked HTML files automatically and upload them to a server. Much of Org-mode's behavior can be customized. Org-mode builds on top of Emacs' core features. It also provides hooks to interact with other Emacs modes and packages. It also can be used to implement David Allen's “Getting Things Done” method for personal productivity (see Resources). I find Org-mode invaluable for taking notes, planning projects, tracking tasks and organizing ideas.
Using only plain-text for writing, organizing, planning, and scheduling may appear to be a quixotic goal. Org-mode meets the challenge and delivers a practical, intuitive, and elegant solution.
Resources
Emacs Wiki: www.emacswiki.org
GNU Emacs: www.gnu.org/software/emacs
Org-mode Web Site: orgmode.org
Chua, S., 2005, “Taming the TODO”, Linux Journal: www.linuxjournal.com/article/8378
Cave, C., 2006, “Using Emacs org-mode for GTD”: members.optusnet.com.au/~charles57/GTD/orgmode.html
Curley, C., 2002, “Getting Started with Emacs”, Linux Journal: www.linuxjournal.com/article/6242
Curley, C., 2004, “Intermediate Emacs Hacking”, Linux Journal: www.linuxjournal.com/article/6771
Dominik, C., 2006, “Re: Another GTD Question”, Gmane: article.gmane.org/gmane.emacs.orgmode/715
Pedersen, J., 2000, “Emacs Macros and the Power-Macros Package”, Linux Journal: www.linuxjournal.com/article/3769
Welsh, M., 1994, “Emacs: Friend or Foe”, Linux Journal: www.linuxjournal.com/article/2801
Abhijeet Chavan is the Chief Technology Officer of Urban Insight, an Internet consulting firm (urbaninsight.com). He also is the cofounder and co-editor of Planetizen (planetizen.com). He wrote this article using Org-mode.

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,537 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2011-04-03T22:13:49+08:00
====== 介绍2 ======
Created Sunday 03 April 2011
Emacs org mode学习笔记
http://emacser.com/org-mode.htm
1 参考文献
2 用Org Mode做笔记
2.1 想法与配置
2.2 常用的编辑
3 用Org Mode管理个人事务
3.1 关于TODO ITEM的基本知识和操作
3.2 标签
3.3 时间和日期
3.4 我的TODO LIST解决方案
===== 1 参考文献 =====
本文参考并引用了以下的文章的部分内容。
Yu Peng的Emacs的Org Mode
Emacs org Mode的官方参考文档
===== 2 用Org Mode做笔记 =====
==== 2.1 想法与配置 ====
以前一直都用Emacs Wiki Mode记笔记,但wiki mode总有些奇奇怪怪的bug,并且已经不更新了,最近org mode 非常火爆,禁不住想试一下。
对于记笔记,我的打算很简单,一个目录用来装所有的笔记,一个目录用来存放publish成HTML格式的笔记。并且能够**自动生成索引文件**。这样就可以在索引文件里直接查找并跳转到所有的笔记里。
Emacs ORG mode的基本配置如下:
(setq load-path (cons "~/lib/emacs-lisp/org-7.01h/lisp" load-path))
(setq load-path (cons "~/lib/emacs-lisp/org-7.01h/contrib/lisp" load-path))
(require 'org-install)
(require 'org-publish)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-hook 'org-mode-hook 'turn-on-font-lock)
(add-hook 'org-mode-hook
(lambda () (setq truncate-lines nil)))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
上面基本上是从ORG-mode的文档里抄来的,其中包含setq truncate-lines nil的两行代码是为了解决org-mode在编辑中文的时候不会自动折行的问题。
接下来的配置基本照抄了meteor1113@newsmth的用org代替muse记日记 , 修改的部分就是我不想让它自动生成index文件,我比较喜欢自己组织。
(setq org-publish-project-alist
'(("note-org"
:base-directory "C:/Documents and Settings/caole/My Documents/My Dropbox/emacs/org/org"
:publishing-directory "C:/Documents and Settings/caole/My Documents/My Dropbox/emacs/org/publish"
:base-extension "org"
:recursive t
:publishing-function org-publish-org-to-html
:auto-index nil
:index-filename "index.org"
:index-title "index"
:link-home "index.html"
:section-numbers nil
:style "<link rel=\"stylesheet\"
href=\"./style/emacs.css\"
type=\"text/css\"/>")
("note-static"
:base-directory "C:/Documents and Settings/caole/My Documents/My Dropbox/emacs/org/org"
:publishing-directory "C:/Documents and Settings/caole/My Documents/My Dropbox/emacs/org/publish"
:recursive t
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|swf\\|zip\\|gz\\|txt\\|el"
:publishing-function org-publish-attachment)
("note"
:components ("note-org" "note-static")
:author "caole82@gmail.com"
)))
值得注意的一个地方是,我把org和publish的目录都扔在了我的Dropbox中,这样可以方便的在不同的系统中同步笔记。有些人喜欢用SVN/GIT/CVS等版本管理工具,也是个不错的办法。但我没有地方搭这些东西的服务器:-(
这样写完了笔记就可以用M-x org-publish 发布了,我把它绑定到了F8-p上。
(global-set-key (kbd "<f8> p") 'org-publish)
为了在org mode中使用auto-complete,我在auto-complete中增加了这样的配置:
(setq ac-modes
(append ac-modes '(org-mode objc-mode jde-mode sql-mode
change-log-mode text-mode
makefile-gmake-mode makefile-bsdmake-mo
autoconf-mode makefile-automake-mode)))
==== 2.2 常用的编辑 ====
=== 结构化编辑 ===
== 标题 ==
一级标题是一个*,两级标题是两个*,三级标题…… 最多可以建10级标题。注意,这里的***必须在行首**。Publish之后会自**动生成目录链接**。在Emacs中S-Tab可以收起所有的目录树,在标题上按Tab可以展开/收起该标题下的所有内容。在标题上按__Alt+左右方向键__可以减少/增加该标题的级别。
== 枚举和列表 ==
在org mode中还支持__枚举__(unordered list),有序的列表(ordered list)和带描述的列表。
枚举可以用__’-',’+'__**,**或者非行首的__’*’__ 作为bullets.同时,可以用**开头的空格来区分枚举的层次结构**。
枚举1
枚举2
枚举3
枚举4
有序的列表可以由__’1.’__或__’1)’__来组织。这里可以方便的使用__Alt+左右方向键__调整列表项的级别。__M-Ret__可以在当前位置插入一个列表项;__C-Ret__可以在文档尾部插入一个列表项或者标题。
第一级
第二级
第二级第一点
第三级
带描述的列表效果是这样的:
Elijah Wood
He plays Frodo
Sean Austin
He plays Sam, Frodo’s friend. I still remember
在文档中是这样的:
- Elijah Wood :: He plays Frodo
- Sean Austin :: He plays Sam, Frodo’s friend. I still remember
__ 5个或以上的“-”是一个水平分割符。__
== 脚注 ==
org mode可以为文章添加脚注,脚注有如下两种方式:
blabla[1]
blablabla[fn:bla]
效果是这样的:
blabla1
blablabla2
接下来必须顶格写这些脚注的内容了,这样在文档的末尾会自动生成脚注。__C-c C-c__可以在脚注的标记与内容之间切换。__C-c C-x f__可以在当前位置添加一个脚注。
[1] 12345
[fn:bla] 67890
== 结构化编辑的常用快捷方式 ==
这里是Structure Editing的默认快捷方式:
next/previous heading C-c C-n/p
next/previous heading, same level C-c C-f/b
backward to higher level heading C-c C-u
jump to another place in document C-c C-j
previous/next plain list item S-UP/DOWN
insert new heading/item at current level M-RET
insert new heading after subtree C-RET
insert new TODO entry/checkbox item M-S-RET
insert TODO entry/ckbx after subtree C-S-RET
turn (head)line into item, cycle item type C-c -
turn item/line into headline C-c *
promote/demote heading M-LEFT/RIGHT
promote/demote current subtree M-S-LEFT/RIGHT
move subtree/list item up/down M-S-UP/DOWN
sort subtree/region/plain-list C-c ^
clone a subtree C-c C-x c
refile subtree C-c C-w
kill/copy subtree C-c C-x C-w/M-w
yank subtree C-c C-x C-y or C-y
narrow buffer to subtree / widen C-x n s/w
=== 富文本编辑 ===
== 表格 ==
最基本的表格是这样的:
| A | B |
| C | D |
效果是这样的:
A B
C D
还可以:
__ #+CAPTION: 表格的标题__
__ #+LABEL: tbl:table_label1__
| A | B |
|---+---|
| C | D |
在这里,CAPTION指定的是表格的标题,LABEL后的tbl用来指定在文档内部引用该表格的标签。
效果是:
ABCD A B
C D
__C-c RET__可以在光标所在表格内插入一行
== 这里是表格相关的常用快捷键: ==
convert region to table C-c
re-align the table without moving the cursor C-c C-c
re-align the table, move to next field TAB
move to previous field S-TAB
re-align the table, move to next row RET
move to beginning/end of field M-a/e
move the current column left M-LEFT/RIGHT
kill the current column M-S-LEFT
insert new column to left of cursor position M-S-RIGHT
move the current row up/down M-UP/DOWN
kill the current row or horizontal line M-S-UP
insert new row above the current row M-S-DOWN
insert hline below (C-u : above) current row C-c -
insert hline and move to line below it C-c RET
sort lines in region C-c ^
== 引用文字或代码 ==
我常用到的引用文字的标签是#+BEGIN_EXAMPLE / #+END_EXAMPLE ,在这之间的文字会保留原有的格式。
对于代码而言,可以用#+BEGIN_SRC SRC_TYPE / #+END_SRC,其中SRC_TYPE用来指定代码的类型,
如lisp, java, c, c++等。结合HTMLIZE可以让导出的HTML页面里的代码被按照语法着色。
为了保留引文的格式,还可以使用#+BEGIN_VERSE / #+END_VERSE 和#+BEGIN_QUOTE/ #+END_QUOTE.
将引文居中排版可以使用#+BEGIN_CENTER / #+END_CENTER.
== 引用图片 ==
用如下方法可以直接在文档内显示图片:
#+CAPTION: title for the image
#+LABEL: fig:tag_for_img
[[path/to/image.jpg]]
CAPTION用来指定图片的标题,LABEL用来在文档内部引用这张图片。和表格一样,这两部分都不是必须的。
== 插入链接或附件 ==
给文档添加附件非常简单,C-c C-a 然后就着菜单选好了,其中C-c C-a a是添加文件系统中的文件作为附件。
Org mode提供多种链接方式,包括链接到一个文件内部,链接到外部文件,电子邮件等等。
链接的格式:
链接主要是两种格式:
[link][description 或者 link
例如 SINA
如何访问链接:
在一个链接上按C-c C-o即可访问,至于调用什么程序访问,取决于链接的内容,emacs和org mode的配置了。
== 链接的类型 ==
如下都是可以支持的常用link类型:
http://www.sina.com Web
file:paper/lastdoc.pdf 本地文档,用相对路径表示
file:/path/to/filename 本地文档,用绝对路径表示
news:comp.emacs 新闻组
caole82@gmail.com 邮件地址
内部链接 Internal Link
内部链接就类似于HTML的锚点(实际上export成HTML文件后就变成了锚点),可以实现在一个文档内部的跳转。
如下命令定义了一个名为target的跳转目标:
#<<target>>
如下方式可以设置到target的链接:
target 或 [target][description]
== 其他常用链接命令 ==
C-c l 可以在光标所在处创建一个跳转目标点,在需要跳转至该目标的位置输入命令C-c C-l可以建立到目标的链接
当输入C-c C-l命令,光标若处在已经存在的一个链接上的时候,可以编辑改链接。
命令C-c %可以记录当前光标所在位置,当光标移到其他地方后,可以用C-c &跳转回来。这里的位置记录类似一个kill-ring,重复输入C-c %可以记录多个位置,重复输入C-c &可以连续跳转到之前记录的对应位置上。
===== 3 用Org Mode管理个人事务 =====
==== 3.1 关于TODO ITEM的基本知识和操作 ====
设置TODO项目
所有标题只要以TODO开头,就会变成
*** TODO 付手机费
*** TODO 开会
更改TODO项目的状态
C-c C-t Rotate the TODO state of the current item among
,-> (unmarked) -> TODO -> DONE --.
'--------------------------------'
C-c C-t是在定义的状态中循环,而C-u C-c C-t可以指定一个状态。
S-Right 和 S-Left也可以在定义的状态中循环。
C-c a t可以显示所有的TODO项目,能从所有agenda file里非DONE状态的TODO项目都显示出来
S-M RET可以在当前项目下插入一个新的TODO 项目(与当前项目同一级别)
更改TODO项目的优先级
以下方式可以设置TODO ITEM的优先级:
*** TODO [#A] 付手机费
C-c , 可以设置一个TODO项目的优先级
S-Up/Down 可以增减一个TODO项目的优先级
增加TODO Item的状态
默认情况下,TODO Item只有两种状态,TODO和DONE。我们可以在.emacs中配置Org,以设置更多的中间状态,例如:
用下面的方法,我们可以增加一个TODO Item的中间状态,这些状态是顺序的,通常是工作流中的不同状态。
(setq org-todo-keywords
'((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
另一种可能性是,每个TODO Item可能有不同的类型,例如,公司的TODO Item,家里的TODO Item。或者,我们可能把TODO Item分配给不同的人,因此我们可以自定义TODO keywords以表示一个TODO Item的不同类型。
(setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
有的时候我们可能对不同的TODO Item有不同的状态,例如,交手机费这类简单的事情只有TODO和DONE两种状态,但是对于解决一个程序的bug可能有REPORT, BUG, KNOWNCAUSE, FIXED等状态。这样我们需要定义不同的状态子集(subset):
(setq org-todo-keywords
'((sequence "TODO" "|" "DONE")
(sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
(sequence "|" "CANCELED")))
C-S-Right/Left可以从一个子集跳转到另一个子集,而S-RIGHT/LEFT会在所有状态之间遍历。
我们还可以用快捷键来迅速切换一个TODO Item的状态。
(setq org-todo-keywords
'((sequence "TODO(t)" "|" "DONE(d)")
(sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
(sequence "|" "CANCELED(c)")))
上面说的都是全局的设置,我们也可以针对一个文件进行设置,如:
#+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
(这里也可以用 #+SEQ_TODO,和#+TODO效果是一样的)
对于类型的设置:
#+TYP_TODO: Fred Sara Lucy Mike | DONE
对于多个子集的设置:
#+TODO: TODO | DONE
#+TODO: REPORT BUG KNOWNCAUSE | FIXED
#+TODO: | CANCELED
进度记录
最基本的就是记录当一个Item被标记为DONE时的时间戳了,另外,在一个Item完成后,可能会想要写点心得或者备注什么的,可以用如下配置实现:
(setq org-log-done 'time)
(setq org-log-done 'note)
Org Mode还能记录每个状态改变的时间,但恐怕不是所有人都需要这么精细的控制了。
把项目拆分成子项目
很简单,高一级的TODO下所有的低级TODO就是它的子项目,在各级TODO的标题的任意位置插入[/] 或者[%]即会根据其子项目的完成情况自动更新进度。
如果想要当所有子项目都标记为Done的时候,父项目也被标记为Done,可以在配置中添加如下设置:
(defun org-summary-todo (n-done n-not-done)
"Swith entry to DONE when all subentries are done, to TODO otherwise."
(let (org-log-done org-log-states) ; turn off logging.
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
另一种办法是,如果有大量的字项目,则可以使用check box来标记。
每一个item前只要加上一个[ ] 就变成了check box item, 这在TODO List Item里也是一样的。在TODO List里,C-c C-c可以切换check box item的选中与未选中的状态。
** TODO Test [1/3]
- [X] Only a test
- [ ] It's another test
- [ ] Third test
和Check Box Item相关的快捷键:
C-c C-c 切换Check Box的状态
M-S-Ret 插入新的check box item.
3.2 标签
标签的基本知识
其实标签并不仅限于TODO Item,而是可以用在任何标题上。标签可以由所有字母,数字,和@构成,标签必须有一个前导的:并且还必须有一个后继的:,比如,看起来是这样的,‘:work:’,多个标签可以用:分开,例如:‘:work:urgent:’。
需要用到的标签可以预先在配置文件里定义,和增加TODO Item的状态的方法一样,唯一的区别是这里用到的变量是org-tag-faces.
Tag是有继承性的,也就是说,假如一级标题的tag有work,则该级标题以下的所有子标题无论是否显式注明,都自动具有work的标签。例如:
* Meeting with sb. :work:
** Summary with sb1. :boss:notes:
*** TODO Prepare slides for him :action:
这里,Summary with sb1的标签就是work, boss, notes,最后一项的标签就是work, boss, notes, action.
设置标签
首先当然可以手动在标题后设置标签,键入:后,M-Tab自动提供标签的补齐。
也可以用命令插入标签:
C-c C-q 为当前标题插入标签
C-c C-c 当光标在某标题栏时,为该标题插入标签(此时和C-c C-q功能一样)
默认情况下,org会动态维护一个Tag列表,即当前输入的标签若不在列表中,则自动加入列表以供下次补齐使用。
另一种方式是在配置文件中配置变量org-tag-alist全局性地预设一些tag,然后在org文件中设置:
#+TAGS: @work @home @tennisclub
#+TAGS: laptop car pc sailboat
这样,在该文件中只能使用个以上定义的7个标签。
如果想既使用预设的标签,又动态增加,则必须在文件中增加一个空的TAGS option.
#+TAGS:
在org中我们还可以给tag定义快捷键。对于全局的定义可以写在配置文件中:
(setq org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("laptop" . ?l)))
这样要标记@work,@home,laptop就只需要按w, h, l键即可。如果不是全局的定义,即指针对一个文件有效,我们可以在文件中定义,其中,\n表示换行,等效于分开写在两个TAGS里。
#+TAGS: @work(w) @home(h) @tennisclub(t) \n laptop(l) pc(p)
假如我们要让@work, @home, @tennisclub变成互斥的,则可以定义:
#+TAGS: { @work(w) @home(h) @tennisclub(t) } laptop(l) pc(p)
这也可以在配置文件中定义,但需要用dummy tag :startgroup和:endgroup包围起来。
(setq org-tag-alist '((:startgroup . nil)
("@work" . ?w) ("@home" . ?h)
("@tennisclub" . ?t)
(:endgroup . nil)
("laptop" . ?l) ("pc" . ?p)))
C-c \ 可以用来查找某个tag下的所有项目
C-c / m 建立符合某tag的sparse tree
C-c a m 从所有agenda file里建立符合某tag的全局性列表
C-c a M 同上,但只检查TODO item或org-tags-match-list-sublevels里指定要检查的项目。
3.3 时间和日期
在TODO Item上我们通常还需要标记时间和日期,这里就包含了:
普通的时间和日期,比如该TODO ITEM的开始时间,例如下午三点开会等。
<2010-09-18 Sat 15:00>
每天,每周,每月,每年都重复的时间和日期,比如每周去一次健身房之类的。
* pick up Sam at school <2007-05-16 Wed 12:30 +1w>
表示一段时间
* 在上海开会 <2004-08-23 Mon>--<2004-08-26 Thu>
仅仅表示一段时间而已,不需要在其他模式中引用。(Inactive Timestamp)
* 今天吃饭吃到苍蝇了 [2010-09-28 Tue]
C-c > 打开Emacs Calendar
C-c < 把Emacs Calendar光标所在的日期插入到org mode光标所在处。
C-c C-y 当光标放在time range上时,计算两个timestamp之间的天数。
C-c ! 用来添加一个inactive 的timestamp.
在我的配置文件中,我把C-c t 定义给了“插入一个timestamp”。
对于TODO item,我们常常需要指定什么时候开始这项工作,什么时候是截止日期,在org中分别是SCHEDULED 和DEADLINE.
*** TODO write article about the Earth for the Guide
The editor in charge is bbdb:Ford Prefect
DEADLINE: <2004-02-29 Sun>
*** TODO Call Trillian for a date on New Years Eve.
SCHEDULED: <2004-12-25 Sat>
C-c C-d 插入一个Deadline
C-c C-s 插入一个Schedule
C-c / d 建立一个包含所有deadline的TODO项目的sparse tree
C-c / b 建立一个包含deadline在指定日期前的TODO项目的sparse tree
C-c / a 建立一个包含deadline在指定日期后的TODO项目的sparse tree
3.4 我的TODO LIST解决方案
我的TODO List方案基本上是在常规的待办事项上加上一些的GTD思想。
作为一个IT民工,我的生活比较简单,我不在家就在公司,两者都不在就基本在路上。因此我的TODO 项目的地点基本就是这三项。另外,有些项目需要用到电脑,有些不需要,有些都可以(比如看某本既有电子版又有纸版的书)。
下面列出了我用到的标签,TODO Item的中间状态很简单,就是TODO:未开始;INPROGRESS:进行中;和DONE:已完成。根据GTD的思想,有些TODO Item是2分钟内即可完成的,我把它们标记为immediately,立刻完成。wait是需要等待其他人或其他资源的;action是随时可以开始做的项目。
#+TODO: TODO INPROGRESS | DONE
#+TAGS: @office(o) @home(h) @traffic(t)
#+TAGS: computer(c) nocomputer(n) either(e)
#+TAGS: immediately(i) wait(w) action(a)
根据简化的GTD思想,TODO的项目分为Idea List; Task List; Project List; Someday/Maybe List; Reminder这五项。Reminder这一项和前四个关系不大,我用来记录一些备忘录,诸如下周末前要还房贷,某月某日是结婚纪念日之类的。这类提醒很多人喜欢记在Agenda里头,或者日历里。我更愿意直接写成条目放在Reminder里,每天看一下,这主要是因为我需要记住的事情不算太多,不需要用到Agenda。
每天抽两个时间做一下所谓的Mind Sweep,把所有想到可能要做的事情都扔进Idea List里头。每天抽一个时间整理一下Idea List,把不可能实现的直接删掉,把将来可能会做的,但现在肯定不做的扔到Someday/Maybe List中。Task List用于放一步即可完成的项目,Project List用于放比较复杂的项目,可能需要细分为许多个TODO Item,或者可能需要合作才能完成。
* Idea List:
* Task List:
* Project List:
* Someday/Maybe List:
* Reminder:
这样,举个例子,每天到公司或者到家开始工作的时候,首先要做的是三步:
按照GTD的说法是清空大脑,把脑子里的所有想法都列出来,然后放到Idea List。
用C-c \ 查询标签为@office或者@home 的未完成项目
浏览一下Reminder 里有没有和今天相关的事情。
然后,在每天结束工作的时候清理一下 Idea List。
ORG Mode我主要的用处就是拿来记笔记和做Todo List,似乎它还有很多其他功能,等我需要的时候再去研究吧。

View File

@@ -0,0 +1,247 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2011-09-22T19:59:38+08:00
====== 使用org-mode来GTD(1)— 入门 ======
Created Thursday 22 September 2011
http://www.yifeiyang.net/using-the-org-mode-for-gtd-1-getting-started/
使用org-mode来GTD(1)— 入门
GTD,org-mode概要
GTD(Getting Things Done)是美国的商业顾问David Allen提倡的一种提高生产效率的时间管理系统。利用GTD可以缓解压力,专心地工作,学习。详细可以参考他的两部书《尽管去做:无压工作的艺术》,《结果第一:平衡工作和生活的52条原则》。
Org-Mode是为Emacs编写的个人信息管理以及编写大纲的工具。因为Emacs强大的特性,用其来实践GTD系统是再方便不过的了。这里我将介绍一些org-mode的特性。需要深入了解的可以看这里。
操作方法
收集
调用 remember-mode (C-c r)
选择 Todo(GTD)或者是 notes
选择情境标签(OFFICE, HOME, READING, DVD, etc...)
选择Todo的状态(TODO, STARTED, WAITING, etc...)
设置任务结束时间(C-c C-d)
设置任务的开始时间(C-c C-s)
每天的操作
首先确认当天的任务
确认当天所有的任务 (C-c a d)
利用情境确认当天的预定任务 (C-c a h)
在时间轴上确认任务 (C-c a L)
任务由 TODO 状态转换为 DONE 状态 (C-c C-t 或者 shift+左右)
如果有新的预定使用 remember-mode (F8) 来添加任务
周回顾
打开 org 文件 (C-c g)
检查 INBOX 中积攒的任务
选择合适的项目分类 (C-c C-w)
设置任务的结束时间 (C-c C-d)
设置任务的开始时间(C-c C-s)
org-mode 的设置
org-mode的设置可以在 .emacs 中设置,也可以在 org 文件中设置。
先看看 org-mode 所需要的文件。
~/.emacs
~/elisp/org-mode.el
~/org/gtd.org
~/org/notes.grg
~/org/someday.org
~/org/birthday.org
首先是在 ~/.emacs 文件中加载 org-mode.el。其中文件位于 ~/elisp/org-mode.el。
(load "org-mode")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(auto-raise-tool-bar-buttons t t)
'(auto-resize-tool-bars t t)
'(calendar-week-start-day 1)
'(case-fold-search t)
'(org-agenda-files (quote ("~/org/birthday.org" "~/org/gtd.org")))
'(org-agenda-ndays 7)
'(org-agenda-repeating-timestamp-show-all nil)
'(org-agenda-restore-windows-after-quit t)
'(org-agenda-show-all-dates t)
'(org-agenda-skip-deadline-if-done t)
'(org-agenda-skip-scheduled-if-done t)
'(org-agenda-sorting-strategy (quote ((agenda time-up priority-down tag-up) (todo tag-up))))
'(org-agenda-start-on-weekday nil)
;; '(org-agenda-todo-ignore-deadlines t)
;; '(org-agenda-todo-ignore-scheduled t)
;; '(org-agenda-todo-ignore-with-date t)
'(org-agenda-window-setup (quote other-window))
'(org-deadline-warning-days 7)
'(org-export-html-style "<link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">")
'(org-fast-tag-selection-single-key nil)
'(org-log-done (quote (done)))
'(org-refile-targets (quote (("gtd.org" :maxlevel . 1) ("someday.org" :level . 1))))
'(org-reverse-note-order nil)
'(org-tags-column -78)
'(org-tags-match-list-sublevels nil)
'(org-time-stamp-rounding-minutes 5)
'(org-use-fast-todo-selection t)
'(org-use-tag-inheritance nil)
'(unify-8859-on-encoding-mode t nil (ucs-tables)))
;; These lines only if org-mode is not part of the X/Emacs distribution.
(autoload 'org-mode "org" "Org mode" t)
(autoload 'org-diary "org" "Diary entries from Org mode")
(autoload 'org-agenda "org" "Multi-file agenda from Org mode" t)
(autoload 'org-store-link "org" "Store a link to the current location" t)
(autoload 'orgtbl-mode "org" "Org tables as a minor mode" t)
(autoload 'turn-on-orgtbl "org" "Org tables as a minor mode")
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
;(setq org-log-done nil)
(setq org-log-done t)
(setq org-agenda-include-diary nil)
(setq org-deadline-warning-days 7)
(setq org-timeline-show-empty-dates t)
(setq org-insert-mode-line-in-empty-file t)
(require 'org-install)
(autoload 'remember "remember" nil t)
(autoload 'remember-region "remember" nil t)
(setq org-directory "~/org/")
(setq org-default-notes-file "~/org/notes.org")
(setq remember-annotation-functions '(org-remember-annotation))
(setq remember-handler-functions '(org-remember-handler))
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(define-key global-map "\C-cr" 'org-remember)
(setq org-remember-templates
'(
("Todo" ?t "* TODO %^{任务} %^g\n%?\nAdded: %U" "~/org/gtd.org" "INBOX")
("Note" ?n "\n* %U %^{笔记} %^g \n%i%?\n %a" "~/org/notes.org")
))
(setq org-agenda-exporter-settings
'((ps-number-of-columns 1)
(ps-landscape-mode t)
(htmlize-output-type 'css)))
(setq org-agenda-custom-commands
'(
("p" "Projects"
((tags "PROJECT")))
("h" "Office and Home Lists"
((agenda)
(tags-todo "OFFICE")
(tags-todo "HOME")
(tags-todo "WEB")
(tags-todo "CALL")
))
("d" "Daily Action List"
(
(agenda "" ((org-agenda-ndays 1)
(org-agenda-sorting-strategy
(quote ((agenda time-up priority-down tag-up) )))
(org-deadline-warning-days 0)
))))))
(setq org-todo-keywords '((sequence "TODO" "APPT" "STARTED" "DONE")))
(defun gtd ()
(interactive)
(find-file "~/org/gtd.org"))
(global-set-key (kbd "C-c g") 'gtd)
(add-hook 'org-agenda-mode-hook 'hl-line-mode)
org 文件的设置 ::
~/org/gtd.rog
#+STARTUP: showall
* INBOX
#+CATEGORY: INBOX
* Research
#+CATEGORY: Research
* Project A
#+CATEGORY: Project A
* Private
#+CATEGORY: Private
* Archive
#+CATEGORY: Archive
* org-mode configuration
#+STARTUP: hidestars
#+STARTUP: logdone
#+PROPERTY: Effort_ALL 0:10 0:20 0:30 1:00 2:00 4:00 6:00 8:00
#+COLUMNS: %38ITEM(Details) %TAGS(Context) %7TODO(To Do) %5Effort(Time){:} %6CLOCKSUM{Total}
#+PROPERTY: Effort_ALL 0 0:10 0:20 0:30 1:00 2:00 3:00 4:00 8:00
#+TAGS: { OFFICE(o) HOME(h) WEB(w) DOWNTOWN(d) CALL(c) }
#+TAGS: PROJECT(p) READING(r)
#+TODO: TODO(t) STARTED(s) WAITING(w) APPT(a) | DONE(d) CANCELLED(c) DEFERRED(f)
~/org/notes.org
#+STARTUP: showall
#+STARTUP: hidestars
#+TAGS: OFFICE(o) RESEARCH(r) DIARY(d) BOOK(b) FILMS(f) IDEA(i) WEB(w) COMPUTER(c)
* 笔记
** [2010-02-02 星期二 18:53] 今天写博 使用org-mode来GTD(1) :OFFICE:
~/org/someday.org
也许某天会做的事。
#+STARTUP: showall
* Someday
** 计算机升级。
** 去马尔代夫旅游。
~/org/birthday.org
这里记录预先决定的日常安排。比如生日节假日。
与其他设备无缝连接
使用Emacs的tramp1可以无缝地访问远程的设备。同样也可以连接 org-mode 的文件。下面是在HOST机器上设置 org-mode 与tramp关联的方法。
比如下面设置的地方
1
"~/org/foo.org"
替换为
1
"/domain-name/org/foo.org"
如果是 Windows 的 NTEmacs 为:
1
"/plink:domain-name/org/foo.org"
1. TRAMP 代表”Transparent Remote (file) Access, Multiple Protocol”,他是 Emacs 的一个用于远程文件编辑的扩展包。用来访问scp/ssh/smb服务器上的文件,可以做到像读写本地文件一样编辑远程的文件。