From d451b56eebfe2a1d9cb684d12c07beffc5e261ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Wed, 3 Jan 2024 21:45:44 +0000 Subject: [PATCH] Add functions for tracking music (performances and scrobbles) --- custom/capture.el | 30 ++++++++++++++++-- custom/refile.el | 78 +++++++++++++++++++++++++++-------------------- 2 files changed, 72 insertions(+), 36 deletions(-) diff --git a/custom/capture.el b/custom/capture.el index 9d9c39d..9b6bb81 100644 --- a/custom/capture.el +++ b/custom/capture.el @@ -18,12 +18,12 @@ "Find or create heading for acquired books" (filedate) (goto-char (point-min)) - (if (not (search-forward "** acquired" nil t)) + (if (not (search-forward "** obtained" nil t)) (if (not (search-forward "* books" nil t)) (progn (goto-char (point-max)) - (insert "* books\n** acquired")) - (insert "\n** acquired")))) + (insert "* books\n** obtained")) + (insert "\n** obtained")))) (defun findwatched () "Find or create heading for watched films" @@ -81,6 +81,26 @@ (setq visitend (read-string "End date (YYYY-MM-DD): " )) (setq visitreturn (concat " <" visitstart ">--<" visitend ">"))) visitreturn) + + (defun findperf () + "Find or create heading for performances" + (filedate) + (goto-char (point-min)) + (if (not (search-forward "* performances" nil t)) + (progn + (goto-char (point-max)) + (insert "* performances")))) + + (defun setensemble () + "Get the ensemble performed with" + (setq ensembles (s-split "\n" (f-read "~/Documents/drive/admin/emacs/ensembles.txt") t)) + (setq theensemble (completing-read "Ensemble: " ensembles)) + theensemble) + + (defun setvenue () + (setq venues (s-split "\n" (f-read "~/Documents/drive/admin/emacs/venues.txt") t)) + (setq thevenue (completing-read "Venue: " venues)) + thevenue) (setq org-default-notes-file (concat "~/Documents/drive/org/journal/" (format-time-string "%Y/%m/%Y-%m-%d") ".org")) @@ -101,6 +121,10 @@ (file+function "" findwatched) "* %^{Title} (%^{Year})%(therating)" :jump-to-captured t) + ("m" "Musical performance" entry + (file+function "" findperf) + "* %(setensemble)\n** %^{Performance name} (%(setvenue))\n%?" + :jump-to-captured t) ("p" "Visited place" entry (file+function "" findvisited) "* %^{Place}%(thevisitdate)" diff --git a/custom/refile.el b/custom/refile.el index ff98a3d..7aa99c9 100644 --- a/custom/refile.el +++ b/custom/refile.el @@ -1,36 +1,3 @@ -(defun filejournal () - "Refile heading to specific file based on heading (journal edition)" - (interactive) - (setq orgheading (org-get-heading)) - (setq orgyear (substring orgheading 0 4)) - (setq orgmonth (substring orgheading 5 7)) - (setq orgfilepath (concat "~/Documents/drive/org/journal/" orgyear "/" orgmonth "/" orgheading ".org")) - (org-edit-headline "journal") - (let ((org-refile-targets '((orgfilepath :maxlevel . 1)))) - (org-refile))) - -(defun filediscord () - "Refile heading to specific file based on heading (discord edition)" - (interactive) - (setq orgheading (org-get-heading)) - (setq orgyear (substring orgheading 0 4)) - (setq orgmonth (substring orgheading 5 7)) - (setq orgfilepath (concat "~/Documents/drive/org/journal/" orgyear "/" orgmonth "/" orgheading ".org")) - (org-edit-headline "discord") - (let ((org-refile-targets '((orgfilepath :maxlevel . 1)))) - (org-refile))) - -(defun filemusic () - "Refile heading to specific file based on heading (music edition)" - (interactive) - (setq orgheading (org-get-heading)) - (setq orgyear (substring orgheading 0 4)) - (setq orgmonth (substring orgheading 5 7)) - (setq orgfilepath (concat "~/Documents/drive/org/journal/" orgyear "/" orgmonth "/" orgheading ".org")) - (org-edit-headline "music") - (let ((org-refile-targets '((orgfilepath :maxlevel . 1)))) - (org-refile))) - (defun filedate () "Insert timestamp if required based on file name" (interactive) @@ -41,3 +8,48 @@ (org-ctrl-c-ctrl-c) (insert "\n\n") (goto-char (point-min)))) + +(defun filejournal () + "Refile heading to specific file based on heading (journal edition)" + (interactive) + (setq orgheading (org-get-heading)) + (setq orgyear (substring orgheading 0 4)) + (setq orgmonth (substring orgheading 5 7)) + (setq orgfilepath (concat "~/Documents/drive/org/journal/" orgyear "/" orgmonth "/" orgheading ".org")) + (setq orgbuffername (concat orgheading ".org")) + (org-edit-headline "journal") + (let ((org-refile-targets '((orgfilepath :maxlevel . 1)))) + (org-refile)) + (with-current-buffer orgbuffername + (filedate) + (write-file orgbuffername))) + +(defun filediscord () + "Refile heading to specific file based on heading (discord edition)" + (interactive) + (setq orgheading (org-get-heading)) + (setq orgyear (substring orgheading 0 4)) + (setq orgmonth (substring orgheading 5 7)) + (setq orgfilepath (concat "~/Documents/drive/org/journal/" orgyear "/" orgmonth "/" orgheading ".org")) + (setq orgbuffername (concat orgheading ".org")) + (org-edit-headline "discord") + (let ((org-refile-targets '((orgfilepath :maxlevel . 1)))) + (org-refile)) + (with-current-buffer orgbuffername + (filedate) + (write-file orgbuffername))) + +(defun filemusic () + "Refile heading to specific file based on heading (music edition)" + (interactive) + (setq orgheading (org-get-heading)) + (setq orgyear (substring orgheading 0 4)) + (setq orgmonth (substring orgheading 5 7)) + (setq orgfilepath (concat "~/Documents/drive/org/journal/" orgyear "/" orgmonth "/" orgheading ".org")) + (setq orgbuffername (concat orgheading ".org")) + (org-edit-headline "music") + (let ((org-refile-targets '((orgfilepath :maxlevel . 1)))) + (org-refile)) + (with-current-buffer orgbuffername + (filedate) + (write-file orgbuffername)))