Function: forge--read-topic

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

Signature

(forge--read-topic PROMPT CURRENT ACTIVE ALL)

Source Code

;; Defined in ~/.emacs.d/elpa/forge-20260408.1922/forge-topic.el
(defun forge--read-topic (prompt current active all)
  (let* ((current (funcall current))
         (repo    (forge-get-repository (or current :tracked)))
         (default (and current (forge--format-topic-line current)))
         (alist   (forge--topic-collection
                   (forge--list-topics (if forge-limit-topic-choices active all)
                                       repo)))
         (choices (mapcar #'car alist))
         (choices (cond ((and forge-limit-topic-choices
                              default
                              (not (member default choices)))
                         (push (cons default (oref current id)) alist)
                         (cons default choices))
                        (choices)))
         (choice
          (if forge-limit-topic-choices
              (minibuffer-with-setup-hook
                  (lambda ()
                    (use-local-map (make-composed-keymap
                                    forge-read-topic-minibuffer-map
                                    (current-local-map))))
                (magit-completing-read
                 (substitute-command-keys
                  (format "%s (\\<%s>\\[%s] for all)" prompt
                          'forge-read-topic-minibuffer-map
                          'forge-read-topic-lift-limit))
                 (completion-table-dynamic
                  (let (all-choices)
                    (lambda (_string)
                      ;; For other frameworks, the minibuffer is current
                      ;; when this function is called, but for Helm we
                      ;; have to make it so.  Starting with Helm commit
                      ;; 5e7c8498, this isn't necessary anymore.  See
                      ;; https://github.com/emacs-helm/helm/issues/2744.
                      (with-selected-window (minibuffer-window)
                        (cond
                          (all-choices)
                          (forge-limit-topic-choices choices)
                          (t
                           (setq alist (forge--topic-collection
                                        (forge--list-topics all repo)))
                           (setq all-choices (mapcar #'car alist))))))))
                 nil t nil nil default))
            (magit-completing-read prompt choices nil t nil nil default))))
    (cdr (assoc choice alist))))