diff --git a/init.org b/init.org index a7c4e89..40e0925 100644 --- a/init.org +++ b/init.org @@ -561,7 +561,7 @@ FILE-1 will appear above FILE-2." (launch-file "/media/data/anon/Documents/Text Files/latex/Don't, Mr. Disraeli!/dont-mr-disraeli.pdf")) ("Exercise" (chronometrist-key-values-unified-prompt "Exercise") - (chronometrist-open-log)) + (chronometrist-edit-file (chronometrist-active-backend))) ("Guitar" (let* ((path-1 "/media/data/anon/Sync/Scores/guitar-solo/repertoire.org") (path-2 "/media/data/anon/Sync/Scores/guitar-duo/repertoire.org") @@ -668,9 +668,9 @@ Return nil (and run `magit-status') if the user answers no." (defun my-make-osm-url (id) (concat "https://www.openstreetmap.org/changeset/" id)) -(defun my-get-saved-changeset-id (chronometrist-file) +(defun my-get-saved-changeset-id (backend) (-let* (((&plist :changesets saved-changesets) - (chronometrist-loop-file for plist in chronometrist-file + (chronometrist-loop-records for plist in backend ;; the very latest OSM plist is the one we just created - ;; we want the one before that initially do (backward-list) @@ -683,14 +683,15 @@ Return nil (and run `magit-status') if the user answers no." (first (last (split-string last-url "/")))))) (cl-defun my-save-osm-details (&key data &allow-other-keys) - (-let* ((last-id (my-get-saved-changeset-id chronometrist-file)) + (-let* ((backend (chronometrist-active-backend)) + (last-id (my-get-saved-changeset-id backend)) (response-changesets (esxml-node-children data)) (new-changesets (if last-id (cl-loop with id for changeset in response-changesets do - (setq id (alist-get - 'id (esxml-node-attributes changeset))) + (setq id (alist-get 'id + (esxml-node-attributes changeset))) if (equal id last-id) return (reverse changesets) else collect @@ -702,16 +703,17 @@ Return nil (and run `magit-status') if the user answers no." ;; no changeset information in file - just use ;; the latest changeset from the response (let* ((changeset (first response-changesets)) - (id (alist-get 'id (esxml-node-attributes changeset))) + (id (alist-get 'id (esxml-node-attributes changeset))) (comment (my-get-changeset-comment changeset))) `((:osm-url ,(my-make-osm-url id) - :osm-comment ,comment)))))) - (chronometrist-sexp-replace-last - (chronometrist-plist-update - (chronometrist-last) `(:changesets ,new-changesets))))) + :osm-comment ,comment))))) + (new-plist (chronometrist-plist-update + (chronometrist-latest-record (chronometrist-active-backend)) + `(:changesets ,new-changesets)))) + (chronometrist-replace-last (chronometrist-active-backend) new-plist))) (defun my-save-osm-changeset-details () - "Save OSM changeset details in `chronometrist-file'." + "Save OSM changeset details in the Chronometrist file." (request "https://api.openstreetmap.org/api/0.6/changesets" :params '(("display_name" . "contrapunctus")) @@ -783,16 +785,6 @@ What if... :load-path "~/.emacs.d/contrapunctus/chronometrist/elisp/") #+END_SRC **** count-expressions -#+BEGIN_SRC emacs-lisp -(defun contrapunctus-count-expressions () - (interactive) - (chronometrist-sexp-in-file chronometrist-file - (goto-char (point-min)) - (cl-loop with count = 0 - while (ignore-errors (read (current-buffer))) - do (cl-incf count) - finally do (message "%s" count)))) -#+END_SRC **** tangling Wrote these two as potential alternatives to `org-babel-tangle', which was far slower than I'd like (took around 20s for chronometrist.org when I checked during the migration process, and 43s after the migration was complete.) These, on the other hand, are almost instant, but I don't use them anywhere because I run a sed script as a file local variable. #+BEGIN_SRC emacs-lisp @@ -831,8 +823,9 @@ Wrote these two as potential alternatives to `org-babel-tangle', which was far s #+END_SRC **** querying data An example of querying the Chronometrist file data - finding out how much time I've spent on tasks matching a certain criteria. + #+BEGIN_SRC emacs-lisp :tangle no :load no -(chronometrist-loop-file for plist in chronometrist-file +(chronometrist-loop-records for plist in chronometrist-file with count = 0 when (and (equal (plist-get plist :name) "Composing") (equal (plist-get plist :song) "आदि काल से आज तलक")) @@ -847,7 +840,7 @@ An example of querying the Chronometrist file data - finding out how much time I Intervals and durations for task Exercise. #+BEGIN_SRC emacs-lisp :tangle no :load no -(chronometrist-loop-file for plist in chronometrist-file +(chronometrist-loop-records for plist in chronometrist-file with count = 0 when (equal (plist-get plist :name) "Exercise") @@ -862,7 +855,7 @@ Intervals and durations for task Exercise. Unique key-values for task "Exercise" #+BEGIN_SRC emacs-lisp :tangle no :load no -(chronometrist-loop-file for plist in chronometrist-file +(chronometrist-loop-records for plist in chronometrist-file when (equal (plist-get plist :name) "Exercise") collect (chronometrist-plist-key-values plist) into key-values