Skip to content

Commit 3cde5fc

Browse files
committed
Support lifting topic limit on the fly when using Helm
When using built-in completion, vertico, and I assume most other completion frameworks, `forge-read-topic-lift-limit' can call some function which causes the `completion-table-dynamic' function to be called again. Calling `helm-force-update' does not do that. It also does not call `forge--read-topic' again. It does however do some recalculations (I don't understand how), which do take `forge-limit-topic-choices' into account. When that calculation takes place, the minibuffer is not current, and because we temporarily lift the limit by setting `forge-limit-topic-choices' to nil in that buffer, that means that for Helm the limit is still in place. Trying to counter act this by making the minibuffer, or the helm buffer, current when setting the variable and/or when calling `helm-force-update', did not work. So we have to set the global value instead. But that would mean that the filter remains off for all future invocations. So we have to re-enable filtering, every time `forge--read-topic' is invoked. But some users might want to actually remove the filter for good, so we have to give them another variable that the can use to make their preference known: `forge-read-topic-lift-limit-for-helm'. See emacs-helm/helm#2744.
1 parent b372fad commit 3cde5fc

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

lisp/forge-topic.el

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
;;; Options
4747

4848
(defcustom forge-limit-topic-choices t
49-
"Whether to initially limit completion candidates to active topics."
49+
"Whether to initially limit completion candidates to active topics.
50+
51+
For Helm users setting this option has no effect. Instead they have
52+
to set the value of the variable `forge-limit-topic-choices-for-helm'."
5053
:package-version '(forge . "0.4.0")
5154
:group 'forge
5255
:type 'boolean)
@@ -719,7 +722,12 @@ can be selected from the start."
719722
(forge--topics-spec :type 'topic :active t)
720723
(forge--topics-spec :type 'topic :active nil :state nil)))
721724

725+
(defvar forge-limit-topic-choices-for-helm t
726+
"Like `forge-limit-topic-choices' (which see) but for Helm users.")
727+
722728
(defun forge--read-topic (prompt current active all)
729+
(when (bound-and-true-p helm-mode)
730+
(setq forge-limit-topic-choices forge-limit-topic-choices-for-helm))
723731
(let* ((current (funcall current))
724732
(repo (forge-get-repository (or current :tracked)))
725733
(default (and current (forge--format-topic-line current)))
@@ -772,16 +780,22 @@ can be selected from the start."
772780
(interactive)
773781
(when (and (minibufferp)
774782
forge-limit-topic-choices)
775-
(setq-local forge-limit-topic-choices nil)
776-
(forge-read-topic--remove-prompt-hint)
777783
(cond
778784
((and (bound-and-true-p vertico-mode)
779785
(boundp 'vertico--input)
780786
(fboundp 'vertico--exhibit))
787+
(setq-local forge-limit-topic-choices nil)
781788
(setq vertico--input t)
782789
(vertico--exhibit))
783-
((minibuffer-completion-help (minibuffer--completion-prompt-end)
784-
(point-max))))))
790+
((and (bound-and-true-p helm-mode)
791+
(fboundp 'helm-force-update))
792+
(setq forge-limit-topic-choices nil)
793+
(helm-force-update))
794+
(t
795+
(setq-local forge-limit-topic-choices nil)
796+
(minibuffer-completion-help (minibuffer--completion-prompt-end)
797+
(point-max))))
798+
(forge-read-topic--remove-prompt-hint)))
785799

786800
(defun forge-read-topic--remove-prompt-hint ()
787801
(when (minibufferp)

0 commit comments

Comments
 (0)