[chronometrist-details] expand key-value display function
This commit is contained in:
parent
306dd277ea
commit
efdd14695a
57
init.org
57
init.org
|
@ -555,18 +555,55 @@ Return nil (and run `magit-status') if the user answers no."
|
|||
|
||||
***** display-key-values
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun contrapunctus-objects-to-string (separator &rest args)
|
||||
(mapconcat (lambda (elt)
|
||||
(format "%s" elt))
|
||||
(flatten-list
|
||||
(seq-filter #'identity args))
|
||||
separator))
|
||||
|
||||
(defun contrapunctus-display-key-values-function (plist)
|
||||
"Function used to print key-values in `chronometrist-details' buffers."
|
||||
(if (chronometrist-plist-key-values plist)
|
||||
(pcase (plist-get plist :name)
|
||||
("Programming"
|
||||
(-let [(&plist :project project
|
||||
:feature feature) plist]
|
||||
(--> (list project feature)
|
||||
(-interpose " " it)
|
||||
(apply #'concat it))))
|
||||
(t "Task not implemented"))
|
||||
""))
|
||||
(let ((key-values (chronometrist-plist-key-values plist)))
|
||||
(pcase (plist-get plist :name)
|
||||
("Programming"
|
||||
(-let [(&plist :project project
|
||||
:feature feature
|
||||
:component component) plist]
|
||||
(contrapunctus-objects-to-string " " project feature component)))
|
||||
("Guitar"
|
||||
(-let* (((&plist :piece
|
||||
(&plist :name name
|
||||
:bwv bwv :opus opus
|
||||
:movement movement))
|
||||
plist)
|
||||
(catalog (format "(%s)" (or opus bwv)))
|
||||
(movement (cond ((not movement) "")
|
||||
((chronometrist-plist-pp-alist-p movement)
|
||||
(contrapunctus-objects-to-string ", " " - " (mapcar #'cdr movement)))
|
||||
(t (format "- %s" (cdr movement))))))
|
||||
(contrapunctus-objects-to-string " " name catalog movement)))
|
||||
("Cooking"
|
||||
(-let (((&plist :recipe (&plist :name name)) plist)
|
||||
((&plist :recipe recipe) plist))
|
||||
recipe))
|
||||
("Video editing"
|
||||
(-let [(&plist :episode ep) plist]
|
||||
(contrapunctus-objects-to-string " " "episode" ep)))
|
||||
(_ "Task not implemented"))))
|
||||
|
||||
;; (-let [(&plist :recipe recipe)
|
||||
;; '(:name "Cooking"
|
||||
;; :recipe "rajma"
|
||||
;; :start "2021-05-26T20:33:48+0530")]
|
||||
;; recipe)
|
||||
|
||||
;; (pcase-let (((_ :recipe recipe _)
|
||||
;; '(:name "Cooking"
|
||||
;; :recipe "rajma"
|
||||
;; :start "2021-05-26T20:33:48+0530")))
|
||||
;; recipe)
|
||||
|
||||
#+END_SRC
|
||||
**** key-values
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
|
|
Loading…
Reference in New Issue