Merge branch 'master' of ssh://repo.or.cz/srv/git/Worg
[Worg.git] / org-tutorials / org-column-view-tutorial.org
blobef48285ce4e715ae439f70c4c902bb0bba84d3cc
1 #+TITLE:     Emacs Org's Column View 
2 #+AUTHOR:    Bastien Guerry
3 #+EMAIL:     bzg@altern.org
4 #+SEQ_TODO:  TODO DONE
5 #+OPTIONS:   H:3 num:t toc:t 
6 #+LANGUAGE:  en
7 #+OPTIONS:   H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil f:t *:t TeX:t LaTeX:t skip:nil p:nil
9 [[file:../index.org][{Back to Worg's index}]]
11 A short introduction to Org's column view @<br/>
12 By [[mailto:bzg%20AT%20altern%20DOT%20org][Bastien Guerry]] - 15/10/2007
14 Please check the [[file:org-column-screencast.org][screencast]] demonstrating some of the possibilities I'm
15 discussing here. 
17 Also note that the column view feature is not available for Org < 5.01,
18 Hence this feature is not in Emacs 22.1 (which comes with Org 4.67c.)
19 Since Org is actively developed, it's always a good idea to upgrade to
20 the [[http://www.legito.net/#sec-2][latest version]].
22 * Introduction: the default column view
24 First press =C-c C-x C-c= to show the default column view.  It turns
25 each outline item into a table row displaying some of its properties.
27 [[file:../images/org-col-default-view.png][file:../images/thumbs/org-col-default-view.png]]
29 You can switch the column view /off/ and return to the normal view by
30 pressing `q' while the cursor is on the highlighted entry -- but you can
31 turn the column view /on/ from any location in the buffer.
33 The first headline is now a row of /browsable columns/ displaying
34 properties. The first highlighted line of the buffer briefly tells you
35 what property is displayed in each columns.  In this screenshot it
36 reads:
38 : ITEM for the headline title) 
39 :   T for the TODO keyword  
40 :   P for the priority cookie
41 :   T for the tags
43 The default column only shows the item, the TODO state, the priority of
44 the item and its tags, we will see later how to add other properties of
45 your own.
47 This default setup is driven by the variable
48 =org-columns-default-format=, which global value is:
50 : #+COLUMNS: %25ITEM %TODO %3PRIORITY %TAGS
52 | Element    | Description                                     |
53 |------------+-------------------------------------------------|
54 | %25ITEM    | display the item in a 25-characters-width field |
55 | %TODO      | display the TODO state of the item              |
56 | %3PRIORITY | display the priority in a 3-chars-width field   |
57 | %TAGS      | display the tags of the entry                   |
59 * Slight customization of the default column view
61 Okay, so now we'd like to customize the column display.  
63 For example, we'd like to change the /width/ of the "priority" field and
64 the "tags" field in the column:
66 : #+COLUMNS: %25ITEM %5TODO %1PRIORITY %10TAGS
68 [[file:../images/org-col-default-customized-view1.png][file:../images/thumbs/org-col-default-customized-view1.png]]
71 The TODO field (=%5TODO=) is now 5 characters wide, whereas the priority
72 and the tags fields are 1 and 10.
74 Now we'd like to change the /title/ of the columns.  For example -- and
75 since we are such *hardworkers* -- each so-called item is in fact... a
76 "task" :
78 : #+COLUMNS: %25ITEM(Task) %5TODO(To-do) %1PRIORITY %10TAGS
80 [[file:../images/org-col-default-customized-view2.png][file:../images/thumbs/org-col-default-customized-view2.png]]
82 We also add a "To-do" label for displaying the TODO state for this
83 entry.
85 * Displaying other properties
87 What if you want to display *other properties* in the column view? For
88 example, we'd like to display the =SCHEDULED= property. Then we need to
89 redefine the global #+COLUMNS option like this:
91 : #+COLUMNS: %30ITEM %10SCHEDULED %TODO %3PRIORITY %TAGS
93 Refresh your Org buffer to take this change into account, then =C-c C-x
94 C-c= again on the entry.  The column now shows the =SCHEDULED= property.
96 [[file:../images/org-col-default-customized-view3.png][file:../images/thumbs/org-col-default-customized-view3.png]]
98 : ** Exemple of outline item with a SCHEDULED property
99 :    SCHEDULED: <2007-10-14 dim>
101 What is the list of available properties?  Here it is:
103 : ITEM         The content of the headline.
104 : TODO         The TODO keyword of the entry.
105 : TAGS         The tags defined directly in the headline.
106 : ALLTAGS      All tags, including inherited ones.
107 : PRIORITY     The priority of the entry, a string with a single letter.
108 : DEADLINE     The deadline time string, without the angular brackets.
109 : SCHEDULED    The scheduling time stamp, without the angular brackets.
111 These are all *special properties*, but of course you can define your
112 own properties.
114 Before going to the rather complex stuff you can do with your own
115 properties, we'd like to know how to use different column views for
116 different subtrees.
118 * Defining a column format for a subtree
120 To define a colum view for a specific item, just add the special
121 property =:COLUMNS:= to it:
123 : ** Top node for columns view
124 :    :PROPERTIES:
125 :    :COLUMNS:  %25ITEM %TAGS %PRIORITY %TODO
126 :    :END:
128 This view will be used for the entry and its entire subtree -- unless
129 some of its children has its own column view.
131 See for example this:
133 : ** Top node for columns view
134 :    :PROPERTIES:
135 :    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
136 :    :END:
137 : *** TODO Example 1
138 : *** TODO Example 2
139 : *** DONE Example 3
141 [[file:../images/org-col-default-customized-view4.png][file:../images/thumbs/org-col-default-customized-view4.png]]
143 Good.
145 But what if you suddenly prefer =%TAGS= to be at the right of =%TODO=?
146 Put the cursor in the =%TAGS= field and press =M-<right>=, it will move
147 the field to the right.
149 What if you want to make a field larger?  No problem.  Just go to that
150 field and press `>' to widen the field (or `<' to narrow it.)
152 If you want to interactively define the column element of a property, go
153 the its field and press `s'.
155 So now that we know how to customize the column view for each entry,
156 it's time to play with user-defined properties.
158 * Adding summary-types for some properties
160 Let's define a new entry with its own column view and a few properties:
162 : ** My project 
163 :    :PROPERTIES:
164 :    :COLUMNS:  %20ITEM %9Approved(Approved?){X} %Owner %11Status %10Time_Spent{:}
165 :    :END:
167 [[file:../images/org-col-default-customized-view5.png][file:../images/thumbs/org-col-default-customized-view5.png]]
169 Let's comment this a bit.
171 We have a =:COLUMNS:= property, defining the column view. It says:
173 | Element                  | Description                                     |
174 |--------------------------+-------------------------------------------------|
175 | %20ITEM                  | display the item (20 characters for this field) |
176 | %9Approved(Approved?){X} | display the "Approved" property                 |
177 | %Owner                   | display the "Owner" property                    |
178 | %11Status                | display the "Status" property                   |
179 | %10Time_Spent{:}         | display the "Time_spent" property               |
181 What are ={X}= and ={:}=?  
183 It defines *summary-types*.
185 ={X}= means: display =[X]= if all entries have a =[X]= value for their
186 "Approved" property (=[-]= or =[ ]= otherwise).
188 ={:}= means: display a summary of the time spend, by adding all the time
189 values found in the property "Time_Spent".
191 Once you get the =:COLUMN:= property defined, you can interactively add
192 any property with =C-c C-x p=.  It will prompt you for the name of the
193 property, and offer default possible values depending on the =_ALL=
194 friend of the property (if any) or on the values found in the buffer.
196 * Defining all the possible values for a property
198 Defining summary-types implies that you need to have a limited set of
199 possible values for certain properties.
201 For example, the "Approved" value discussed above should take only two
202 values: =[ ]= and =[X]=.
204 Same for the "Status" property: you might want to define only a few
205 status like "In progress" "Not started yet" "Finished".
207 You can restrict the allowed values for any property using the =_ALL=
208 suffix like this:
210 : ** My project 
211 :    :PROPERTIES:
212 :    :COLUMNS:  %20ITEM %9Approved(Approved?){X} %Owner %11Status %10Time_Spent{:}
213 :    :Owner_ALL:    Tammy Mark Karl Lisa Don
214 :    :Status_ALL:   "In progress" "Not started yet" "Finished" ""
215 :    :Approved_ALL: "[ ]" "[X]"
216 :    :END:
218 : | Owner_ALL    | only accept Tammy Mark Karl Lisa Don                   |
219 : | Status_ALL   | only accept "In progress" "Not started yet" "Finished" |
220 : | Approved_ALL | only accept "[ ]" "[X]"                                |
222 Note: =*_ALL= properties are meta-properties, defining rules on how to
223 use the properties themselves.
225 When you're in a field of the column, you can define all the possible
226 values for the associated property by pressing `a': it will prompt the
227 current set of allowed values and you will be able to edit it.
229 * Complete example with three items in the subtree
231 Here is a example on how the column view affect the display of an entry
232 and its subtree.  Take it and test it.
234 : ** My project 
235 :    :PROPERTIES:
236 :    :COLUMNS:  %20ITEM %9Approved(Approved?){X} %Owner %11Status %10Time_Spent{:}
237 :    :Owner_ALL:    Tammy Mark Karl Lisa Don
238 :    :Status_ALL:   "In progress" "Not started yet" "Finished" ""
239 :    :Approved_ALL: "[ ]" "[X]"
240 :    :END:
242 : *** Item 1
243 :     :PROPERTIES:
244 :     :Owner:    Tammy
245 :     :Time_spent:   1:45
246 :     :Status:   Finished
247 :     :END:
249 : *** Item 2
250 :     :PROPERTIES:
251 :     :Owner:    Tammy
252 :     :Status:   In progress
253 :     :Time_spent:   0:15
254 :     :END:
256 : *** Item 3
257 :     :PROPERTIES:
258 :     :Owner:    Lisa
259 :     :Status:   Not started yet
260 :     :Approved: [X]
261 :     :END:
263 * Editing properties from the column view
265 So far, so good.  But one great thing about the column view is that it
266 lets you access and edit any property very quickly.
268 See this:
270 : ** My project 
271 :    :PROPERTIES:
272 :    :COLUMNS:  %20ITEM %10Approved(Approved?){X} %Owner %11Status %10Time_Spent{:}
273 :    :Owner_ALL:    Tammy Mark Karl Lisa Don
274 :    :Status_ALL:   "In progress" "Not started yet" "Finished" ""
275 :    :Approved_ALL: "[ ]" "[X]"
276 :    :END:
278 Use =v= to display the field value in the minibuffer.
280 Use =e= to interactively select/edit the value.
282 Use =S-left/right= to cycle through the allowed values in a field.
284 Use =a= to edit the allowed values for this property.
286 Nice, isn't it?
288 * Conclusion: more to come
290 Okay, that's all for today. But let me drop two last hints to let you
291 explore column views further:
293 1. You can use the column view and cycle through visibility.
294 2. The column view also works in agenda buffers.
296 I guess this is already suggestive enough...
298 Enjoy!
300 - http://orgmode.org/
301 - http://orgmode.org/org.html#Column-view
302 - http://www.cognition.ens.fr/~guerry/bastien-org-mode.php
304 [[file:bastien-org-mode.org][Back to Bastien's org page]]