Org-Grimoire
Table of Contents
- 1. Introduction
- 2. How to use this Guide
- 3. Org fixing - all the small things that need tweaking
- 4. What do I need.
- 5. Agenda Files
- 6. TODO s
- 7. Tags
- 8. Categories
- 9. Stuck Projects
- 10. Habits
- 11. Refiling
- 12. Better Linking
- 13. Capturing and Capture Templates
- 14. Pomodoro
- 15. Diary
- 16. Attachments
- 17. Agenda
- 17.1. Basic customizations
- 17.2. Tweak the look
- 17.3. Display a cool title
- 17.4. Display a cool subtitle with Kawaii
- 17.5. Display Goals at the top of agenda
- 17.6. Display the current cycles
- 17.7. Specific agenda frame
- 17.8. Display the current context
- 17.9. Display based on tags
- 17.10. Find Stuck projects
- 17.11. Finalize agenda
- 17.12. Make it convenient
- 17.13. Display the daily agenda on load
- 18. Exports
- 19. Plotting
- 20. Working with Code in Babel mode
- 21. Saving and auto Commiting
- 22. Prettiness
- 23. References and Shoutouts
1 Introduction
Trying to keep my org-mode setup inside of the Emagicians Starter Kit was getting too insane. On top of that I declared org-bankruptcy awhile ago, and haven't really recovered since. And so, here is a fresh new attempt at using org. Along with it will be a tutorial that anyone can follow along with and get themselves into a better state.
2 How to use this Guide
Not sure yet. Wait till it is written.
3 Org fixing - all the small things that need tweaking
3.1 Saveplace
(defun emagician-org/fix-saveplace ()
"Fixes a bit of brokenness with saveplace.el and org-mode"
(when (outline-invisible-p)
(save-excursion
(outline-previous-visible-heading 1)
(org-show-subtree))))
(add-hook 'org-mode-hook 'emagician-org/fix-saveplace)
3.2 Turn on flyspell
(add-hook 'org-mode-hook 'flyspell-mode)
3.3 Fix YAS
The latest version of yasnippet doesn't play well with Org mode. If the above code does not fix the conflict, start by defining the following function:
(defun yas/org-very-safe-expand ()
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
Then, tell Org mode what to do with the new function:
(emagician/defhook fix-yasnippet-for-org org-mode-hook
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
(define-key yas/keymap [tab] 'yas/next-field))
4 What do I need.
- Basic Todo Listing and entry
- Grouping of tasks under a project
- Tasks Have states: TODO, NEXT, WAITING and DONE.
- Show all Next Actions
- Grouping of tasks under a project
- Pomodoro
- Timers
- Journaling and time management
- Prompt for when tasks change state
- show time spent on a task.
- Habits For Review
- Agendas
- Quick access to org files
- Sane attachment handling (link to, not copy)
5 Agenda Files
(setq org-agenda-files '("~/org/" "~/Dropbox/arduino/BunnyCyborg/BunnyCyborg.org" "~/Dropbox/Creativity/Site3.0/Site.org"))
6 TODO s
6.1 Start with states.
Simple GTD States.
(setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "STARTED(g)" "|" "DONE(d@/!)")
(sequence "PROJECT(p)" "|" "FINISHED(f)")
(sequence "SOMEDAY(s)" "MAYBE(m)")
(sequence "WAITING(w@/!)")
))
6.2 Enable fast selection of TODO states
Fast selection is good! But not on tags.
(setq org-fast-tag-selection-include-todo nil)
6.3 Log state changes into a drawer
(setq org-log-into-drawer t)
6.4 Faces
A better looking org mode looks better.
(setq org-todo-keyword-faces
`(("TODO" :foreground "red"
:background "red4" :weight bold :box (:line-width 2 :color "red3" :style released-button))
("PROJECT" :foreground "cyan" :background "cyan4" :weight bold :box (:line-width 2 :color "cyan3" :style released-button))
("HABIT" :foreground "DodgerBlue4" :background "DodgerBlue2" :weight bold :box (:line-width 2 :color "DodgerBlue2" :style released-button))
("NEXT" :foreground "DodgerBlue4" :background "DodgerBlue2" :weight bold :box (:line-width 2 :color "DodgerBlue2" :style released-button))
("STARTED" :foreground "blue" :background "blue4" :weight bold :box (:line-width 2 :color "blue3" :style released-button))
("DONE" :foreground "chartreuse"
:background "chartreuse4" :weight bold :box (:line-width 2 :color "chartreuse3" :style released-button))
("FINISHED" :foreground "SeaGreen1"
:background "SeaGreen4" :weight bold :box (:line-width 2 :color "SeaGreen3" :style released-button))
("WAITING" :foreground "orange"
:background "orange4" :weight bold :box (:line-width 2 :color "orange3" :style released-button))
("SOMEDAY" :foreground "purple1"
:background "purple4" :weight bold :box (:line-width 2 :color "purple3" :style released-button))))
6.5 Set as next action
(defun emagician-org/todo-to-next ()
"sets the todo state of the current headline to next."
(interactive)
(org-todo "NEXT")
(org-set-tags))
(eval-after-load 'org
'(define-key org-mode-map (kbd "C-c n") 'emagician-org/todo-to-next))
6.6 GO!
(defun emagician-org/go ()
"Launches the task at point, and starts a pomodoro if required"
(interactive)
(if (org-entry-is-todo-p)
(progn
(org-todo "STARTED")
(if (not (org-pomodoro-active-p))
(org-pomodoro-start)
(progn
(when (org-clocking-p)
(org-clock-out nil t))
(org-pomodoro-kill))))
(warn "Not on a TODO task")))
(eval-after-load 'org '(define-key org-mode-map (kbd "C-c g") 'emagician-org/go))
7 Tags
7.1 Tags are a fluid thing
So list em all!
(require 'dash)
(defun emagician/get-tag-counts ()
"Thanks to John Kitchin for this"
(let ((all-tags '()))
(org-map-entries
(lambda ()
(let ((tag-string (car (last (org-heading-components)))))
(when tag-string
(setq all-tags
(append all-tags (split-string tag-string ":" t))))))
t
'agenda)
;; now get counts
(loop for tag in (-uniq all-tags)
collect (cons tag (cl-count tag all-tags :test 'string=)))))
7.2 Display
(setq org-tags-column -100)
(setq org-agenda-tags-column -100)
7.3 Tags for contexts
(emagician/get-tag-counts)
7.4 State selection etc
(setq org-use-fast-tag-selection t)
7.5 Preset tags
(setq org-tag-alist '((:startgroup . nil)
("code" . ?c)
("design" . ?d)
("emacs" . ?e)
("gtd" . ?g)
(:endgroup . nil)
(:startgroup . nil)
("decide" . ?a)
("phone" . ?p)
("read" . ?r)
("research" . ?u)
("talk" . ?t)
("vm" . ?v)
("web" . ?w)
("write" . ?x)
(:endgroup . nil)
("backburner" . ?b)
("braindead" . ?z)
(:newline . nil)
("chaman" . ?C)
("charles" . ?H)
("paul" . ?P)
("sohan" . ?S)
))
8 Categories
Work, Music, Personal. That's it. Everything else should be a tag.
8.1 Icons
(setq org-agenda-category-icon-alist
`(("Work" ,(list (propertize "💼")))
("Music" ,(list (propertize "🎶" )))
("Home" ,(list (propertize"🏡" )))))
9 Stuck Projects
(setq org-stuck-projects '("TODO=\"PROJECT\""
("NEXT")
nil ""))
10 Habits
(require 'org-habit)
(setq org-habit-graph-column 50)
(add-to-list 'org-todo-keywords '(sequence "HABIT(h)" "|" "DONE(d!)") t)
10.1 Example of my weekly Review habit
` ** HABIT Weekly
` SCHEDULED: <2015-02-09 Mon 09:00 ++1w>
` :PROPERTIES:
` :STYLE: habit
` :LAST_REPEAT: [2015-02-02 Mon 16:39]
` :END:
` - [X] Get Clear
` - [X] Clean off desk
` - [X] Clean Out Bag
` - [X] Clean off Desktop file:~/Desktop/ (~20 files per iteration)
` - [X] Clean Downloads file:~/Downloads/ (~20 files per iteration)
` - [X] Review Last weeks email
` - [X] Liquid Planner Timesheet good to go
` - [X] Clean out Inbox
` - [X] Archive all finished Tasks
` - [-] Get Current
` - [X] Review next months calendar
` - [X] Check My upcoming work in LP
` - [ ] Fix Any Stuck Projects
` - [ ] Review Project Agenda
` - [ ] Review Next Action Agenda
` - [ ] Review Waiting Agenda
` - [ ] Get Creative
` - [ ] Review someday/maybe
` - [ ] Do something creative and courageous
`
11 Refiling
All agenda files are valid for targeting
(setq org-refile-targets '((org-agenda-files :maxlevel . 1)))
(setq org-refile-use-outline-path 'file)
(setq org-outline-path-complete-in-steps nil)
12 Better Linking
12.1 Set keybinding for links keybinding
(setq org-return-follows-link t)
(define-key global-map "\C-cl" 'org-store-link)
(setq org-return-follows-link t)
12.2 Store info pages as links
(require 'org-info)
13 Capturing and Capture Templates
(define-key global-map (kbd "C-c c") 'org-capture)
(define-key global-map (kbd "C-c i") 'emagician-org-capture-inbox)
(defun emagician-org-capture-inbox ()
(interactive)
(org-capture nil "i"))
(setq org-capture-templates
'(("i" "Inbox" entry (file+headline "~/org/GTD.org" "Inbox")
"** TODO %?\n %i\n")))
14 Pomodoro
org-pomodoro is pretty simple, so lets start with that.
C-c p
Will start a pomodoro on your current task. Call it during a pomodoro to reset.
(use-package org-pomodoro
:bind
("C-c p" . org-pomodoro))
Fancy it up a little
(setq org-pomodoro-format "🍅~%s")
15 Diary
15.1 Set Location
(setq diary-file "~/.emacs.d/diary")
15.1.1 Like actual location too, so sunrise/sunset is handled well
51.0368334,-114.0715046,15z
(setq calendar-longitude -114.0715046)
(setq calendar-latitude 51.0368334)
15.2 Include it in agenda
(setq org-agenda-include-diary t)
15.3 Now for warnings
(appt-activate 1)
(org-agenda-to-appt)
16 Attachments
(setq org-attach-allow-inheritance t)
(setq org-attach-store-link-p t)
17 Agenda
17.1 Basic customizations
17.1.1 Dim Tasks
(setq org-agenda-dim-blocked-tasks t)
17.2 Tweak the look
(setq org-agenda-block-separator ?\═)
17.3 Display a cool title
(defun emagician-agenda/insert-title (title)
"show a centered title"
(setq buffer-read-only nil)
(let ((centering-str (make-string (/ (- (window-body-width)
(length title))
2)
?\ )))
(insert (propertize (concat centering-str title centering-str "\n")
'face
'org-agenda-structure))))
(defun emagician-agenda/insert-separator ()
(insert (make-string (window-body-width) org-agenda-block-separator) "\n"))
(defun emagician-agenda/insert-headline (&rest args)
"Daily wisdom, Cool title, etc."
(setq buffer-read-only nil)
(emagician-agenda/insert-separator)
(emagician-agenda/insert-title "-|-+-|-")
(emagician-agenda/insert-separator)
(insert (concat (emagician/cookie-from-file "assets/collected-works-ov-chaos.lines") "\n")))
17.4 Display a cool subtitle with Kawaii
17.5 Display Goals at the top of agenda
(defun emagician-agenda/get-goals (&rest args)
"Show top level goal headlines"
'(tags "goal" ((org-agenda-overriding-header "Goals")) "~/org/Goals.org"))
17.6 Display the current cycles
17.6.1 Lunar Phase
(require 'lunar)
(setq lunar-phase-names
'("🌚 New Moon 🌚" "🌛 First Quarter🌛" "🌝 Full Moon 🌝" "🌜Last Quarter 🌜"))
(defun emagician-agenda/get-current-lunar-phase ()
"Get the current lunar phase. For some reason it is out of sync by a day, so... yea"
(lunar-phase-name (mod (+ 1 (lunar-index (calendar-current-date)))
4)))
17.6.2 Solar Calendar
(require 'solar)
;; Half works. Kinda.
(defun diary-equinoxes-solstices (date)
"Equinox and solstice diary entry."
(let* ((displayed-month (car date))
(displayed-year (car (cdr (cdr date))))
(equinox (solar-equinoxes-solstices)))
(if (calendar-date-equal (car (car equinox)) date)
(car (cdr (car equinox))))))
17.6.3 TODO Erisian Calendar
17.6.4 TODO 8 Wheel Spoke
17.6.5 Cycle Display
(defun emagician-agenda/insert-cycle (&rest args)
(let ((buffer-read-only nil))
(insert (emagician-agenda/get-current-lunar-phase))
(insert "\n")
(emagician-agenda/insert-separator)))
17.7 Specific agenda frame
(setq org-agenda-window-setup 'other-frame)
17.8 Display the current context
(defvar emagician/org-context "Work")
17.8.1 TODO Get context from Location
17.9 Display based on tags
Best is the enemy of the good. Make this not suck later.
(defun emagician-agenda/get-tag (tag title &optional include-dates)
(if (not include-dates)
`(todo ,tag
((org-agenda-overriding-header ,(concat title "\n"))
(org-agenda-todo-ignore-with-date t)))
`(todo ,tag
((org-agenda-overriding-header ,(concat title "\n"))))))
(emagician-agenda/get-tag "NEXT" "❇ Next Actions" t)
(todo "NEXT" ((org-agenda-overriding-header "❇ Next Actions") (org-agenda-todo-ignore-with-date t)))
17.10 Find Stuck projects
(defun emagician-agenda/get-stuck-projects ()
"return a string showing all Stuck projects"
'(tags "TODO=\"PROJECT\""
((org-agenda-overriding-header " 📖 Stuck Projects")
(org-agenda-skip-function '(org-agenda-skip-subtree-if 'regexp "NEXT")))))
17.11 Finalize agenda
17.11.1 set up a custom agenda with our sections
(setq org-agenda-custom-commands
`((" " "Agenda"
((emagician-agenda/insert-headline "")
,(emagician-agenda/get-goals "")
(emagician-agenda/insert-cycle "")
(agenda "" ((org-agenda-span 1) (org-agenda-show-log nil) ))
,(emagician-agenda/get-tag "STARTED" "💥 Started" t)
,(emagician-agenda/get-tag "WAITING" "💬 Waiting" t)
,(emagician-agenda/get-tag "NEXT" "❇ Next Actions" t)
,(emagician-agenda/get-stuck-projects))
((org-agenda-category-filter-preset '("-Home" "-Music"))))
("W" "Weekly Review"
((emagician-agenda/insert-headline " Weekly Review ")
(agenda "" ((org-agenda-span 7)
(org-agenda-log-mode-items '(closed clock state))
(org-agenda-start-day "-7d")
(org-agenda-entry-type '(:timestamp :sexp :deadline :sheduled))
(org-agenda-show-log t)))
(tags-todo "inbox")
(agenda "" ((org-agenda-span 31)))
,(emagician-agenda/get-stuck-projects)
,(emagician-agenda/get-tag "PROJECT" "📖 Projects")
,(emagician-agenda/get-tag "FINISHED" "📘 Finished ($ to archive)")
,(emagician-agenda/get-tag "NEXT" "❇ Next Actions")
,(emagician-agenda/get-tag "TODO" "🌱 TODO")
,(emagician-agenda/get-tag "WAITING" "💬 Waiting")
,(emagician-agenda/get-tag "FINISHED" "📘 Finished ($ to archive)")
,(emagician-agenda/get-tag "SOMEDAY" "🌞 Someday")
,(emagician-agenda/get-tag "MAYBE" "🌠 Maybe")
))))
17.11.2 Display the started action
17.11.3 Display next actions for the context
17.11.4 PROJECT List all next actions on a keystroke (F4)
17.11.4.1 NEXT Org agenda command
17.11.4.2 TODO filter to work
17.12 Make it convenient
17.12.1 Function to show the main agenda
(defun emagician-org/daily-agenda ()
"Show the daily agenda"
(interactive)
(org-agenda nil " "))
17.12.2 Main agenda key
(global-set-key (kbd "C-c a") 'emagician-org/daily-agenda)
(global-set-key (kbd "C-c A") 'org-agenda)
17.13 Display the daily agenda on load
This is temporarily deactivated. Loading my agenda currently takes a long time.
(emagician/defhook open-agenda-and-swap-to-other-frame emacs-startup-hook
(emagician-org/daily-agenda)
(other-frame 1))
18 Exports
(require 'ox-beamer)
18.1 Htmlize
(use-package htmlize)
19 Plotting
(use-package gnuplot)
20 Working with Code in Babel mode
(setq org-src-tab-acts-natively t)
(setq org-src-fontify-natively t)
(setq org-edit-src-content-indentation 0)
20.1 Languages
(require 'ob-shell)
(require 'ob-sql)
(require 'ob-org)
(org-babel-do-load-languages
'org-babel-load-languages
'((shell . t)
(sql . t)
(emacs-lisp . t)
(org . t)
))
21 Saving and auto Commiting
(defun emagician-org/save-commit-and-push ()
"Do the thing automagickally"
(message "Autosaving buffers")
(org-save-all-org-buffers)
(with-helm-default-directory "~/org"
(async-start
(lambda ()
(message "Commiting to git")
(shell-command "git add *" "*org autocommit*" "*org autocommit*"))
(lambda (result)
(async-start
(lambda ()
(shell-command "git commit -m\"autpmagick commit\"" "*org autocommit*" "*org autocommit*"))
'ignore)))))
(run-at-time t 600 'emagician-org/save-commit-and-push)
21.0.1 TODO fix this to use shell commands instead.
21.0.2 Mobile Org
(setq org-mobile-directory "~/Dropbox/org-mobile")
22 Prettiness
(defun turn-on-org-show-all-inline-images ()
(org-display-inline-images t t))
(add-hook 'org-mode-hook 'turn-on-org-show-all-inline-images)
23 References and Shoutouts
- http://home.fnal.gov/~neilsen/notebook/orgExamples/org-examples.html A set of really good examples in cookbook form. 👍
- http://fgiasson.com/blog/index.php/2016/06/21/optimal-emacs-settings-for-org-mode-for-literate-programming/ Blog post about making org-mode work well with clojure.