forked from FG42/FG42
235 lines
9.3 KiB
EmacsLisp
235 lines
9.3 KiB
EmacsLisp
;;; OrgCube --- The org cube for FG42 -*- lexical-binding: t; -*-
|
|
;;
|
|
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
|
|
;;
|
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
|
;; URL: https://devheroes.codes/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)
|
|
|
|
|
|
(defflag org-journal
|
|
"Enable the support for org-journal in FG42." t)
|
|
|
|
|
|
(defvar fg42/default-org-journal-heder
|
|
"#+TITLE: Yearly Journal
|
|
#+STARTUP: folded logdrawer logdone logreschedule indent content align constSI entitiespretty")
|
|
|
|
|
|
(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
|
|
(require 'org-super-agenda)
|
|
(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
|
|
(require 'org-sidebar)
|
|
(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"))
|
|
(journal-header (or (plist-get fg42/org-cube-params :journal-header) fg42/default-org-journal-heder))
|
|
(journal-type (or (plist-get fg42/org-cube-params :journal-type) 'yearly))
|
|
(global-tags (plist-get fg42/org-cube-params :global-tags))
|
|
(agenda-files (or (plist-get fg42/org-cube-params :agenda-files) '("~/orgs/main.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)
|
|
|
|
(when-flag org-journal
|
|
;; This function will handle the org-capture integration only if org-journal
|
|
;; flag is set
|
|
(defun fg42/org-journal-find-location ()
|
|
;; Open today's journal, but specify a non-nil prefix argument in order to
|
|
;; inhibit inserting the heading; org-capture will insert the heading.
|
|
(org-journal-new-entry t)
|
|
(unless (eq org-journal-file-type 'daily)
|
|
(org-narrow-to-subtree))
|
|
(goto-char (point-max)))
|
|
|
|
(fpkg/use org-journal
|
|
:defer t
|
|
:init
|
|
(require 'org-journal)
|
|
;; Change default prefix key; needs to be set before loading org-journal
|
|
(setq org-journal-prefix-key "C-c j ")
|
|
:config
|
|
(setq org-journal-file-type journal-type
|
|
org-journal-file-header journal-header
|
|
org-journal-dir (expand-file-name "journal" org-home)
|
|
org-journal-date-format "%Y-%m-%d (%A): ")))
|
|
|
|
|
|
(fpkg/use org
|
|
:init
|
|
(progn
|
|
(require 'org)
|
|
(require 'org-capture)
|
|
(global-set-key capture-key 'org-capture)
|
|
(setq org-tag-alist global-tags)
|
|
(setq org-agenda-files agenda-files)
|
|
(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
|
|
:immediate-finish t
|
|
:empty-lines 1)
|
|
,@(when-flag org-journal
|
|
'((quote ("j" "Journal Entry" plain #'fg42/org-journal-find-location
|
|
"** %(format-time-string org-journal-time-format)%^{Title} %^G\n %?\n\n*** Context:\n %i\n From: %a"
|
|
:jump-to-captured t
|
|
:immediate-finish nil))))
|
|
|
|
'("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 'fg42/cubes/org)
|
|
;;; org.el ends here
|