From cb5409866f2127dc6a3138a433ac918b51721ab5 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Sun, 13 Mar 2022 21:56:44 +0800 Subject: Refactor org config (emacs) - org-agenda config is now in a dedicated file - Add a new agenda view "Weekly Log" - Add display settings for agenda view --- .emacs.d/lisp/init-org.el | 158 +--------------------------------------------- 1 file changed, 2 insertions(+), 156 deletions(-) (limited to '.emacs.d/lisp/init-org.el') diff --git a/.emacs.d/lisp/init-org.el b/.emacs.d/lisp/init-org.el index 0ba9cb2..0102460 100644 --- a/.emacs.d/lisp/init-org.el +++ b/.emacs.d/lisp/init-org.el @@ -1,65 +1,3 @@ -(gx/maybe-require-package 'org-ql) - -(defvar gx/org-agenda-block--today-schedule - '(agenda "" ((org-agenda-span 1) - (org-agenda-overriding-header "Today's Schedule"))) - "A block showing today's schedule.") - -(defvar gx/org-agenda-block--weekly-schedule - '(agenda "" ((org-agenda-overriding-header "Weekly Schedule") - (org-agenda-ndays-to-span 7))) - "A block showing weekly schedule.") - -(defvar gx/org-agenda-block--stuck-projects - '(org-ql-block '(and (or (tags "PROJECT") - (not (ancestors (todo)))) - (todo) - (not (done)) - (not (todo "SOMEDAY")) - (not (todo "NEXT")) - (not (scheduled)) - (not (descendants (todo "NEXT"))) - (not (descendants (scheduled)))) - ((org-ql-block-header "Stuck Projects"))) - "A block showing stuck projects.") - -(defvar gx/org-agenda-block--unwilling-to-do - '(tags-todo "UNWILLING" - ((org-agenda-overriding-header "Unwilling to do"))) - "A block showing tasks I am not willing to do ...") - -(defvar gx/org-agenda-block--week-at-a-glance - '(agenda "" - ((org-agenda-span 7) - (org-agenda-repeating-timestamp-show-all t) - (org-agenda-entry-types '(:deadline :scheduled)) - (org-agenda-overriding-header "Week at a Glance"))) - "A block showing the tasks scheduled or due this week.") - -(defvar gx/org-agenda-block--attention - '(org-ql-block '(and (not (todo "WAITING")) - (or (tags "URGENT" "FLAGGED") - (priority "A"))) - ((org-ql-block-header "ATTENTION"))) - "A block showing tasks require attention.") - -(defvar gx/org-agenda-block--waiting-not-scheduled - '(org-ql-block '(and (todo "WAITING") - (not (scheduled))) - ((org-ql-block-header "Waiting unscheduled tasks"))) - "A block showing waiting and not scheduled tasks.") - -(defvar gx/org-agenda-block--next-not-scheduled - '(org-ql-block '(and (todo "NEXT") - (not (scheduled))) - ((org-ql-block-header "Next unscheduled tasks"))) - "A block showing next unscheduled tasks.") - -(defun gx/org-agenda-quit (fn) - (org-save-all-org-buffers) - (funcall fn)) -(advice-add 'org-agenda-quit :around 'gx/org-agenda-quit) - (defun gx/org-refile (fn &optional arg default-buffer rfloc msg) (funcall-interactively fn arg default-buffer rfloc msg) (org-save-all-org-buffers)) @@ -102,66 +40,7 @@ ;; priority (kbd "+") 'org-priority-up - (kbd "-") 'org-priority-down) - - (evil-set-initial-state 'org-agenda-mode 'motion) - (evil-define-key 'motion org-agenda-mode-map - - ;; motion - (kbd "j") 'org-agenda-next-line - (kbd "k") 'org-agenda-previous-line - (kbd "gg") 'evil-goto-first-line - (kbd "G") 'evil-goto-line - (kbd "C-n") 'org-agenda-next-item - (kbd "C-p") 'org-agenda-previous-item - (kbd "[[") 'org-agenda-earlier - (kbd "]]") 'org-agenda-later - - ;; actions - (kbd "RET") 'org-agenda-switch-to - (kbd "TAB") 'org-agenda-goto - (kbd "t") 'org-agenda-todo - (kbd "r") 'org-agenda-refile - (kbd "+") 'org-agenda-priority-up - (kbd "-") 'org-agenda-priority-down - (kbd "H") 'org-agenda-do-date-earlier - (kbd "L") 'org-agenda-do-date-later - (kbd "o") 'org-agenda-add-note - (kbd "A") 'org-agenda-append-agenda - (kbd "C") 'org-agenda-capture - (kbd "R") 'org-agenda-redo - - (kbd "dd") 'org-agenda-kill - - ;; bulk - (kbd "m") 'org-agenda-bulk-toggle - (kbd "x") 'org-agenda-bulk-action - - ;; set - (kbd "ss") 'org-agenda-schedule - (kbd "sd") 'org-agenda-deadline - (kbd "st") 'org-agenda-set-tags - (kbd "sT") 'org-timer-set-timer - (kbd "se") 'org-agenda-set-effort - - ;; filter - (kbd "fc") 'org-agenda-filter-by-category - (kbd "fr") 'org-agenda-filter-by-regexp - (kbd "fe") 'org-agenda-filter-by-effort - (kbd "ft") 'org-agenda-filter-by-tag - (kbd "F") 'org-agenda-filter-remove-all - - ;; clock - (kbd "ci") 'org-agenda-clock-in - (kbd "co") 'org-agenda-clock-out - (kbd "cc") 'org-agenda-clock-cancel - (kbd "cg") 'org-agenda-clock-goto - (kbd "cr") 'org-agenda-clockreport-mode - - ;; goto - (kbd "gc") 'org-agenda-goto-calendar - - (kbd "u") 'org-agenda-undo)) + (kbd "-") 'org-priority-down)) (add-hook 'org-mode-hook (lambda () @@ -235,44 +114,10 @@ '((shell . t) (plantuml . t)))) -;; agenda -(setq org-agenda-dim-blocked-tasks nil) -(setq org-agenda-skip-deadline-prewarning-if-scheduled t) -(setq org-deadline-warning-days 30) -(setq org-agenda-window-setup 'current-window) -;; (setq org-agenda-prefix-format -;; '((agenda . "%i %-12:c%?-12t% s %b") -;; (timeline . " % s") -;; (todo . "%i %-12:c %b") -;; (tags . "%i %-12:c") -;; (search . " %i %-12:c"))) -(setq org-agenda-custom-commands - `((" " "Daily agenda and all important TODOs" - (,gx/org-agenda-block--today-schedule - ,gx/org-agenda-block--attention - ,gx/org-agenda-block--unwilling-to-do - ;; (tags-todo "computer|@office|phone") - ;; (tags "PROJECT+CATEGORY=\"elephants\"") - ,gx/org-agenda-block--stuck-projects - ,gx/org-agenda-block--next-not-scheduled - ,gx/org-agenda-block--waiting-not-scheduled - ,gx/org-agenda-block--week-at-a-glance)) - ("d" "Upcoming deadlines" agenda "" - ((org-agenda-time-grid nil) - (org-deadline-warning-days 365) - (org-agenda-entry-types '(:deadline)))) - ("g" . "GTD contexts") - ("gh" "Home" tags-todo "home") - ("p" . "Priorities") - ("pa" "A items" tags-todo "+PRIORITIES=\"A\"") - ("pb" "B items" tags-todo "+PRIORITIES=\"B\"") - ("pc" "C items" tags-todo "+PRIORITIES=\"C\""))) - ;; evil (when (gx/maybe-require-package 'evil-org) (add-hook 'org-mode-hook 'evil-org-mode) (add-hook 'org-agenda-mode-hook 'evil-org-mode)) -(autoload 'evil-org-agenda-set-keys "evil-org-agenda") ;; (add-hook 'evil-org-mode-hook ;; (lambda () ;; (setq evil-want-C-i-jump nil))) @@ -322,4 +167,5 @@ (setq alert-default-style 'osx-notifier)) (setq org-alert-interval 60) +(require 'init-org-agenda) (provide 'init-org) -- cgit v1.2.3