1
0
Fork 0

Compare commits

...

5 commits

Author SHA1 Message Date
3a3460b0d7 [oni-org-roam] Add command to pick a random book from toread list 2023-03-25 21:40:39 -07:00
94a7eeef18 [oni-org] Add keybinding to refile items to the top of a heading 2023-03-25 21:39:56 -07:00
b468287aa7 [oni-org] Don't truncate the text in the pomodoro overview
Instead specify a width for the column and shrink the table. This way it still
gets truncated, but it can be expanded and the whole text is in the column.
2023-03-20 22:57:50 -07:00
aec7aa6267 [oni-org] Fix ‘oni-org-pomodoro-times’ for when no logbook exists 2023-03-20 22:57:16 -07:00
af7ff9343a [oni-core] Fix function names 2023-03-20 22:28:06 -07:00
3 changed files with 46 additions and 18 deletions

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0112.144039
;; Version: 2023.0227.150230
;; Package-Requires: (oni-data-dir oni-embrace oni-hydra expand-region multiple-cursors gcmh diminish ws-butler which-key insert-char-preview mixed-pitch ace-window vertico marginalia orderless consult embark docstr)
;; This program is free software; you can redistribute it and/or modify
@ -423,13 +423,13 @@ _s_: String list"
(defvar oni-core-related-places-source
'(:name "Related File"
:category file
:items oni-related-files
:items oni-core-related-files
:enabled buffer-file-name
:action find-file))
(with-eval-after-load 'consult
(with-eval-after-load 'related-files
(add-to-list 'consult-buffer-sources 'oni-related-places-source)))
(add-to-list 'consult-buffer-sources 'oni-core-related-places-source)))
;;; Embark

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2022.1122.231427
;; Version: 2023.0325.115622
;; Package-Requires: (oni-org org-roam)
;; This program is free software; you can redistribute it and/or modify
@ -66,6 +66,27 @@
(and (not (null state))
(not (string= state "FINISHED")))))
(defun oni-org-roam--books-to-read ()
(seq-filter (lambda (item)
(string= (map-elt (car item) "STATUS") "toread"))
(org-roam-db-query [:select [nodes:properties nodes:file nodes:title]
:from nodes
:left-join tags
:on (= tags:node-id nodes:id)
:where (like tag (quote "%\"book\"%"))])))
(defun oni-org-roam-list-books-to-read ()
(interactive)
(let ((buffer (get-buffer-create "*books-to-read*")))
(with-current-buffer buffer
(erase-buffer)
(mapc (lambda (item) (insert (caddr item) "\n")) (oni-org-roam--books-to-read)))
(switch-to-buffer buffer)))
(defun oni-org-roam-random-book-to-read ()
(interactive)
(find-file (cadr (seq-random-elt (oni-org-roam--books-to-read)))))
(add-to-list 'display-buffer-alist
`(,(rx string-start "*org-roam*" string-end)
display-buffer-in-side-window

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0314.013950
;; Version: 2023.0325.213834
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti form-feed)
;; This program is free software; you can redistribute it and/or modify
@ -777,6 +777,11 @@ After running it once remove it from `org-capture-after-finalize-hook'."
;;; Refile
(defun oni-org-refile-to-top ()
(interactive)
(let ((org-reverse-note-order t))
(org-refile)))
;; Set it up so that I can refile easily and still create new nodes when I
;; refile. Include the file in the outline path so that I can refile into them
;; and create top-level headings.
@ -791,6 +796,8 @@ After running it once remove it from `org-capture-after-finalize-hook'."
(oni-org-todo-main-file . (:maxlevel . 10))
(oni-org-todo-someday-file . (:maxlevel . 1))))
(define-key org-mode-map (kbd "C-c C-S-w") #'oni-org-refile-to-top 'remove)
;;; Export
(require 'ox-html)
(require 'nxml-mode)
@ -971,19 +978,19 @@ placed above TARGET. Otherwise it will be placed below it."
(string-trim-right
(apply #'concat "| | Task | Effort |\n"
"|-+------+--------|\n"
"| | <60> | |\n"
(mapcar (lambda (itm)
(let ((emphasis (if (alist-get 'done itm) "+" ""))
(title (alist-get 'title itm)))
(format "| | %s[[id:%s][%s]]%s | %s |\n"
emphasis
(alist-get 'id itm)
(if (> (length title) 60)
(format "%s..." (substring title 0 57))
title)
title
emphasis
(make-string (alist-get 'poms itm) ?X))))
info))))
(org-table-align)))
(org-table-align)
(org-table-shrink)))
(defun oni-org-insert-pomodoro-overview ()
"Create a dynamic block showing the Pomodoro overview for today."
@ -1021,7 +1028,7 @@ placed above TARGET. Otherwise it will be placed below it."
(save-excursion
(goto-char entry-beginning)
(save-match-data
(re-search-forward org-logbook-drawer-re entry-end)
(when (re-search-forward org-logbook-drawer-re entry-end nil)
(let ((logbook-beginning (match-beginning 0))
(logbook-end (match-end 0)))
(goto-char logbook-beginning)
@ -1029,7 +1036,7 @@ placed above TARGET. Otherwise it will be placed below it."
(rx "Finished a pomodoro on "
(group "[" (one-or-more (not "]")) "]"))
logbook-end t)
(push (org-parse-time-string (match-string 1)) results)))))
(push (org-parse-time-string (match-string 1)) results))))))
results))
(defun oni-org-pomodoro-times-for-date (date)