Created
August 18, 2023 05:03
-
-
Save colonelpanic8/67b6bd165c10b0e90775a4cd0aeccd0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (org-time-string-to-time "-30d") | |
| (* 24 6 60 60) | |
| (format-time-string | |
| "<%Y-%m-%d>" (time-subtract (current-time) (days-to-time 1))) | |
| ((eq direction :before) (and property-value | |
| )) | |
| ((eq direction :after) (and property-value | |
| (time-less-p (org-time-string-to-time property-value) compare-time))) | |
| ((lambda (&optional what) | |
| what) t)- | |
| ((("M" "Main agenda view" ((agenda "" ((org-agenda-overriding-header "Agenda:") (org-agenda-ndays 5) (org-deadline-warning-days 0))) (alltodo "" ((org-agenda-overriding-header "Due today:") (org-agenda-skip-function (lambda nil (if (or (imalison:org-time-condition-met-p :property "DEADLINE" :days 1 :future t) (imalison:org-time-condition-met-p :property "SCHEDULED" :days 0 :future t)) nil (or (outline-next-heading) (point-max))))))) (todo "NEXT") (todo "STARTED") (tags-todo "+PRIORITY<\"C\"" ((org-agenda-overriding-header "Upcoming high priority tasks:") (org-agenda-skip-function (lambda nil (if (or (imalison:org-time-condition-met-p :property "DEADLINE" :days 7 :future t) (imalison:org-time-condition-met-p :property "SCHEDULED" :days 7 :future t)) nil (or (outline-next-heading) (point-max))))))) (alltodo "" ((org-agenda-overriding-header "Recently Created:") (org-agenda-skip-function (lambda nil (if (imalison:org-time-condition-met-p :property "DEADLINE" :days 10) nil (or (outline-next-heading) (point-max)))))))) nil nil) ("A" "High priority upcoming" tags-todo "+PRIORITY<\"C\"" ((org-agenda-overriding-header "Upcoming high priority tasks:") (org-agenda-skip-function (lambda nil (if (or (imalison:org-time-condition-met-p :property "DEADLINE" :days 7 :future t) (imalison:org-time-condition-met-p :property "SCHEDULED" :days 7 :future t)) nil (or (outline-next-heading) (point-max))))))) ("d" "Overdue tasks and due today" alltodo "" ((org-agenda-overriding-header "Due today:") (org-agenda-skip-function (lambda nil (if (or (imalison:org-time-condition-met-p :property "DEADLINE" :days 1 :future t) (imalison:org-time-condition-met-p :property "SCHEDULED" :days 0 :future t)) nil (or (outline-next-heading) (point-max))))))) ("r" "Recently created" alltodo "" ((org-agenda-overriding-header "Recently Created:") (org-agenda-skip-function (lambda nil (if (imalison:org-time-condition-met-p :property "DEADLINE" :days 10) nil (or (outline-next-heading) (point-max))))))) ("h" "A, B priority:" tags-todo "+PRIORITY<\"C\"" ((org-agenda-overriding-header "High Priority:"))) ("c" "At least priority C:" tags-todo "+PRIORITY<\"D\"" ((org-agenda-overriding-header "At least priority C:")))) nil) | |
| (define-transient-command my-debug-transient () | |
| "My debug transient." | |
| ;; The columns in the pop-up | |
| [["Action" | |
| ("p" "Print debug message" my-print-debug-message) | |
| ("e" "Evaluate expression" eval-expression)] | |
| ["Options" | |
| ("-v" "Toggle verbosity" "--verbose")]]) | |
| (defvar org-agenda-builtin-key-to-action | |
| '(("C" "Configure custom agenda commands." | |
| (lambda (&optional arg) | |
| (customize-variable 'org-agenda-custom-commands))) | |
| ("a" "Display the agenda for current day or week." | |
| (lambda (&optional arg) | |
| (call-interactively 'org-agenda-list))) | |
| ("s" "Search entries for keywords." | |
| (lambda (&optional arg) | |
| (call-interactively 'org-search-view))) | |
| ("S" "Search entries for TODO keywords." | |
| (lambda (&optional arg) | |
| (org-call-with-arg 'org-search-view (or arg '(4))))) | |
| ("t" "Display the global TODO list." | |
| (lambda (&optional arg) | |
| (call-interactively 'org-todo-list))) | |
| ("T" "Display the global TODO list with specific keyword." | |
| (lambda (&optional arg) | |
| (org-call-with-arg 'org-todo-list (or arg '(4))))) | |
| ("m" "Display headlines with tags matching a condition." | |
| (lambda (&optional arg) | |
| (call-interactively 'org-tags-view))) | |
| ("M" "Display TODO headlines with tags matching a condition." | |
| (lambda (&optional arg) | |
| (org-call-with-arg 'org-tags-view (or arg '(4))))) | |
| ("e" "Export views to associated files." | |
| (lambda (&optional arg) | |
| (call-interactively 'org-store-agenda-views))) | |
| ("?" "List flagged tasks with description." | |
| (lambda (&optional arg) | |
| (org-tags-view nil "+FLAGGED") | |
| (add-hook | |
| 'post-command-hook | |
| (lambda () | |
| (unless (current-message) | |
| (let* ((m (org-agenda-get-any-marker)) | |
| (note (and m (org-entry-get m "THEFLAGGINGNOTE")))) | |
| (when note | |
| (message "FLAGGING-NOTE ([?] for more info): %s" | |
| (org-add-props | |
| (replace-regexp-in-string | |
| "\\\\n" "//" | |
| (copy-sequence note)) | |
| nil 'face 'org-warning)))))) | |
| t t))) | |
| ("#" "List \"stuck\" projects." | |
| (lambda (&optional arg) | |
| (call-interactively 'org-agenda-list-stuck-projects))) | |
| ("/" "Multi occur across all agenda files." | |
| (lambda (&optional arg) | |
| (call-interactively 'org-occur-in-agenda-files))) | |
| ("!" "Configure what \"stuck\" means." | |
| (lambda (&optional arg) | |
| (customize-variable 'org-stuck-projects))))) | |
| (transient-define-prefix org-agenda-transient () | |
| "Transient for org-agenda commands." | |
| :value '("--") | |
| ;; Define the main groups and their commands | |
| [["Built-in commands" | |
| ;; Dynamically generate the built-in commands | |
| (mapcar (lambda (entry) | |
| (list (car entry) (cadr entry) | |
| (lambda () | |
| (funcall (caddr entry))))) | |
| org-agenda-builtin-key-to-action) | |
| ] | |
| ["Custom commands" | |
| ;; Dynamically generate the custom commands | |
| (mapcar (lambda (entry) | |
| (list (car entry) (nth 1 entry) | |
| (lambda () | |
| (org-agenda-execute-command (car entry))))) | |
| (org-agenda-normalize-custom-agenda-commands)) | |
| ]]) | |
| (defun org-agenda-transient-generate () | |
| "Dynamically generate the Org Agenda Transient definitions." | |
| (let (commands) | |
| (dolist (key-action org-agenda-builtin-key-to-action) | |
| (let ((key (car key-action)) | |
| (action (cdr key-action))) | |
| ;; Using key as the description for now | |
| (push (list key key action) commands))) | |
| (setq commands (nreverse commands)) ; Fix the order | |
| `(transient-define-prefix org-agenda-transient () "Org Agenda Transient" ,@commands))) | |
| (transient-define-prefix org-agenda-transient () | |
| [:description | |
| (lambda () "Org Agenda") | |
| :class transient-column | |
| :setup-children org-agenda-transient--setup | |
| :pad-keys t]) | |
| (defun org-agenda-execute-custom-command (entry) | |
| "Execute the org-agenda command associated with ORG-KEYS with optional ARG." | |
| (if (or (symbolp (nth 2 entry)) (functionp (nth 2 entry))) | |
| (progn | |
| (setq type (nth 2 entry) org-match (eval (nth 3 entry) t) | |
| lprops (nth 4 entry)) | |
| (when org-agenda-sticky | |
| (setq org-agenda-buffer-name | |
| (or (and (stringp org-match) (format "*Org Agenda(%s:%s)*" org-keys org-match)) | |
| (format "*Org Agenda(%s)*" org-keys)))) | |
| (cl-progv | |
| (mapcar #'car lprops) | |
| (mapcar (lambda (binding) (eval (cadr binding) t)) lprops) | |
| (pcase type | |
| (`agenda (org-agenda-list arg)) | |
| (`agenda* (org-agenda-list arg nil nil t)) | |
| (`alltodo (org-todo-list arg)) | |
| (`search (org-search-view arg org-match nil)) | |
| (`stuck (org-agenda-list-stuck-projects arg)) | |
| (`tags (org-tags-view arg org-match)) | |
| (`tags-todo (org-tags-view '(4) org-match)) | |
| (`todo (org-todo-list org-match)) | |
| (`tags-tree | |
| (org-check-for-org-mode) | |
| (org-match-sparse-tree arg org-match)) | |
| (`todo-tree | |
| (org-check-for-org-mode) | |
| (org-occur (concat "^" org-outline-regexp "[ \t]*" | |
| (regexp-quote org-match) "\\>"))) | |
| (`occur-tree | |
| (org-check-for-org-mode) | |
| (org-occur org-match)) | |
| ((pred functionp) (funcall type org-match)) | |
| ((pred fboundp) (funcall type org-match)) | |
| (_ (user-error "Invalid custom agenda command type %s" type)))) | |
| (let ((inhibit-read-only t)) | |
| (add-text-properties (point-min) (point-max) | |
| `(org-lprops ,lprops)))) | |
| (org-agenda-run-series (nth 1 entry) (cddr entry)))) | |
| (defun org-agenda-transient-get-custom-actions () | |
| (let ((normalized-commands (car (org-agenda-normalize-custom-agenda-commands)))) | |
| (cl-loop for custom-command in normalized-commands | |
| collect (list (car custom-command) (nth 1 custom-command) | |
| (lambda () | |
| (org-agenda-execute-custom-command (nthcdr 2 custom-command))))))) | |
| (length (org-agenda-normalize-custom-agenda-commands)) | |
| (defun org-agenda-transient-triples () | |
| (append (org-agenda-transient-get-custom-actions) org-agenda-builtin-key-to-action)) | |
| (org-agenda-transient-triples) | |
| (defun org-agenda-transient--setup (_) | |
| (transient-parse-suffixes | |
| 'gptel-system-prompt | |
| (cl-loop for (key description fn) in (org-agenda-transient-triples) | |
| with taken | |
| unless (member key taken) | |
| do | |
| (push key taken) | |
| collect (list (key-description key) description fn)))) | |
| (member "b" '("a")) | |
| (("f" "Tasks created in the last 30 days" (closure ((x "f" "Tasks created in the last 30 days" todo "" ((org-agenda-skip-function (lambda nil (unless (imalison:org-created-in-last-30-days-p) (or (outline-next-heading) (point-max)))))))) nil (org-agenda-execute-custom-command (car x))))) | |
| ((("M" "Main agenda view" | |
| ((agenda "" ((org-agenda-overriding-header "Agenda:") (org-agenda-ndays 5) (org-deadline-warning-days 0))) (alltodo "" ((org-agenda-overriding-header "Due today:") (org-agenda-skip-function (lambda nil (if (or (imalison:org-time-condition-met-p :property "DEADLINE" :days 1 :future t) (imalison:org-time-condition-met-p :property "SCHEDULED" :days 0 :future t)) nil (or (outline-next-heading) (point-max))))))) (todo "NEXT") (todo "STARTED") (tags-todo "+PRIORITY<\"C\"" ((org-agenda-overriding-header "Upcoming high priority tasks:") (org-agenda-skip-function (lambda nil (if (or (imalison:org-time-condition-met-p :property "DEADLINE" :days 7 :future t) (imalison:org-time-condition-met-p :property "SCHEDULED" :days 7 :future t)) nil (or (outline-next-heading) (point-max))))))) (alltodo "" ((org-agenda-overriding-header "Recently Created:") (org-agenda-skip-function (lambda nil (if (imalison:org-time-condition-met-p :property "DEADLINE" :days 10) nil (or (outline-next-heading) (point-max)))))))) | |
| nil | |
| nil) | |
| ("A" "High priority upcoming" tags-todo "+PRIORITY<\"C\"" | |
| ((org-agenda-overriding-header "Upcoming high priority tasks:") (org-agenda-skip-function (lambda nil (if (or (imalison:org-time-condition-met-p :property "DEADLINE" :days 7 :future t) (imalison:org-time-condition-met-p :property "SCHEDULED" :days 7 :future t)) nil (or (outline-next-heading) (point-max))))))) | |
| ("d" "Overdue tasks and due today" alltodo "" | |
| ((org-agenda-overriding-header "Due today:") (org-agenda-skip-function (lambda nil (if (or (imalison:org-time-condition-met-p :property "DEADLINE" :days 1 :future t) (imalison:org-time-condition-met-p :property "SCHEDULED" :days 0 :future t)) nil (or (outline-next-heading) (point-max))))))) | |
| ("r" "Recently created" alltodo "" | |
| ((org-agenda-overriding-header "Recently Created:") (org-agenda-skip-function (lambda nil (if (imalison:org-time-condition-met-p :property "DEADLINE" :days 10) nil (or (outline-next-heading) (point-max))))))) | |
| ("h" "A, B priority:" tags-todo "+PRIORITY<\"C\"" | |
| ((org-agenda-overriding-header "High Priority:"))) ("c" "At least priority C:" tags-todo "+PRIORITY<\"D\"" ((org-agenda-overriding-header "At least priority C:")))) nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment