Skip to content

Commit

Permalink
[dump] label
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed May 23, 2024
1 parent f573584 commit 8a4b1e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
32 changes: 19 additions & 13 deletions lisp/forge-topic.el
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,9 @@ can be selected from the start."
(crm-separator ","))
(magit-completing-read-multiple
"Labels: "
(mapcar #'cadr (oref repo labels))
(forge--format-labels repo)
nil t
(and topic (mapconcat #'car (closql--iref topic 'labels) ",")))))
(and topic (mapconcat #'identity (forge--format-labels topic) ", ")))))

(defun forge-read-topic-marks (&optional topic)
(let ((marks (mapcar #'car (forge-sql [:select name :from mark])))
Expand Down Expand Up @@ -801,16 +801,21 @@ can be selected from the start."
(and-let* ((id (oref topic milestone)))
(caar (forge-sql [:select [title] :from milestone :where (= id $s1)] id))))

(defun forge--format-topic-labels (topic)
(and-let* ((labels (closql--iref topic 'labels)))
(mapconcat (pcase-lambda (`(,name ,color ,_description))
(let* ((background (forge--sanitize-color color))
(foreground (forge--contrast-color background)))
(magit--propertize-face
name `(( :background ,background
:foreground ,foreground)
forge-topic-label))))
labels " ")))
(cl-defmethod forge--format-labels ((topic forge-topic))
(mapcar (pcase-lambda (`(,name ,color ,_description))
(let* ((background (forge--sanitize-color color))
(foreground (forge--contrast-color background)))
(magit--propertize-face
name `(( :background ,background
:foreground ,foreground)
forge-topic-label))))
(closql--iref topic 'labels))) ;TODO inline

(cl-defmethod forge--format-labels ((repo forge-repository)) ;TODO
(mapcar #'cadr (oref repo labels)))

(cl-defmethod forge--format-labels ((labels list)) ;TODO
labels)

(defun forge--format-topic-marks (topic)
(and-let* ((marks (closql--iref topic 'marks)))
Expand Down Expand Up @@ -1397,7 +1402,8 @@ This mode itself is never used directly."

(transient-define-suffix forge-topic-set-labels (labels)
"Edit the LABELS of the current topic."
:class 'forge--topic-set-slot-command :slot 'labels)
:class 'forge--topic-set-slot-command :slot 'labels
:formatter #'forge--format-labels)

(transient-define-suffix forge-topic-set-marks (marks)
"Edit the MARKS of the current topic."
Expand Down
3 changes: 2 additions & 1 deletion lisp/forge-topics.el
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,8 @@ then display the respective menu, otherwise display no menu."
(transient-define-suffix forge-topics-filter-labels ()
"Read labels and limit topic list to topics with one of these labels."
:class 'forge--topics-filter-command
:slot 'labels)
:slot 'labels
:formatter #'forge--format-labels)

(transient-define-suffix forge-topics-filter-marks ()
"Read marks and limit topic list to topics with one of these marks."
Expand Down

0 comments on commit 8a4b1e8

Please sign in to comment.