aboutsummaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <msabate@suse.com>2017-01-03 13:40:47 +0100
committerMiquel Sabaté Solà <msabate@suse.com>2017-01-03 13:40:47 +0100
commit4609e14306d96bcdb973befd5a6d6b05929d1f4a (patch)
treecae55e9391cbf3ac90c8bdb47b95e9435c1a412a /emacs
parent93de554d5daa172b48f1e8d3a8dd2e2349f62528 (diff)
downloaddotfiles-4609e14306d96bcdb973befd5a6d6b05929d1f4a.tar.gz
dotfiles-4609e14306d96bcdb973befd5a6d6b05929d1f4a.zip
emacs: added a lot of stuff into org-mode
Mostly org-agenda stuff. Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'emacs')
-rw-r--r--emacs/settings/init-org.el127
1 files changed, 116 insertions, 11 deletions
diff --git a/emacs/settings/init-org.el b/emacs/settings/init-org.el
index c8cc808..8dd1154 100644
--- a/emacs/settings/init-org.el
+++ b/emacs/settings/init-org.el
@@ -20,7 +20,40 @@
(require 'org)
-;; TODO
+;; Helper functions.
+
+(defun mssola-org-skip-if-priority (priority &optional subtree)
+ "Skip an agenda item if it has a priority of PRIORITY.
+PRIORITY may be one of the characters ?A, ?B, or ?C.
+Skips the current entry unless SUBTREE is not nil. This function has been
+copied from @aaronbieber."
+
+ (let ((end (if subtree (save-excursion (org-end-of-subtree t))
+ (save-excursion (progn (outline-next-heading) (1- (point))))))
+ (pri-value (* 1000 (- org-lowest-priority priority)))
+ (pri-current (org-get-priority (thing-at-point 'line t))))
+ (if (= pri-value pri-current)
+ end
+ nil)))
+
+(defun mssola-org-skip-if-not-closed-in-day (time &optional subtree)
+ "Skip entries that were not closed in the given TIME.
+Skip the current entry unless SUBTREE is not nil, in which case skip
+the entire subtree. Idea taken from @aaronbieber"
+
+ (let ((end (if subtree (save-excursion (org-end-of-subtree t))
+ (save-excursion (progn (outline-next-heading) (1- (point))))))
+ (day-prefix (format-time-string "%Y-%m-%d" time)))
+
+ (if (save-excursion
+ (and (re-search-forward org-closed-time-regexp end t)
+ (string= (substring (match-string-no-properties 1) 0 10) day-prefix)))
+ nil
+ end)))
+
+;; General org config.
+
+;; TODO: wc mode in org-mode
(with-eval-after-load 'evil
; TODO: doesn't work
@@ -28,29 +61,101 @@
(fset 'help-command help-map))
; TODO: this might overlap some existing keybindings
-(global-set-key "\C-cl" 'org-store-link)
-(global-set-key "\C-ca" 'org-agenda)
-(global-set-key "\C-cb" 'org-iswitchb)
-(setq org-log-done t)
+;(global-set-key "\C-cl" 'org-store-link)
+;(global-set-key "\C-ca" 'org-agenda)
+;(global-set-key "\C-cb" 'org-iswitchb)
(setq org-todo-keywords
'((sequence "TODO(t)" "|" "DONE(d!)")
- (sequence "BUG(b)" "|" "RESOLVED(r@/!)" "WONTFIX(w@/!)" "FIXED(f@/!)")
(sequence "IDEA(i)" "WORKING(w)" "|" "USED(u@/!)" "DISCARDED(x@/!)")))
(setq org-todo-keyword-faces
'(("TODO" . org-todo)
- ("BUG" . org-todo)
("IDEA" . font-lock-constant-face)
("WORKING" . font-lock-constant-face)
("DONE" . org-done)
- ("RESOLVED" . org-done)
- ("WONTFIX" . org-done)
- ("FIXED" . org-done)
("USED" . org-done)
("DISCARDED" . org-done)))
-;; TODO: wc mode in org-mode
+; Logging
+(setq org-log-done t)
+(setq org-log-redeadline (quote time))
+(setq org-log-reschedule (quote time))
+
+;; org-agenda
+
+(setq org-agenda-files '("~/org/"))
+
+(setq org-agenda-custom-commands
+ '(("p" "Printed agenda"
+ ; Display a "High Priority" list of tasks on top.
+ ((tags "PRIORITY=\"A\""
+ ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
+ (org-agenda-sorting-strategy '(tag-up priority-down))
+ (org-agenda-todo-keyword-format "")
+ (org-agenda-overriding-header "High priority\n--------------\n")))
+
+ ; Daily agenda with a 2-weeks deadline warning. Tasks are
+ ; represented as [ ] items.
+ (agenda ""
+ ((org-agenda-ndays 1)
+ (org-deadline-warning-days 14)
+ (org-agenda-todo-keyword-format "[ ]")
+ (org-agenda-scheduled-leaders '("" ""))))
+
+ ; All tasks except those already listed as high priority or
+ ; ideas. Scheduled and deadlines are also ignored here.
+ (alltodo ""
+ ((org-agenda-skip-function '(or (mssola-org-skip-if-priority ?A)
+ (org-agenda-skip-entry-if 'todo '("IDEA" "WORKING"))
+ (org-agenda-skip-if nil '(scheduled deadline))))
+ (org-agenda-sorting-strategy '(tag-up priority-down))
+ (org-agenda-todo-keyword-format "")
+ (org-agenda-overriding-header "\nAll tasks\n----------\n")))
+
+ ; List of ideas.
+ (todo "IDEA"
+ ((org-agenda-overriding-header "\nIdeas\n------\n")
+ (org-agenda-todo-keyword-format ""))))
+
+ ((org-agenda-compact-blocks t)
+ (org-agenda-remove-tags t)))
+
+ ; List of done items. Useful for standups, review meetings, weekly
+ ; reports, etc.
+ ("d" "Done items"
+ ; First show the items done yesterday. Useful for standups.
+ ((todo "DONE"
+ ((org-agenda-overriding-header "Done yesterday\n---------------\n")
+ (org-agenda-skip-function
+ '(mssola-org-skip-if-not-closed-in-day
+ (time-subtract (current-time) (seconds-to-time 86400))))
+ (org-agenda-todo-keyword-format "")))
+
+ ; Then show what I've done today.
+ (todo "DONE"
+ ((org-agenda-overriding-header "\nDone today\n-----------\n")
+ (org-agenda-skip-function
+ '(mssola-org-skip-if-not-closed-in-day
+ (current-time)))
+ (org-agenda-todo-keyword-format "")))
+
+ ; Finally show what I've been doing in the past 15 days. Useful for
+ ; review meetings and weekly reports.
+ (todo "DONE"
+ ((org-agenda-start-day "-15d")
+ (org-agenda-span 15)
+ (org-agenda-start-on-weekday nil)
+ (org-agenda-todo-keyword-format "")
+ (org-agenda-scheduled-leaders '("" ""))
+ (org-agenda-overriding-header "\nDone during the past 15 days\n-----------------------------\n"))))
+
+ ((org-agenda-compact-blocks t)
+ (org-agenda-remove-tags t)))))
+
+; The prefix for the different kinds of types being used.
+(setq org-agenda-prefix-format '((agenda . "%t%s")
+ (todo . "%c:%t%s")))
(provide 'init-org)
;;; init-org.el ends here