# Organize you life in Emacs Org

## 1 introduction

Using spacemacs I divide my Org config into servel private layers for the sake of easy maintenance and flexibility. You can check my .spacemacs.d on github. I suggest you excerpt some of my config instead of copying all of them because some of them maybe not what you want.

Based on the comprehensive tutorial Organize Your Life In Plain Text, I build my own GTD system using Org. Actually, there exists quite a few posts on building personal GTD system through Emacs Org. Some excellent ones are listed as below:

1. Organize Your Life In Plain Text . This article is the starting point of my serious using of Emacs Org as GTD tool. It is quite long, but deserves spending time to read it. It pays off. Furthermore, reading just one time is not enough. Perhaps you will visit this post several times before your GTD system is handy.
2. Using org-mode as a Day Planner . This article describe how the author replace pen-and-paper day planner with the Emacs Org. After trying many software available, the author choose Emacs Org.
3. How I use Emacs and Org-mode to implement GTD . The author’s job is developing classroom training materials and E-Learning solutions for a software company based in North Sydney. It’s also worthwhile to give the article a shot.

I am not interested in listing all the articles. What I want to say is that you need to define your need first. After that you can excerpt the config from other’s implement. Most of the time you will modify other’s config before Org is handy for you. So some knowledge of Elisp is desirable.

## 2 My GTD workflow

First let me introduce my GTD workflow. In general, a task in my GTD workflow will go the road shown as below whick is the same as show in Organize Your Life In Plain Text but with different triggering conditions:

The main features are listed below.

1. Every moment, for the sake of clearing my head, I capture all the ideas or some todos jumping into my head during my handling one event. I will handle the capture later.
2. Every morning, I check the my agenda which is generated by a combination of ten commends.
4. After the scheduled one and the deadlined one, I take a NEXT task, which is in NEXT status. Also, I start a clock under such task.
5. After finishing the NEXT tasks, the NEXT status will be changed to DONE automatically. Then I pick a new task in the TODO lists and change the TODO status into NEXT. Everytime I change a TODO task into a NEXT task, clock is running under that task automatically.
6. After finishing all the TODO tasks, I check the DONE list to see if there is any tasks need to be archived.

## 3 some preparations

In order to run the GTD, some preparations are needed.

### 3.1 set the agenda file

To use Org as a GTD tool, the first thing is to setup the org-agenda-files ;

;;set up the agenda files
(setq org-agenda-files (list "~/zorg/Dropbox/base/zlife.org"
"~/zorg/Dropbox/base/zwork.org"
"~/zorg/Dropbox/base/zrefile.org"
"~/zorg/Dropbox/base/zdiary.org"
"~/zorg/Dropbox/base/ztimelog.org"))


As you can see, I put my configs into the Dropbox directory, so that my config will never lose even if I delete them from the local carelessly.

Notice that there is a file named “zrefile.org” which is the entrance of all my todos and some other captures. It plays as an inbox. Everytime I check this file and take actions to clean it. All this can be done in the agenda buffer, which I will explain later. To refile the items in the refile.org, I need to set up the refile targets.

### 3.2 set the refile targets

(setq org-refile-targets (quote (
("~/zorg/Dropbox/base/zwork.org" :maxlevel . 6)
("~/zorg/Dropbox/base/zlife.org" :maxlevel . 6)
("~/zorg/zcl.space/content_org/math.org" :maxlevel . 6)
("~/zorg/zcl.space/content_org/computer.org" :maxlevel . 6)
("~/zorg/zcl.space/content_org/telecommunication.org" :maxlevel . 6)
("~/zorg/zcl.space/content_org/life.org" :maxlevel . 6)
("~/zorg/zcl.space/content_org/tools.org" :maxlevel . 6))))


Notice that, besides the zwork.org and zlife.org which are the agenda files, there are other five org files. These five org files are for my personal blog. Sometime, I capture a draft or outline of a new post in the zrefile.org, so I need to refile these drafts into the right category.

To understand why I add these extra five org files as the refile targets, you need to see my org-capture-templates

### 3.3 set the org capture templates

