summary refs log tree commit diff
path: root/emacs/custom
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-10-11 06:52:29 -0700
committerFranck Cuny <franck@fcuny.net>2021-10-11 06:52:29 -0700
commitb308c5b0b4358a3753c90f3777a1f85eb07ecdca (patch)
tree9ab221229a8194c6031e5b4a97413e76787b3648 /emacs/custom
parentemacs: tweak the UI (diff)
downloademacs.d-b308c5b0b4358a3753c90f3777a1f85eb07ecdca.tar.gz
org: mostly rewrite configuration for the agenda
For some reasons using `defvar` for the files does not work with the
agenda.

Rewrite the org-capture templates to specify the files instead of
relying on the variable, since it's not working (at least on linux with
emacs 27.2).

Add a custom command for the agenda, to see what I care about for the
week.
Diffstat (limited to 'emacs/custom')
-rw-r--r--emacs/custom/fcuny-org.el93
1 files changed, 44 insertions, 49 deletions
diff --git a/emacs/custom/fcuny-org.el b/emacs/custom/fcuny-org.el
index 1937652..5486fc2 100644
--- a/emacs/custom/fcuny-org.el
+++ b/emacs/custom/fcuny-org.el
@@ -1,45 +1,22 @@
 (require 'fcuny-org-custom)
+(require 'fcuny-vars)
 
 (use-package org-ml
   :ensure t)
 
-(require 'fcuny-vars)
-
-(defvar fcuny/org-directory
-  ;; if we're on a macOS machine, we're using a work machine, so we
-  ;; store the notes inside a directory in the workspace. In other
-  ;; cases, we store them in ~/documents/notes which is backed up by
-  ;; syncthing.
-  (if (memq window-system '(mac ns))
-      (expand-file-name "~/workspace/notebooks"))
-  (expand-file-name "~/documents/notes"))
-
-(defvar fcuny/org-tasks-file
-  (concat fcuny/org-directory "/tasks.org"))
-
-(defvar fcuny/org-references-file
-  (concat fcuny/org-directory "/references.org"))
-
-(defvar fcuny/org-notes-file
-  (concat fcuny/org-directory "/notes.org"))
-
-(defvar fcuny/org-journal-file
-  (concat fcuny/org-directory "/journal.org"))
-
 (use-package htmlize
   :ensure t)
 
 (use-package org
   :ensure t
+  :commands (org-check-agenda-file org-protocol-capture)
   :mode (("\\.txt\\'" . org-mode))
   :hook ((org-mode                     . org-indent-mode)
          (org-mode                     . org-hide-block-all)
          (org-mode                     . visual-line-mode)
          (org-capture-after-finalize   . org-save-all-org-buffers)
          (org-capture-prepare-finalize . org-save-all-org-buffers))
-
-  :bind (("C-c c" . org-capture)
-         ("C-c a" . org-agenda))
+  :bind (("C-c c" . org-capture))
 
   :config
   (defvar load-language-list '((emacs-lisp . t)
@@ -54,7 +31,6 @@
 
   :custom
   (org-directory fcuny/org-directory)
-
   ;; hide emphasis markup
   (org-hide-emphasis-markers t)
 
@@ -84,25 +60,9 @@
   (org-lowest-priority ?D)
   (org-default-priority ?C) ;; Ensures unset tasks have low priority.
 
-  ;; agenda related
-  (org-agenda-span 14)
-  (org-agenda-show-all-dates t)
-  (calendar-week-start-day 1)      ;; org-mode uses calendar for the date picker, and I want this to start on Monday
-  (org-agenda-start-on-weekday 1)  ;; this is specific to org-agenda
-  (org-agenda-files `(,fcuny/org-notes-file
-                      ,fcuny/org-tasks-file
-                      ,fcuny/org-journal-file))
-
-  (org-agenda-use-time-grid t)
-  (org-agenda-prefix-format
-   '((agenda . " %i %-12:c%?-12t% s")
-     (todo . " %i %-12:c")
-     (tags . " %i %-12:c")
-     (search . " %i %-12:c")))
-
   ;; refile
   (org-refile-use-cache nil)
-  (org-refile-targets '((org-agenda-files . (:maxlevel . 3))))
+  (org-refile-targets '((org-agenda-files . (:maxlevel . 1))))
   (org-refile-use-outline-path 'file)
   (org-outline-path-complete-in-steps nil)
   (org-refile-allow-creating-parent-nodes 'confirm)
@@ -137,6 +97,43 @@
 
   (org-reverse-note-order t))
 
+(use-package org-agenda
+  :ensure nil
+  :after (org)
+  :bind (("C-c a" . org-agenda))
+  :custom
+  (org-agenda-files `(,(expand-file-name "inbox.org" org-directory)
+                      ,(expand-file-name "notes.org" org-directory)
+                      ,(expand-file-name "tasks.org" org-directory)
+                      ,(expand-file-name "projects.org" org-directory)
+                      ,(expand-file-name "journal.org" org-directory)))
+  (org-agenda-show-all-dates t)
+  (calendar-week-start-day 1)
+  (org-agenda-custom-commands nil)
+  (org-agenda-start-on-weekday 1)
+
+  :config
+  (add-to-list 'org-agenda-custom-commands
+               '("A" "Agenda"
+                 ((agenda ""
+                          ((org-agenda-span 'week)))
+                  (todo "TODO"
+                        ((org-agenda-overriding-header "To Refile")
+                         (org-agenda-files `(,(expand-file-name "inbox.org" org-directory)))))
+                  (todo "STARTED"
+                        ((org-agenda-overriding-header "In Progress")
+                         (org-agenda-files `(,(expand-file-name "projects.org" org-directory)))))
+                  (todo "WAITING"
+                        ((org-agenda-overriding-header "Blocked")
+                         (org-agenda-files `(,(expand-file-name "projects.org" org-directory)))))
+                  (todo "TODO"
+                        ((org-agenda-overriding-header "Projects")
+                         (org-agenda-files `(,(expand-file-name "projects.org" org-directory)))))
+                  (todo "TODO"
+                        ((org-agenda-overriding-header "One-off Tasks")
+                         (org-agenda-files `(,(expand-file-name "tasks.org" org-directory)))
+                         (org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline 'scheduled))))))))
+
 (use-package org-bullets
   :ensure t
   :after (org)
@@ -147,16 +144,14 @@
   :after (org)
   :custom
   (org-capture-templates
-   `(("t" "Todo [inbox]" entry
-      (file+headline ,fcuny/org-tasks-file "Tasks")
+   `(("t" "Todo" entry (file "inbox.org")
       "* TODO [#D] %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n")
 
-     ("n" "Note" entry
-      (file ,fcuny/org-notes-file)
+     ("n" "Note" entry (file "inbox.org")
       "* NOTE %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n")
 
      ("j" "Journal" entry
-      (file+olp+datetree ,fcuny/org-journal-file)
+      (file+olp+datetree "journal.org")
       "* %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n" :tree-type month))))
 
 (provide 'fcuny-org)