aboutsummaryrefslogtreecommitdiffstats
path: root/oni-org/oni-org.el
diff options
context:
space:
mode:
Diffstat (limited to 'oni-org/oni-org.el')
-rw-r--r--oni-org/oni-org.el124
1 files changed, 69 insertions, 55 deletions
diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el
index 444a508..1c6ef2f 100644
--- a/oni-org/oni-org.el
+++ b/oni-org/oni-org.el
@@ -4,8 +4,8 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2026.0324.011543
-;; Package-Requires: (oni-yasnippet oni-hydra org org-edna diminish olivetti org-pretty-table)
+;; Version: 2026.0707.150746
+;; Package-Requires: (oni-hydra org org-edna diminish olivetti)
;; 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
@@ -38,6 +38,7 @@
(require 'color)
(require 'diminish)
(require 'hydra)
+(require 'map)
(require 'ob)
(require 'org)
(require 'org-clock)
@@ -46,10 +47,13 @@
(require 'org-faces)
(require 'org-habit)
(require 'org-protocol)
-(require 'org-roam)
(require 'range)
(require 'subr-x)
-(require 'yasnippet)
+
+(use-package org-pretty-table
+ :vc (:url "https://github.com/Fuco1/org-pretty-table.git"
+ :rev :newest)
+ :hook (org-mode))
;;; Constants
@@ -59,10 +63,6 @@
(buffer-file-name)))
"The directory where ‘oni-org’ was loaded from.")
-(defconst oni-org-snippets-dir
- (expand-file-name "snippets" oni-org-root)
- "The directory where ‘oni-org’ stores its snippets.")
-
(defconst oni-org-icons-dir
(expand-file-name "icons" oni-org-root)
"The directory where ‘oni-org’ stores its icons.")
@@ -152,12 +152,6 @@ located at the start of the line."
(setq-local yas-buffer-local-condition
'(looking-back (rx line-start (one-or-more (not space))))))
-(defun oni-org-snippets-initialize ()
- "Initialize the snippets for ‘oni-org’."
- (when (boundp 'yas-snippet-dirs)
- (add-to-list 'yas-snippet-dirs oni-org-snippets-dir t))
- (yas-load-directory oni-org-snippets-dir))
-
(defun oni-org-maybe-change-to-wip-state (current-state)
"Change the state of the current task to in-progress CURRENT-STATE is todo."
(if (and (not org-capture-mode)
@@ -189,7 +183,7 @@ located at the start of the line."
(if-let ((keywords (cl-remove-if (lambda (tag) (assoc tag org-todo-keyword-faces))
org-todo-keywords-1)))
(append org-todo-keyword-faces
- (mapcar (lambda (keyword) (cons keyword (oni-org-color-for keyword)))
+ (mapcar (lambda (keyword) (cons keyword (list :background (oni-org-color-for keyword) :foreground "#111414" :weight 'bold :box (yoshi-theme--make-inline-box (oni-org-color-for keyword)))))
keywords))
org-todo-keyword-faces))
@@ -252,8 +246,8 @@ _di_: Add inlineimages STARTUP
("t" (org-capture nil "t"))
("A" (org-capture nil "a"))
("j" (org-capture nil "j"))
- ("f" org-roam-node-find)
- ("i" org-roam-node-insert)
+ ("f" oni-org-find-node)
+ ;; ("i" org-roam-node-insert)
("di" oni-org-document-add-inline-images-startup))
(defun oni-org-in-dblock-p ()
@@ -345,7 +339,7 @@ and not a state update."
(org-update-all-dblocks)))
(setq org-todo-keywords
- '((sequence "TODO(t)" "WIP" "WAITING(W@)" "|" "DONE(d!)")
+ '((sequence "TODO(t)" "NEXT(n)" "WIP" "WAITING(W@)" "|" "DONE(d!)")
(sequence "|" "CANCELLED(c@)")))
(add-hook 'org-after-todo-state-change-hook 'oni-org-todo-maybe-hide-body)
@@ -372,7 +366,6 @@ and not a state update."
(add-hook 'org-mode-hook 'flyspell-mode)
(add-hook 'org-mode-hook 'olivetti-mode)
(add-hook 'org-mode-hook 'org-indent-mode)
-(add-hook 'org-mode-hook 'org-pretty-table-mode)
(add-hook 'org-mode-hook 'variable-pitch-mode)
(add-hook 'org-mode-hook 'visual-line-mode)
(add-hook 'org-mode-hook 'yas-minor-mode)
@@ -385,10 +378,6 @@ and not a state update."
;;;###autoload
(global-set-key (kbd "C-<home>") #'oni-org-open-index)
-(with-eval-after-load 'org
- (with-eval-after-load 'yasnippet
- (oni-org-snippets-initialize)))
-
(with-eval-after-load 'org-edna (diminish 'org-edna-mode))
(with-eval-after-load 'org-id
@@ -467,6 +456,12 @@ and not a state update."
display-buffer-in-previous-window
(inhibit-same-window . t)))
+;;;;; Custom Commands
+
+(setf (map-elt org-agenda-custom-commands "n")
+ '("NEXT items"
+ ((todo "NEXT"))))
+
;;;; Capture
(require 'org-capture)
@@ -995,27 +990,9 @@ This is done by adding a ‘:hidden t’ header argument to the code block."
,(/ (length text) 2)))))
text))
-(defmacro oni-org--map-put (collection key value)
- "The result of ‘(setf (map-elt ...) ...)’ on a list.
-Trying to byte-compile the above form doesn't work at the moment.
-This is a temporary hack to make sure I don't have to repeat this
-same code all the time."
- (declare (indent 2))
- (let ((key-name (gensym))
- (value-name (gensym)))
- `(let ((,key-name ,key)
- (,value-name ,value))
- (condition-case nil
- (with-no-warnings
- (map-put! ,collection ,key-name ,value-name nil))
- (map-not-inplace
- (setq ,collection
- (map-insert ,collection ,key-name ,value-name))
- ,value-name)))))
-
(defvar oni-org--capture-D-date nil)
-(oni-org--map-put org-capture-templates "D"
- '("A DONE item for my to-done list." entry (file oni-org-todo-main-file) "* DONE %?
+(setf (map-elt org-capture-templates "D")
+ '("A DONE item for my to-done list." entry (file oni-org-todo-main-file) "* DONE %?
CLOSED: %(setq oni-org--capture-D-date (format-time-string (org-time-stamp-format t t) (org-read-date t t nil \"Date: \")))
:PROPERTIES:
:CREATED: %(progn oni-org--capture-D-date)
@@ -1023,39 +1000,71 @@ CLOSED: %(setq oni-org--capture-D-date (format-time-string (org-time-stamp-forma
:LOGBOOK:
- State \"DONE\" from \"TODO\" %(progn oni-org--capture-D-date)
:END:"
- :after-finalize (lambda () (setq oni-org--capture-D-date nil))))
+ :after-finalize (lambda () (setq oni-org--capture-D-date nil))))
-(oni-org--map-put org-capture-templates "t"
- '("A simple TODO item." entry (file "") "* TODO %?
+(setf (map-elt org-capture-templates "t")
+ '("A simple TODO item." entry (file "") "* TODO %?
:PROPERTIES:
:CREATED: %U
:END:"))
-(oni-org--map-put org-capture-templates "U"
- '("A TODO capture from the browser." entry (file "") "* TODO %:description
+(setf (map-elt org-capture-templates "U")
+ '("A TODO capture from the browser." entry (file "") "* TODO %:description
:PROPERTIES:
:CREATED: %U
:END:
%:link"
- :immediate-finish t))
+ :immediate-finish t))
(defun oni-org-find-new-note-file ()
(let ((title (read-string "Title: ")))
(find-file (expand-file-name (format "reference/%s-%s.org"
(format-time-string "%Y%m%d%H%M%S")
- (replace-regexp-in-string (rx whitespace) "-" (downcase title)))
+ (replace-regexp-in-string
+ (rx whitespace) "-"
+ (replace-regexp-in-string
+ (rx (not (any whitespace alnum)))
+ ""
+ (downcase title))))
oni-org-todo-dir))
(setq-local oni-org--capture-page-title title)))
-(oni-org--map-put org-capture-templates "p"
- '("A note page." plain (function oni-org-find-new-note-file) "#+TITLE: %(with-current-buffer (org-capture-get :buffer) oni-org--capture-page-title)
+(setf (map-elt org-capture-templates "p")
+ '("A note page." plain (function oni-org-find-new-note-file) "#+TITLE: %(with-current-buffer (org-capture-get :buffer) oni-org--capture-page-title)
#+DATE: %U
%?"
- :after-finalize (lambda () (when org-note-abort
- (delete-file (buffer-file-name (org-capture-get :buffer)) t)
- (kill-buffer (org-capture-get :buffer))))))
+ :after-finalize (lambda () (when org-note-abort
+ (delete-file (buffer-file-name (org-capture-get :buffer)) t)
+ (kill-buffer (org-capture-get :buffer))))))
+
+(setf (map-elt org-capture-templates "c")
+ '("Chores"))
+
+(setf (map-elt org-capture-templates "cl")
+ `("Laundry" entry (file ,oni-org-todo-main-file)
+ (file ,(expand-file-name "laundry.org" oni-org-capture-template-directory))
+ :immediate-finish t))
+
+(defun oni-org-get-morning-checklist ()
+ "Get the template for my morning checklist."
+ (let ((template (org-file-contents
+ (expand-file-name "morning-checklist.org" oni-org-capture-template-directory))))
+ (if (= 1 (decoded-time-weekday (decode-time)))
+ (concat template
+ (org-file-contents
+ (expand-file-name "morning-checklist-bedding.org" oni-org-capture-template-directory)))
+ (if (= 2 (decoded-time-weekday (decode-time)))
+ (concat template
+ (org-file-contents
+ (expand-file-name "morning-checklist-trash.org" oni-org-capture-template-directory)))
+ template))))
+
+(setf (map-elt org-capture-templates "cm")
+ `("Morning Checklist" entry (file ,oni-org-todo-main-file)
+ (function oni-org-get-morning-checklist)
+ :immediate-finish t))
(defun oni-org-insert-link (title entry)
(interactive
@@ -1076,6 +1085,11 @@ CLOSED: %(setq oni-org--capture-D-date (format-time-string (org-time-stamp-forma
(file-relative-name (org-mem-entry-file entry))
title))))
+(defun oni-org-find-node ()
+ (interactive)
+ (let ((entries (mapcar (lambda (x) (cons (org-mem-title x) (org-mem-file x))) (org-mem-all-entries))))
+ (find-file (map-elt entries (completing-read "Header: " entries)))))
+
;;; Mastodon post dynamic block
(defun oni-org-dblock-write-mastodon-post (params)