Function: forge--format-labels

forge--format-labels is a byte-compiled function defined in forge-topic.el.

Signature

(forge--format-labels &optional ARG CONCAT)

Source Code

;; Defined in ~/.emacs.d/elpa/forge-20260408.1922/forge-topic.el
(defun forge--format-labels (&optional arg concat)
  (and-let*
      ((local t)
       (labels (cond
                 ((eieio-object-p arg)
                  (oref arg labels))
                 ((forge-buffer-repository)
                  (forge-sql-cdr `[:select label:* :from label :where
                                   ,(if arg
                                        '(and (= repository $s1)
                                              (in name $v2))
                                      '(= repository $s1))
                                   :order-by [(asc name)]]
                                 forge-buffer-repository
                                 (vconcat arg)))
                 (t
                  (setq local nil)
                  (forge-sql `[:select :distinct name :from label
                               ,@(and arg '(:where (in name $v1)))
                               :order-by [(asc name)]]
                             (vconcat arg)))))
       (format (if local
                   (pcase-lambda (`(,_id ,name ,color ,_description))
                     (let* ((background (forge--sanitize-color color))
                            (foreground (readable-foreground-color background)))
                       (magit--propertize-face
                        name `(( :background ,background
                                 :foreground ,foreground)
                               forge-topic-label))))
                 (pcase-lambda (`(,name))
                   (magit--propertize-face name 'forge-topic-label)))))
    (if concat
        (mapconcat format labels (if (stringp concat) concat " "))
      (mapcar format labels))))