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.
Not sure yet. Wait till it is written.
(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)
(add-hook 'org-mode-hook 'flyspell-mode)
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))
- Basic Todo Listing and entry
- Grouping of tasks under a project
- Tasks Have states: TODO, NEXT, WAITING and DONE.
- Show all Next Actions
- 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)
(setq org-agenda-files '("~/org/" "~/Dropbox/arduino/BunnyCyborg/BunnyCyborg.org" "~/Dropbox/Creativity/Site3.0/Site.org"))
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@/!)")
))
Fast selection is good! But not on tags.
(setq org-fast-tag-selection-include-todo nil)
(setq org-log-into-drawer t)
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))))
(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))
(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))
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=)))))
(setq org-tags-column -100)
(setq org-agenda-tags-column -100)
(emagician/get-tag-counts)
(setq org-use-fast-tag-selection t)
(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)
))
Work, Music, Personal. That’s it. Everything else should be a tag.
(setq org-agenda-category-icon-alist
`(("Work" ,(list (propertize "💼")))
("Music" ,(list (propertize "🎶" )))
("Home" ,(list (propertize"🏡" )))))
(setq org-stuck-projects '("TODO=\"PROJECT\""
("NEXT")
nil ""))
(require 'org-habit)
(setq org-habit-graph-column 50)
(add-to-list 'org-todo-keywords '(sequence "HABIT(h)" "|" "DONE(d!)") t)
` ** 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 [[file:GTD.org::*Inbo˘x][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
`
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)
(setq org-return-follows-link t)
(define-key global-map "\C-cl" 'org-store-link)
(setq org-return-follows-link t)
(require 'org-info)
(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")))
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")
(setq diary-file "~/.emacs.d/diary")
51.0368334,-114.0715046,15z
(setq calendar-longitude -114.0715046)
(setq calendar-latitude 51.0368334)
(setq org-agenda-include-diary t)
(appt-activate 1)
(org-agenda-to-appt)
(setq org-attach-allow-inheritance t)
(setq org-attach-store-link-p t)
(setq org-agenda-dim-blocked-tasks t)
(setq org-agenda-block-separator ?\═)
(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")))
(defun emagician-agenda/get-goals (&rest args)
"Show top level goal headlines"
'(tags "goal" ((org-agenda-overriding-header "Goals")) "~/org/Goals.org"))
(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)))
(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))))))
(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)))
(setq org-agenda-window-setup 'other-frame)
(defvar emagician/org-context "Work")
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)))
(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")))))
(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")
))))
(defun emagician-org/daily-agenda ()
"Show the daily agenda"
(interactive)
(org-agenda nil " "))
(global-set-key (kbd "C-c a") 'emagician-org/daily-agenda)
(global-set-key (kbd "C-c A") 'org-agenda)
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))
(require 'ox-beamer)
(use-package htmlize)
(use-package gnuplot)
(setq org-src-tab-acts-natively t)
(setq org-src-fontify-natively t)
(setq org-edit-src-content-indentation 0)
(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)
))
(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)
(setq org-mobile-directory "~/Dropbox/org-mobile")
(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)
- 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.