From 7e82143dfb8cb1dc3ed2b218edad00428656c22e Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Mon, 27 Jun 2022 23:41:52 +0100 Subject: [PATCH] Add org-ql, org-sidebar and super agenda via dedicated cubes --- core/cubes/org.el | 114 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/core/cubes/org.el b/core/cubes/org.el index af5d8e3..f8d022f 100644 --- a/core/cubes/org.el +++ b/core/cubes/org.el @@ -28,9 +28,114 @@ (require 'fpkg) (require 'fg42/cube) + + +(defcube fg42/org-ql-cube + "This package provides a query language for Org files. It offers two +syntax styles: Lisp-like sexps and search engine-like keywords. + +It includes three libraries: The ~org-ql~ library is flexible and may +be used as a backend for other tools. The libraries ~org-ql-search~ and +~helm-org-ql~ (a separate package) provide interactive search commands + and saved views. + +After installation, you can use the commands without additional configuration. +To use the functions and macros in your own Elisp code, use libraries ~org-ql~ +and ~org-ql-view~." + (:title "Org Qurey Language" + :flag org-ql + :flag-default t) + (fpkg/use org-ql + :after org)) + + +(defcube fg42/org-super-agenda-cube + "This package lets you “supercharge” your Org daily/weekly agenda. The idea is +to group items into sections, rather than having them all in one big list. + +Now you can sort-of do this already with custom agenda commands, but when you +do that, you lose the daily/weekly aspect of the agenda: items are no longer +shown based on deadline/scheduled timestamps, but are shown no-matter-what. + +You can set your groups via the ~:groups~ parameter. Check out the code +for more parameters. + +For more information checkout [[https://github.com/alphapapa/org-super-agenda]]" + (:title "Org Super Agenda" + :flag org-super-agenda + :flag-default t) + + (defconst fg42/org-super-agenda-groups + nil) + + (let* ((params fg42/org-super-agenda-cube-params) + (groups (plist-get params :groups))) + (fpkg/use org-super-agenda + :after org-agenda + :init + (progn + (setq org-agenda-skip-scheduled-if-done (or (plist-get params :skip-scheduled-if-done) t) + org-agenda-skip-deadline-if-done (or (plist-get params :skip-deadline-if-done) t) + org-agenda-include-deadlines (or (plist-get params :include-deadline) t) + org-agenda-block-separator (plist-get params :block-separator) + org-agenda-compact-blocks (or (plist-get params :compact-blocks) t) + org-agenda-start-day (plist-get params :start-day) ;; nil == today + org-agenda-span (or (plist-get params :span) 1) + org-agenda-start-on-weekday (plist-get params :start-on-week) + org-super-agenda-groups groups)) + :config + (org-super-agenda-mode)))) + + +(defcube fg42/org-sidebar + "This package presents helpful sidebars for Org buffers. Sidebars are customizable using +~org-ql~ queries and ~org-super-agenda~ grouping. + +The default sidebar includes a chronological list of scheduled and deadlined items in the +current buffer (similar to the Org agenda, but without all its features) at the top, and +a list of all other non-done to-do items below. If the buffer is narrowed, the sidebar only +shows items in the narrowed portion; this allows seeing an overview of tasks in a subtree." + + (:title "Org Sidebar" + :flag org-sidebar + :flag-default t) + + (let ((default-file (or (plist-get fg42/org-sidebar-params :default-file) "~/orgs/main.org")) + (fns (plist-get fg42/org-sidebar-params :sidebar-fns))) + + (defun fg42/org-sidebar--default (buf) + (let ((main-org-buf (get-buffer-create "*main-org*"))) + (with-current-buffer main-org-buf + (insert-file default-file)) + main-org-buf)) + + (defun fg42/org-sidebar-toggle-sidebar-default () + (interactive) + (message "here") + (org-sidebar #'fg42/org-sidebar--default)) + + (if-flag org-super-agenda + (if-flag org-ql + (fpkg/use org-sidebar + :init + (setq org-sidebar-default-fns fns) + :bind + (("" . fg42/org-sidebar-toggle-sidebar-default))) + (error "`fg42/org-ql-cube' is required for `fg42/org-sidebar'")) + (error "`fg42/org-sugper-agenda-cube' is required for `fg42/org-sidebar'")))) + + (defcube fg42/org-cube - "Org cube" - (:title "cubes/fg42/org-cube.org" + "A GNU Emacs major mode for keeping notes, authoring documents, computational notebooks, +literate programming, maintaining to-do lists, planning projects, and more — in a fast +and effective plain text system. + +This cube contains ~fg42/org-super-agenda-cube~, ~fg42/org-ql-cube~ and ~fg42/org-sidebar~ +cubes and you can pass parameters to them via ~:super-agenda~, ~:ql~ and ~:sidebar~ keys. + +For more info on ~org-mode~ check out [[https://orgmode.org/]]" + + (:title "Org-mode" :flag org :flag-default t) @@ -42,6 +147,11 @@ (fpkg/use org-bullets :hook (org-mode . org-bullets-mode)) + (fg42/org-super-agenda-cube (plist-get fg42/org-cube-params :super-agenda)) + (fg42/org-ql-cube) + (fg42/org-sidebar) + + (fpkg/use org-mode :init (progn