biome-query: fix line variables

This commit is contained in:
Pavel Korytov 2023-07-18 23:26:05 +03:00
parent 270dcb92a9
commit 09f37690cd

View file

@ -137,7 +137,7 @@ case, the value is a list of variable names available in the group.")
"Format the current report." "Format the current report."
(let ((group (alist-get :group biome-query-current)) (let ((group (alist-get :group biome-query-current))
(var-names (biome-query--get-var-names-cache)) (var-names (biome-query--get-var-names-cache))
lat lon group-vars vars) lat lon group-vars line-vars vars)
(dolist (item (alist-get :params biome-query-current)) (dolist (item (alist-get :params biome-query-current))
(cond (cond
((stringp item) ((stringp item)
@ -151,22 +151,32 @@ case, the value is a list of variable names available in the group.")
(setq lon (cdr item))) (setq lon (cdr item)))
((member (car item) '("end_date" "start_date")) ((member (car item) '("end_date" "start_date"))
(push (push
(format "%s: %s" (propertize (gethash (car item) var-names) (format "%s: %s" (propertize
'face 'font-lock-variable-name-face) (gethash (car item) var-names (capitalize (car item)))
'face 'font-lock-variable-name-face)
(propertize (propertize
(format-time-string biome-query-date-format (cdr item)) (format-time-string biome-query-date-format (cdr item))
'face 'transient-value-face)) 'face 'transient-value-face))
vars)) vars))
((listp (cdr item))
(push
(format "%s: %s"
(gethash (car item) var-names (capitalize (car item)))
(propertize
(mapconcat #'identity (cdr item) "; ")
'face 'font-lock-variable-name-face))
line-vars))
(t (push (t (push
(format "%s: %s" (format "%s: %s"
(propertize (propertize
(gethash (car item) var-names) (gethash (car item) var-names (capitalize (car item)))
'face 'font-lock-variable-name-face) 'face 'font-lock-variable-name-face)
(propertize (propertize
(prin1-to-string (cdr item)) (prin1-to-string (cdr item))
'face 'transient-value-face)) 'face 'transient-value-face))
vars)))) vars))))
(setq group-vars (nreverse group-vars) (setq group-vars (nreverse group-vars)
line-vars (nreverse line-vars)
vars (nreverse vars)) vars (nreverse vars))
(concat "Location: " (concat "Location: "
(if lat (propertize (number-to-string lat) 'face 'transient-value) (if lat (propertize (number-to-string lat) 'face 'transient-value)
@ -189,7 +199,9 @@ case, the value is a list of variable names available in the group.")
group-vars "; "))) group-vars "; ")))
(when vars (when vars
(format "Variables: %s\n" (format "Variables: %s\n"
(mapconcat #'identity vars "; ")))))) (mapconcat #'identity vars "; ")))
(when line-vars
(concat (mapconcat #'identity line-vars "\n") "\n")))))
(transient-define-infix biome-query--transient-report-infix () (transient-define-infix biome-query--transient-report-infix ()
:class 'biome-query--transient-report :class 'biome-query--transient-report