(setq org-capture-templates
'(
("t" "todo" entry (file "~/zorg/Dropbox/base/zrefile.org")
"* TODO %? :TODO: \n Added:%T\n"
:clock-in t :clock-resume t)
("h" "Hugo post")
("hm" "Math"
entry (file+olp "~/zorg/zcl.space/content_org/math.org" "Math")
(function org-hugo-new-subtree-post-capture-template)
":math:"
:clock-in t :clock-resume t)
("hc" "Computer"
entry (file+olp "~/zorg/zcl.space/content_org/computer.org" "Computer")
(function org-hugo-new-subtree-post-capture-template)
:clock-in t :clock-resume t)
("ht" "Telecommunication"
entry (file+olp "~/zorg/zcl.space/content_org/telecommunication.org" "Telecommunication")
(function org-hugo-new-subtree-post-capture-template)
:clock-in t :clock-resume t)
("hl" "Life"
entry (file+olp "~/zorg/zcl.space/content_org/life.org" "Life")
(function org-hugo-new-subtree-post-capture-template)
:clock-in t :clock-resume t)
("ho" "Tools"
entry (file+olp "~/zorg/zcl.space/content_org/tools.org" "Tools")
(function org-hugo-new-subtree-post-capture-template)
:clock-in t :clock-resume t)
("hm" "movie"
entry (file+olp "~/zorg/zcl.space/content_org/all-posts.org" "Movie")
(function org-hugo-new-subtree-post-capture-template)
:clock-in t :clock-resume t)
("hl" "life"
entry (file+olp "~/zorg/zcl.space/content_org/all-posts.org" "Life")
(function org-hugo-new-subtree-post-capture-template)
:clock-in t :clock-resume t)
("l" "my Log Time" entry (file+datetree "~/zorg/Dropbox/base/ztimelog.org" ) "** %T - %?  :timelog:" :clock-in t :clock-resume t)
("d" "diary" entry (file+datetree "~/zorg/Dropbox/base/zdiary.org" ) "* %t - %?  :diary:" :clock-in t :clock-resume t)
("x" "org-protocol" entry (file "~/zorg/Dropbox/base/zrefile.org")
"* TODO Review %c \n Added:%T\n")
))


I have a template for zrefile.org which is :

("t" "todo" entry (file "~/zorg/Dropbox/base/zrefile.org")
"* TODO %? :TODO: \n Added:%T\n"
:clock-in t :clock-resume t)


To understand the meaning of this template, you need to read the doc for variable org-capture-templates.

whenever I check the org-agenda, I will see a block contains all the need-to-refile tasks. So you may curious about my set of org-agenda-custom-commands

### 3.4 set the org agenda custom commands

