FG42/core/cubes/org.el

187 lines
7.2 KiB
EmacsLisp

;;; OrgCube --- The org cube for FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2022 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://gitlab.com/FG42/FG42
;; Version: 3.0.0
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;; Cubes are the building blocks of any `FG42' editor. Each `cube' is a
;; unit which defines different abilities in a deterministic and idempotent
;; way. Cubes are composable and a composition of cubes creates an editor.
;;
;;; Code:
(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
(("<f9>" . 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
"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)
(let ((capture-key (or (plist-get fg42/org-cube-params :capture-key)
(kbd "<f6>")))
(org-home (or (plist-get fg42/org-cube-params :org-home) "~/orgs"))
(notes-file (or (plist-get fg42/org-cube-params :org-home) "~/orgs/notes.org")))
(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
(require 'org-capture)
(global-set-key capture-key 'org-capture)
(setq org-directory org-home)
(setq org-default-notes-file notes-file)
(setq org-capture-templates
(eval
`(list
'("t" "Todo" entry (file+headline ,(expand-file-name "main.org" org-home) "New Tasks")
(file ,(expand-file-name "templates/todo" org-home))
:prepend t)
'("l" "Link" entry (file+headline ,(expand-file-name "bookmarks.org" org-home) "Links")
(file ,(expand-file-name "templates/links" org-home))
:prepend t
:empty-lines 1)
'("h" "Thoughts" entry (file+datetree ,(expand-file-name "journal.org" org-home))
(file ,(expand-file-name "templates/thoughts" org-home))))))
(setq org-refile-targets '((org-agenda-files :maxlevel . 3)))
(with-eval-after-load "ox-latex"
(setq org-latex-default-packages-alist
(append '(("hidelinks" "hyperref" nil))
org-latex-default-packages-alist)))
(unless (server-running-p)
(require 'org-protocol))))))
(provide 'cubes/org)
;;; org.el ends here