learning-org.org (10571B)
1 #+TITLE: Learning org mode 2 #+AUTHOR: Shivakumar 3 #+EMAIL: shivakumar AT disroot DOT org 4 #+DATE: <2026-10-08 Thu> 5 6 This is *bold text*. And this is /italics/. 7 For underlines you have to, well _underline_. 8 For links we have to use [[]], like this [[https://example.com][example]]. 9 Unordered lists start with '*', '+' or '-'. 10 Ordered lists start with '1.' or '1)'. 11 12 * FUNDAMENTAL 13 #+BEGIN_SRC org 14 * TOP LEVEL HEADING 15 ** Second level heading 16 some text under second level heading. 17 *** Third level heading 18 some text under third level heading. 19 * ANOTHER TOP LEVEL HEADING 20 #+END_SRC 21 This is *bold text*. And this is /italics/. 22 For underlines you have to, well _underline_. 23 For links we have to use [[]], like this [[https://example.com][example]]. 24 * LISTS EXAMPLE 25 Unordered lists start with '*', '+' or '-'. 26 Ordered lists start with '1.' or '1)'. 27 28 For example: 29 #+BEGIN_EXAMPLE 30 * List of things on my table 31 My table is messy rn. But, we'll ignore it. 32 1. My laptop 33 2. My mobile phone 34 3. Misc 35 + My wallet 36 + Lot of instant coffee sackets 37 + Sunscreen, etc 38 Things to keep in mind: 39 - My wallet :: Actually a card holder. 40 - Instant coffee :: 3-in-1 instant coffee. 41 #+END_EXAMPLE 42 * TABLES 43 Org mode supports tables. 44 45 example: 46 | slno | Name | Phone | 47 |------+------------+--------| 48 | 1 | Shivakumar | 123456 | 49 | 2 | Tanaya | 654321 | 50 51 'C-c |' to create a table. 52 * HYPERLINKS 53 'C-c C-l' to insert any type of links. 54 55 *** Internal Links 56 If you want to link something from the current document. We use ~‘[[*headline][description]]’~ like this [[*External Links][External Links]]. 57 58 *** External Links 59 Org supports differnt types links like links to file, links to website, etc. For more information refer [[info:orgguide#Hyperlinks][info "(orgguide) Hyperlinks"]]. 60 61 To go to more specific section of a file we use double colon '::'. 62 Like this: 63 'file:~/code/main.c::255' 64 * TODO's 65 Any headline becomes a TODO item when it starts with the word ‘TODO’. 66 67 To toggle Todo we have to 'C-c C-t'. It also cycles: 68 #+begin_src 69 ,-> (unmarked) -> TODO -> DONE --. 70 '--------------------------------' 71 #+END_SRC 72 We can also move through the cycle with S-<RIGHT/LEFT>. 73 74 example: 75 *** TODO This is an example 76 77 ‘M-x org-agenda t’ (‘org-todo-list’) to track all global TODO's in one buffer. 78 ‘S-M-<RET>’ (‘org-insert-todo-heading’) to insert TODO just below. 79 80 To add todo in the current file we use this '#+TODO: TODO(t) | DONE(d)' 81 82 *** Progress logging 83 ‘C-u C-c C-t’ (‘org-todo’) to log the time with the TODO. 84 85 *** Tasks to subtasks 86 Breaking down tasks to subtasks is done as follows: 87 88 example: 89 #+BEGIN_SRC org 90 * Organize Party [33%] 91 ** TODO Call people [1/2] 92 *** TODO Peter 93 *** DONE Sarah 94 ** TODO Buy food 95 ** DONE Talk to neighbor 96 #+END_SRC 97 Add [%] or [/] to these to track the cookies, and can be updated with ‘C-c C-c’. 98 99 *** Checkboxes 100 Checkboxes are done by adding [ ] infront of the TODO. But, checkboxes won't be seen in the global TODO list. 101 102 ‘C-c C-c’, ‘C-u C-c C-c’ (‘org-toggle-checkbox’) to toggle checkboxes. 103 * TAGS 104 Tags are labels added to headlines to refer and cross-corelate information. 105 106 Tags must be wrapped with colon (::). 107 example: ‘:work:’ 108 109 ** Tag inheritance 110 Tags are hierarchical structures of outline trees. i.e. if the heading contains the tag then the subheadings will contain the same parent tag. 111 112 example: 113 #+BEGIN_SRC org 114 * Meeting with the French group :work: 115 ** Summary by Frank :boss:notes: 116 *** TODO Prepare slides for him :action: 117 #+END_SRC 118 119 120 In here the TODO heading will contain ‘work’, ‘boss’, ‘notes’, and ‘action’. 121 122 To make sure all entires in the current file should inherit certain tags, we need to set: 123 124 #+FILETAGS: :all:entires:contains:these:tags 125 126 ** Setting tags 127 M-<TAB> offers completion for the tags. To insert a Tag we need to: 128 129 ‘C-c C-q’ (‘org-set-tags-command’) 130 ‘C-c C-c’ (‘org-set-tags-command’) 131 when the point is in a headline, it does the same as the above command. 132 133 We can set default tags for a given file using the ‘TAGS’ keyword, like 134 135 #+TAGS: @work @home @boom 136 #+TAGS: laptop car pc sailboat 137 ** Tag groups 138 you can add a group tag by using brackets and inserting a colon in between the tag and the related item. 139 140 example: 141 #+TAGS: [ group : tag1 tag2 ] 142 #+TAGS: { group : @tag1 @tag2 } 143 ** Tag search 144 ‘C-c / m’ or ‘C-c \’ (‘org-match-sparse-tree’) 145 Creates a sparse tree with all headlines matching a tag search. 146 147 Refer to [[info:orgguide#Tag searches][info "(orgguide)#Tag searches"]]. 148 * PROPERTIES 149 Properties are key-value pairs associated with an entry. They live in a special drawer with the name ‘PROPERTIES’. 150 151 example: 152 * Some headline 153 ** Some sub-headline 154 :PROPERTIES: 155 :Title: Leanring org mode 156 :Author: Shivakumar 157 :Key: Value 158 :END: 159 160 If we want to define allowed values for a particular property ‘XYZ’, we have to append ~‘_ALL’~ to it, hence it becomes ~‘XYZ_ALL’~. And if we want all the entires to inherit the some property we have to set it in the root level. Like this: 161 162 #+PROPERTY: XYZ_ALL 1 2 3 4 163 164 To set a property we use this command: 165 ‘C-c C-x p’ (‘org-set-property’) 166 167 And, to remove a property we use: 168 ‘C-c C-c d’ (‘org-delete-property’) 169 * DATES AND TIME 170 We can use timestamps in multiple things like planning, in TODO’s, schedule tasks, set deadlines, track time, and more. 171 172 ** Timestamps 173 A simple timestamp can be applied to an item by assigning date/time to it. 174 175 example: 176 * Some headline 177 <2026-09-05 > 178 179 The above is a plain timestamp. 180 181 Timestamps with a repeater interval: 182 183 example: 184 * Gotta do some task 185 <2007-05-16 Wed 12:30 +1w> 186 187 For more formats refer [[info:orgguide#Timestamps][info "(orgguide)#Timestamps"]]. 188 ** Creating timestamps 189 ‘C-c .’ (‘org-timestamp’) 190 To create a timestamp. When the point is a existing timestamp it would modify the timestamp. 191 192 ‘C-c !’ (‘org-timestamp-inactive’) 193 Creates an inactive timestamp, i.e. it won’t be added in the agenda entry. 194 195 For more info refer [[info:orgguide#Creating Timestamps][info "(orgguide)#Creating Timestamps"]]. 196 ** Deadlines and Scheduling 197 198 ‘C-c C-d’ (‘org-deadline’) 199 To insert a deadline to the task. 200 201 example: 202 *** TODO Do some task 203 DEADLINE: <2026-09-21 Mon> 204 205 ‘C-c C-s’ (‘org-schedule’) 206 Ditto, but for schedule. 207 ** Clocking Work Time 208 Org mode allows you to clock the time you spend on specific tasks in a project. 209 210 For commands refer [[info:orgguide#Clocking Work Time][info "(orgguide)#Clocking Work Time"]]. 211 * TODO Capture, Refile, Archive 212 ** Capture 213 Captures lets you quickly jot down or /capture/ the ideas or interruptions of your workflow. Its like quick note. You can define templates for your captures. 214 215 To set up capture refer [[info:orgguide#Setting up capture][info "(orgguide)#Setting up capture"]]. 216 217 ‘M-x org-capture’ (‘org-capture’) 218 This command lets you create and note down the capture. You will be narrowed buffer to edit. 219 220 ‘C-c C-c’ (‘org-capture-finalize’) 221 This command is to lets you finilize the noting down the buffer. This lets you confirm the edit you were noting down and then resume the work without any further distraction. 222 223 ‘C-c C-k’ (‘org-capture-kill’) 224 Abort the capture process and return to the previous state. 225 ** Capture templates 226 You can use templates to capture different types of capture items, and to different capture locations. You can set this for general TODO tasks. etc. 227 228 For more info refer [[info:orgguide#Capture templates][info "(orgguide)#Capture templates"]] 229 * TODO ... 230 * WORKING WITH SOURCE CODE 231 Org mode lets you include source code. 232 233 A source code block conforms to this structure: 234 #+BEGIN_VERSE 235 #+NAME: <name> 236 ~#+BEGIN_SRC~ <language> <switches> <header arguments> 237 <body> 238 ~#+END_SRC~ 239 #+END_VERSE 240 241 For more info refer [[info:orgguide#Working with Source Code][Info "orgguide(#Working with Source Code)"]] 242 243 Use ‘C-c '’ to edit the current source code block. 244 245 ** Header arguments 246 A header argument is specified with an initial colon followed by the argument's name in lowercase. 247 248 249 - System-wide header arguments :: 250 Those are specified by customizing ‘org-babel-default-header-args’ variable. 251 252 - Header arguments in properties :: 253 You can set them using ‘header-args’ property or ‘header-args:LANG’ for language LANG. 254 255 - Header arguments in code blocks :: 256 Header arguments are most commonly set at the source code block level, on the ~‘BEGIN_SRC’~ line: 257 258 #+BEGIN_VERSE 259 #+NAME: factorial 260 ~#+BEGIN_SRC~ haskell :results silent :exports code :var n=0 261 fac 0 = 1 262 fac n = n * fac (n-1) 263 ~#+END_SRC~ 264 #+END_VERSE 265 Code block header arguments can span multiple lines using ‘HEADER’ keyword on each line. 266 ** Evaluating code blocks 267 Use ‘C-c C-c’ to evaluate the current code block and then insert the results in the same org document. 268 269 example: 270 #+NAME: Example 271 #+BEGIN_SRC emacs-lisp :exports both :eval no-export 272 (+ 2 2 2) 273 #+END_SRC 274 275 Output: 276 #+RESULTS: Example 277 : 6 278 279 We can use this as an replacement for jupyter notebooks, cause jupyter is heavy and bloated. 280 281 Python example: 282 #+NAME: Python example 283 #+BEGIN_SRC python :results output :exports both :eval no-export 284 def main(): 285 print("This is run from org!") 286 287 if __name__ == "__main__": 288 main() 289 #+END_SRC 290 291 Output: 292 #+RESULTS: Python example 293 : This is run from org! 294 295 ** Result of Evaluation 296 Org handles the results of the code snippet by the headers given to it. The primary determinant, however, is the ‘results’ header argument. It controls the _collection_, _type_, _format_, and _handling_ of code block results. 297 298 - Collection :: 299 How the result should be collected from the code block. 300 - Type :: 301 What result type to except from the execution of the code block. You may choose among ‘table’, ‘list’, ‘scalar’, and ‘file’. 302 - Format :: 303 How org processes the result. It can be ‘code’, ‘drawer’, ‘html’, etc. 304 - Handling :: 305 How to insert the result once formated. Allowed values are ‘silent’, ‘replace’ (default), ‘append’ and ‘prepend’. 306 ** Exporting code blocks 307 It is possible to export the _code_ of the code block, the result of the code block execution. 308 ** Extracting source code 309 Use ‘C-c C-v t’ to create pure source code files by extracting code from source blocks in the current buffer.