dotemacs/contrapunctus/cp-chronometrist.el

222 lines
9.4 KiB
EmacsLisp

(use-package run-transformers
:load-path "~/.emacs.d/contrapunctus/run-transformers/")
(use-package chronometrist
:load-path "~/.emacs.d/contrapunctus/chronometrist/elisp/"
:hook
(chronometrist-kv-read-mode . visual-line-mode)
(chronometrist-sexp-mode . auto-revert-mode)
(kill-emacs-query-functions . chronometrist-query-stop)
:bind (("<f9>" . chronometrist)
("<kp-insert>" . chronometrist))
:config
(setq chronometrist-before-in-functions '()
chronometrist-after-in-functions '(;; chronometrist-tags-add
;; chronometrist-kv-add
contrapunctus-start-project)
chronometrist-before-out-functions '(contrapunctus-before-project-stop
;; chronometrist-skip-query-prompt
chronometrist-tags-add
;; chronometrist-tags-hydra
;; chronometrist-tags-choice
chronometrist-kv-add
chronometrist-skip-query-reset)
chronometrist-after-out-functions '(contrapunctus-after-project-stop)
chronometrist-activity-indicator 'contrapunctus-chronometrist-activity-indicator))
(use-package chronometrist-goal
:load-path "~/.emacs.d/contrapunctus/chronometrist-goal/"
:hook (chronometrist-mode . chronometrist-goal-minor-mode)
:config
(setq chronometrist-goal-list
'((15 "Arrangement/new edition")
(15 "Aural exercises")
(15 "Transcription" "Theory")
(30 "Composing" "Writing" "Recording")
(15 "Data organization" "Physical organization" "Khilona archiving")
(60 "Exercise")
(120 "Guitar")
(90 "Reading")
(60 "Singing")
(20 "Subtitles")
(15 "Acting")
(30 "Keyboard")
(15 "Wikisource"))
alert-default-style 'libnotify))
(defun contrapunctus-chronometrist-activity-indicator ()
(thread-last (plist-put (chronometrist-last)
:stop (chronometrist-format-time-iso8601))
list
chronometrist-events-to-durations
(-reduce #'+)
truncate
chronometrist-format-time))
(defun contrapunctus-find-two-files-other-window (file-1 file-2)
"Open FILE-1 and FILE-2 in new windows.
FILE-1 will appear above FILE-2."
(find-file-other-window file-2)
(split-window-below)
(find-file file-1))
(defun cp-outline-open-heading (n)
(goto-char (point-min))
(outline-next-visible-heading n)
(outline-show-subtree))
(defun contrapunctus-start-project (project)
(delete-other-windows)
(pcase project
("Arrangement/new edition"
(delete-other-windows)
(find-file
"~/1-music-notation/4-my-arrangements/2020/2020-11-27 Winterreise/01 Gute Nacht/music/")
(launch-file
"~/1-music-notation/4-my-arrangements/2020/2020-11-27 Winterreise/01 Gute Nacht/output/01 Gute Nacht-pacON.pdf")
(launch-file
"~/Sync/Scores/voice/Schubert, Franz/IMSLP570459-PMLP2203-D_911,_Winterreise.pdf"))
("Aural exercises"
(find-file-other-window "~/phone/Nokia 6.1/Documents/Markor/Music/Analyse.md"))
("Composing"
(find-file-other-window
"/home/anon/1-music-notation/2-my-compositions/2017/2017-02 The Rainbow Flower/1 Chhutti Ka Din/music/"))
("Data organization"
(find-dired "~/" "-name \\'dl\\' -size +0c"))
("Exercise"
(let* ((path-1 "~/Documents/Text Files/ma/practice.org")
(path-2 "~/Documents/Text Files/ma/0shoto-syllabus.org")
(file-1 (file-name-nondirectory path-1))
(file-2 (file-name-nondirectory path-2)))
(contrapunctus-find-two-files-other-window path-1 path-2)
(select-window (get-buffer-window file-1))))
("Guitar"
(let* ((path-1 "~/Sync/Scores/guitar-solo/repertoire.org")
(path-2 "~/Sync/Scores/guitar-duo/repertoire.org")
(weekday (elt (decode-time) 6))
(week (string-to-number (format-time-string "%U"))))
(contrapunctus-find-two-files-other-window path-1 path-2)
(select-window (get-buffer-window (get-file-buffer path-1)))
(org-match-sparse-tree nil "perform")))
("Keyboard"
(find-file-other-window "~/Documents/Text Files/music_stuff/piano.org")
(outline-show-subtree))
("Khilona archiving"
(find-file-other-window "/home/anon/Documents/sync/Khilona/")
(split-window-below)
(other-window 1)
(find-file "/home/anon/Khilona/Videos/Me?/")
(other-window 1)
(find-file "/home/anon/Documents/Text Files/khilona/2011 Me?/script/script.tex"))
("OSM"
;; (async-shell-command "java -jar ~/josm-tested.jar" " *JOSM*" " *JOSM errors*")
;; (delete-window (get-buffer-window " *JOSM*"))
(contrapunctus-find-two-files-other-window "~/phone/Nokia 6.1/Android/data/net.osmand.plus/files/"
;; "~/phone/Nokia 6.1/external/DCIM/OpenCamera/osm/"
"~/phone/Nokia 6.1/Documents/Markor/OSM/TODO.md"))
("Programming"
(find-file-other-window
"~/phone/Nokia 6.1/Documents/Markor/Computers/todo.md"))
("Singing"
(find-file-other-window "~/Sync/Scores/voice/repertoire.org"))
("Subtitles"
;; (find-file-other-window "~/Music/0-classical/vocal/musical/Company/")
(start-process "subtitleeditor" nil "subtitleeditor" "/home/khilona/Videos/Peer Gynt/peer-gynt.srt"))
("Teaching"
(launch-file "~/Sync/Scores/voice/jingle-bell-rock.pdf"))
("Theatre rehearsal"
(contrapunctus-find-two-files-other-window
"~/Documents/Text Files/khilona/voices.org"
"~/1-music-notation/2-my-compositions/2019/2019-03 Kahe Natak Karte Ho Ji/Kahe Natak Karte Ho Ji.org"))
("Transcription"
;; (find-file-other-window
;; "~/phone/Nokia 6.1/Documents/Markor/Music/transcriptions.md")
(emms-play-file "~/Music/christmas/Glee - Jingle Bell Rock (Lyrics)-VfLf7A_-1Vw.webm")
(find-file "~/1-music-notation/3-my-transcriptions/Glee - Jingle Bell Rock/music/")
(launch-file "~/1-music-notation/3-my-transcriptions/Glee - Jingle Bell Rock/output/Glee - Jingle Bell Rock-pacON.pdf"))
("Video editing"
(start-process "flatpak" nil "flatpak" "run" "org.kde.kdenlive"
"/home/khilona/Videos/ghar ghar theatre 3/ggt3.kdenlive")
(find-alternate-file-other-window "/home/khilona/Videos/ghar ghar theatre 3/"
;; "/home/khilona/Videos/podcast/"
))
("Wiktionary"
(find-file-other-window
"~/phone/Nokia 6.1/Documents/Markor/Languages/hindi.md"))
("Writing"
(find-file-other-window
"/home/anon/phone/Nokia 6.1/Documents/Markor/Songs or Poems/"))))
(autoload 'magit-anything-modified-p "magit")
(defun contrapunctus-commit-prompt ()
"Prompt user if `default-directory' is a dirty Git repository.
Return t if the user answers yes, if the repository is clean, or
if there is no Git repository.
Return nil (and run `magit-status') if the user answers no."
(cond ((not (magit-anything-modified-p)) t)
((yes-or-no-p
(format "You have uncommitted changes in %S. Really clock out? "
default-directory)) t)
(t (magit-status) nil)))
(defun contrapunctus-before-project-stop (project)
(if (member project '("Composing"
"Khilona archiving"
"Programming"))
(contrapunctus-commit-prompt)
;; all functions in `chronometrist-before-project-stop-functions'
;; must return t for successful clock-out
t))
(require 'request)
(require 'esxml-query)
(defun contrapunctus-after-project-stop (project)
(pcase project
("OSM"
(delete-other-windows)
;; What should we do when there's no network connectivity?
;; Ideally - note the clock-out time, and retry every five
;; minutes. When connected, request the changesets, look for the
;; first changeset with a "created_at" which is less than the
;; clock-out time.
(request
"https://api.openstreetmap.org/api/0.6/changesets"
:params '(("display_name" . "contrapunctus"))
:parser (lambda () (libxml-parse-xml-region (point) (point-max)))
:success
(cl-function
(lambda (&key data &allow-other-keys)
(let* ((latest-changeset (-> data
(esxml-node-children)
(car)))
(comment (->> latest-changeset
(esxml-query "[k=comment]")
(esxml-node-attributes)
(cdr)
(car)
(cdr)))
(id (-> latest-changeset
(esxml-node-attributes)
(car)
(cdr))))
(chronometrist-append-to-last-expr nil
`(:osm-url ,(concat "https://www.openstreetmap.org/changeset/" id)
:osm-comment ,comment)))))))
(_ (delete-other-windows))))
(defun contrapunctus-count-expressions ()
(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))))
(provide 'cp-chronometrist)
;; Local Variables:
;; nameless-current-name: nil
;; End: