Create headings in OSM/Chronometrist config code
This commit is contained in:
parent
13edd13ba5
commit
9871aace1a
35
init.org
35
init.org
|
@ -1834,7 +1834,7 @@ choice.el is required by =chronometrist-key-values=
|
|||
;; chronometrist-kv-add
|
||||
;; chronometrist-skip-query-reset
|
||||
)
|
||||
chronometrist-after-out-functions '(contrapunctus-after-project-stop)
|
||||
chronometrist-after-out-functions '(my-after-project-stop)
|
||||
chronometrist-activity-indicator 'my-chronometrist-activity-indicator
|
||||
chronometrist-details-display-key-values #'contrapunctus-display-key-values-function
|
||||
chronometrist-details-schema `[("#" 3 t)
|
||||
|
@ -2322,21 +2322,31 @@ Return nil (and run `magit-status') if the user answers no."
|
|||
FIXME -
|
||||
1. instead of changing the last plist, change the last plist with name "OSM" and without tags or key-values (because a new plist may have been inserted in the meantime)
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package request
|
||||
:ensure t)
|
||||
(use-package esxml
|
||||
:ensure t)
|
||||
(use-package esxml-query)
|
||||
When I clock out of the "OSM" task, this code stores changeset details in it.
|
||||
|
||||
***** Requirements
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package request :ensure t)
|
||||
(use-package esxml :ensure t)
|
||||
(use-package esxml-query)
|
||||
#+END_SRC
|
||||
|
||||
***** my-get-changeset-comment
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun my-get-changeset-comment (changeset)
|
||||
(->> (esxml-query "[k=comment]" changeset)
|
||||
(esxml-node-attributes)
|
||||
(alist-get 'v)))
|
||||
#+END_SRC
|
||||
|
||||
***** my-make-osm-url
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun my-make-osm-url (id)
|
||||
(concat "https://www.openstreetmap.org/changeset/" id))
|
||||
#+END_SRC
|
||||
|
||||
***** my-get-changeset-comment
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun my-get-saved-changeset-id (backend)
|
||||
(-let* (((&plist :changesets saved-changesets)
|
||||
(cl-loop for plist in
|
||||
|
@ -2350,7 +2360,10 @@ FIXME -
|
|||
(((&plist :osm-url last-url)) (last saved-changesets)))
|
||||
(when last-url
|
||||
(first (last (split-string last-url "/"))))))
|
||||
#+END_SRC
|
||||
|
||||
***** my-save-osm-details
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defun my-save-osm-details (&key data &allow-other-keys)
|
||||
(-let* ((backend (chronometrist-active-backend))
|
||||
(last-id (my-get-saved-changeset-id backend))
|
||||
|
@ -2381,7 +2394,10 @@ FIXME -
|
|||
`(:changesets ,new-changesets))))
|
||||
;; (message "Last changeset ID - %s" last-id)
|
||||
(chronometrist-replace-last (chronometrist-active-backend) new-plist)))
|
||||
#+END_SRC
|
||||
|
||||
***** my-save-osm-changeset-details
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun my-save-osm-changeset-details ()
|
||||
"Save OSM changeset details in the Chronometrist file."
|
||||
(request
|
||||
|
@ -2389,8 +2405,11 @@ FIXME -
|
|||
:params '(("display_name" . "contrapunctus"))
|
||||
:parser (lambda () (libxml-parse-xml-region (point) (point-max)))
|
||||
:success #'my-save-osm-details))
|
||||
#+END_SRC
|
||||
|
||||
(defun contrapunctus-after-project-stop (project)
|
||||
***** my-after-project-stop
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun my-after-project-stop (project)
|
||||
(pcase project
|
||||
("OSM"
|
||||
(delete-other-windows)
|
||||
|
|
Loading…
Reference in New Issue