diff options
-rw-r--r-- | sx-interaction.el | 12 | ||||
-rw-r--r-- | sx-search.el | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/sx-interaction.el b/sx-interaction.el index 9ced1ab..d814485 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -345,6 +345,18 @@ from context at point." (sx-site-get-api-tokens) nil t nil nil default))) +(defun sx--maybe-site-prompt (arg) + "Get a site token conditionally in an interactive context. +If PREFIX-ARG is non-nil, use `sx--interactive-site-prompt'. +Otherwise, use `sx-question-list--site' if non-nil. If nil, +use `sx--interactive-site-prompt' anyway." + ;; This could eventually be generalized into (sx--maybe-prompt + ;; prefix-arg value-if-non-nil #'prompt-function). + (if arg + (sx--interactive-site-prompt) + (or sx-question-list--site + (sx--interactive-site-prompt)))) + ;;;###autoload (defun sx-ask (site) "Start composing a question for SITE. diff --git a/sx-search.el b/sx-search.el index 928db5d..2633da9 100644 --- a/sx-search.el +++ b/sx-search.el @@ -74,7 +74,7 @@ of which is allowed to match. Interactively, the user is asked for SITE and QUERY. With a prefix argument, the user is asked for everything." (interactive - (let ((site (sx--interactive-site-prompt)) + (let ((site (sx--maybe-site-prompt current-prefix-arg)) (query (read-string (format "Query (%s): " (if current-prefix-arg "optional" "mandatory")) |