(setq org-agenda-custom-commands
(quote (
(" " "Agenda"
((agenda "" )
(tags "NOTES"
(org-tags-match-list-sublevels nil)))
(tags "REFILE"
(org-tags-match-list-sublevels nil)))
(tags-todo "-CANCELLED/!"
(org-agenda-skip-function 'bh/skip-non-stuck-projects)
(org-agenda-sorting-strategy
'(priority-down category-keep))))
(tags-todo "-HOLD-CANCELLED/!"
(org-agenda-skip-function 'bh/skip-non-projects)
(org-agenda-sorting-strategy
'(priority-down category-keep))))
(tags-todo "-CANCELLED/!NEXT"
(org-tags-match-list-sublevels t)
(org-agenda-sorting-strategy
'(priority-down todo-state-down effort-up category-keep))))
(todo "TODO"
(org-tags-match-list-sublevels t)))
(todo "DONE"
(org-tags-match-list-sublevels t)))
;;;;(tags-todo "-CANCELLED+WAITING+HOLD/!"
(todo "HOLD"
(org-agenda-skip-function 'bh/skip-stuck-projects)
(org-tags-match-list-sublevels nil)
(org-agenda-todo-ignore-scheduled 'future)
(tags "-REFILE/"
(org-tags-match-list-sublevels nil))))
nil))))


You should never copy the above snippet, because there are some functions whose definitions are not contained in the snippet. Actually, you should go to my Github page to get the repository if you are interested in my .spacemacs.d

According to the command, one of the sample of my org agenda may look like:

I have three projects: math,computer and communication (telecommunication). For each projects, there are some tasks. All the projects appear as level-1 headlines in the org file and the tasks appear as sub-level headlines. If all the tasks under one project are in TODO state, the project is stuck. If at least one of the task under one project is in NEXT state, the project is running.

I think the structure of my agenda buffer is straightforward. you can define your own org-agenda-custom-commands by reading the manual and this post.

## 4 One day based on my workflow

### 4.1 Punch In

At the beginning of every day, I use F8 I to punch in, which starts a clock under a task called Organization:

(defvar bh/organization-task-id "eb155a82-92b2-4f25-a3c6-0304591af2f9")


### 4.2 check out the agenda

Check out the agenda, using org-agenda which is bound to SPC a o o SPC or SPC o a SPC or F5 SPC . Because the org-agenda buffer will be visited quite a few times, I bind this command to several shortcuts. Using the customed command SPC , I collect all the projects, tasks with TODO and NEXT states in the project which give me an overview of what should be done next and what should be started next.

As we can see from the screenshot, the agenda of today is listed at the beginning with scheduled task and deadline task.

Following today’s agenda, several blocks are displayed with each headline in green color and large font size. Those blocks shows:

1. Notes to Refile, which is the draft of a post which should be refile to math.org computer.org or telecommunication.org.
3. Stuck Projects, which are the projects have no sub-tasks in NEXT state.
4. Projects, which are the projects have at least one sub-tasks in NEXT state.
5. Project Next Tasks, which are NEXT sub-tasks in all Projects. In particular, you can filter out the NEXT tasks belonging to certain project.
6. Project Subtasks TODO, which are all the TODO sub-tasks belonging to all projects.
7. Project Subtasks DONE, which are all the DONE sub-tasks belonging to all projects.
8. Waiting and Postponed Tasks, which are all the tasks in WAITING and HOLD state.
9. Tasks to Archive, which are the tasks being tagged as DONE for a period and need to be archived.

### 4.3 focus on certain project

If you have many TODO tasks, it is desirable to focus on certain project at one time. Just move the cursor on the Project you want to focus, then press ^ . If you want to focus on another project, press ^ again then select another project, press ^.

Actually, there are quite a few commands helping you coin your own view of the agenda buffer. some handy are listed below:

Table 1: some handy agenda commands
shortcuts command description
/ org-agenda-filter-by-tag Filter the agenda view with respect to a tag
< org-agenda-filter-by-category Filter the current agenda view with respect to the category of the item at point
^ org-agenda-filter-by-top-headline Filter the current agenda view and only display the siblings and the parent headline of the one at point
= org-agenda-filter-by-regexp Filter the agenda view by a regular expression
_ org-agenda-filter-by-effort filter the agenda view with respect to effort estimates

You can find more agenda commands by reading Agenda views part of the Org manual which is built in the Emacs.

### 4.4 change the state of one task

It is quite easy to change the state of one task. By default, the state is in TODO state. After start clocking the task, the task will be in NEXT state automatically.

From NEXT to other state, you just use C-c C-t . If you are in the org agenda buffer, press t one the line of the task.

Once the task is set as DONE , a temporary buffer will jump out and let you take some note to record the task.

### 4.5 using the mobile phone to take capture

In general, there are two app one is Org-mobile and the another one is BeOrg. I prefer to the later because of is easy to use. All you have to do is put your agenda files in a Dropbox directory.

Org-mobile is kind of complex, and need to config both on the phone and the PC. I finally make it run on both my iPhone and Surface pro 4. However, I resort to BeOrg because you will never forget how to use BeOrg . Unfortunately, I forget how to use Org-mobile after I did not use it for a month.

## 5 conclusion

My GTD workflow based on Org is summarized. To be honest, I change my workflow quite often. So the configuration will change subsequently which is the source of joy using Emacs. You can always config it as handy as possible.