From d943dae2ea3a45ecf2da4a28ff19b807b44e836b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Wed, 3 Jan 2024 22:23:28 +0000 Subject: [PATCH] Add capture templates for book + game progress --- custom/capture.el | 74 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/custom/capture.el b/custom/capture.el index 9b6bb81..acb6446 100644 --- a/custom/capture.el +++ b/custom/capture.el @@ -25,6 +25,50 @@ (insert "* books\n** obtained")) (insert "\n** obtained")))) + (defun findreading () + "Find or create heading for reading progress" + (filedate) + (goto-char (point-min)) + (if (not (search-forward "** progress" nil t)) + (if (not (search-forward "* books" nil t)) + (progn + (goto-char (point-max)) + (insert "* books\n** progress")) + (insert "\n** progress")))) + + (defun findbeaten () + "Find or create heading for beaten games" + (filedate) + (goto-char (point-min)) + (if (not (search-forward "** beaten" nil t)) + (if (not (search-forward "* games" nil t)) + (progn + (goto-char (point-max)) + (insert "* games\n** beaten")) + (insert "\n** beaten")))) + + (defun findobtained () + "Find or create heading for acquired games" + (filedate) + (goto-char (point-min)) + (if (not (search-forward "** acquired" nil t)) + (if (not (search-forward "* games" nil t)) + (progn + (goto-char (point-max)) + (insert "* games\n** acquired")) + (insert "\n** acquired")))) + + (defun findgaming () + "Find or create heading for gaming progress" + (filedate) + (goto-char (point-min)) + (if (not (search-forward "** gameplay" nil t)) + (if (not (search-forward "* games" nil t)) + (progn + (goto-char (point-max)) + (insert "* games\n** gameplay")) + (insert "\n** gameplay")))) + (defun findwatched () "Find or create heading for watched films" (filedate) @@ -101,6 +145,18 @@ (setq venues (s-split "\n" (f-read "~/Documents/drive/admin/emacs/venues.txt") t)) (setq thevenue (completing-read "Venue: " venues)) thevenue) + + (defun bookcalc () + "Read in or calculate position in book" + (setq ispageno (y-or-n-p "Calculate percentage from page number?")) + (if ispageno + (progn + (setq reachedpage (string-to-number (concat (read-string "Page reached: ") ".0"))) + (setq totalpages (string-to-number (concat (read-string "Total pages: ") ".0"))) + (setq bookprogress (number-to-string (truncate (* 100 (/ reachedpage totalpages)))))) + (setq bookprogress (read-string "Progress (%): "))) + (setq returnprogress (concat "*" bookprogress "%.* ")) + returnprogress) (setq org-default-notes-file (concat "~/Documents/drive/org/journal/" (format-time-string "%Y/%m/%Y-%m-%d") ".org")) @@ -109,7 +165,7 @@ (file+function "" findacquired) "* %^{Author} /%^{Title}/" :jump-to-captured t) - ("b" "Read book" entry + ("b" "Finished book" entry (file+function "" findread) "* %^{Author} /%^{Title}/%(therating)" :jump-to-captured t) @@ -121,13 +177,29 @@ (file+function "" findwatched) "* %^{Title} (%^{Year})%(therating)" :jump-to-captured t) + ("g" "Beat game" entry + (file+function "" findgame) + "* %^{Title}%(therating)" + :jump-to-captured t) ("m" "Musical performance" entry (file+function "" findperf) "* %(setensemble)\n** %^{Performance name} (%(setvenue))\n%?" :jump-to-captured t) + ("n" "Gameplay progress" entry + (file+function "" findgaming) + "* %^{Title}\n%?" + :jump-to-captured t) + ("o" "Obtained game" entry + (file+function "" findobtained) + "* %^{Title}" + :jump-to-captured t) ("p" "Visited place" entry (file+function "" findvisited) "* %^{Place}%(thevisitdate)" + :jump-to-captured t) + ("r" "Reading progress" entry + (file+function "" findreading) + "* %^{Author} /%^{Title}/\n%(bookcalc)%?" :jump-to-captured t))) (global-set-key (kbd "C-c c") #'org-capture)))