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> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; 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) ;; 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 ;; 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 (defvar oni-core-related-places-source
'(:name "Related File" '(:name "Related File"
:category file :category file
:items oni-related-files :items oni-core-related-files
:enabled buffer-file-name :enabled buffer-file-name
:action find-file)) :action find-file))
(with-eval-after-load 'consult (with-eval-after-load 'consult
(with-eval-after-load 'related-files (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 ;;; Embark

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; Keywords: local
;; Version: 2022.1122.231427 ;; Version: 2023.0325.115622
;; Package-Requires: (oni-org org-roam) ;; Package-Requires: (oni-org org-roam)
;; This program is free software; you can redistribute it and/or modify ;; This program is free software; you can redistribute it and/or modify
@ -66,6 +66,27 @@
(and (not (null state)) (and (not (null state))
(not (string= state "FINISHED"))))) (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 (add-to-list 'display-buffer-alist
`(,(rx string-start "*org-roam*" string-end) `(,(rx string-start "*org-roam*" string-end)
display-buffer-in-side-window display-buffer-in-side-window

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; 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) ;; 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 ;; 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 ;;; 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 ;; 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 ;; refile. Include the file in the outline path so that I can refile into them
;; and create top-level headings. ;; 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-main-file . (:maxlevel . 10))
(oni-org-todo-someday-file . (:maxlevel . 1)))) (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 ;;; Export
(require 'ox-html) (require 'ox-html)
(require 'nxml-mode) (require 'nxml-mode)
@ -971,19 +978,19 @@ placed above TARGET. Otherwise it will be placed below it."
(string-trim-right (string-trim-right
(apply #'concat "| | Task | Effort |\n" (apply #'concat "| | Task | Effort |\n"
"|-+------+--------|\n" "|-+------+--------|\n"
"| | <60> | |\n"
(mapcar (lambda (itm) (mapcar (lambda (itm)
(let ((emphasis (if (alist-get 'done itm) "+" "")) (let ((emphasis (if (alist-get 'done itm) "+" ""))
(title (alist-get 'title itm))) (title (alist-get 'title itm)))
(format "| | %s[[id:%s][%s]]%s | %s |\n" (format "| | %s[[id:%s][%s]]%s | %s |\n"
emphasis emphasis
(alist-get 'id itm) (alist-get 'id itm)
(if (> (length title) 60) title
(format "%s..." (substring title 0 57))
title)
emphasis emphasis
(make-string (alist-get 'poms itm) ?X)))) (make-string (alist-get 'poms itm) ?X))))
info)))) info))))
(org-table-align))) (org-table-align)
(org-table-shrink)))
(defun oni-org-insert-pomodoro-overview () (defun oni-org-insert-pomodoro-overview ()
"Create a dynamic block showing the Pomodoro overview for today." "Create a dynamic block showing the Pomodoro overview for today."
@ -1021,15 +1028,15 @@ placed above TARGET. Otherwise it will be placed below it."
(save-excursion (save-excursion
(goto-char entry-beginning) (goto-char entry-beginning)
(save-match-data (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)) (let ((logbook-beginning (match-beginning 0))
(logbook-end (match-end 0))) (logbook-end (match-end 0)))
(goto-char logbook-beginning) (goto-char logbook-beginning)
(while (re-search-forward (while (re-search-forward
(rx "Finished a pomodoro on " (rx "Finished a pomodoro on "
(group "[" (one-or-more (not "]")) "]")) (group "[" (one-or-more (not "]")) "]"))
logbook-end t) logbook-end t)
(push (org-parse-time-string (match-string 1)) results))))) (push (org-parse-time-string (match-string 1)) results))))))
results)) results))
(defun oni-org-pomodoro-times-for-date (date) (defun oni-org-pomodoro-times-for-date (date)