diff options
author | Sean Allred <code@seanallred.com> | 2015-01-02 09:00:27 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2015-01-02 09:00:27 -0500 |
commit | b87903a14b5b6da5b847ed64de34df00971cbb4a (patch) | |
tree | d75e0564b947655e996b3fe8387704557c3c5c4a /sx-interaction.el | |
parent | 80541f53ab81695f5878055ac4404ee212766b11 (diff) |
Introduce convencience function for site prompting
Arose from comment discussion at [1]. This function allows for
simplified syntax when the use case wants to retrieve a site token in an
interactive context. See docstring for details.
[1]: https://github.com/vermiculus/sx.el/pull/183/files#r22403919
Diffstat (limited to 'sx-interaction.el')
-rw-r--r-- | sx-interaction.el | 12 |
1 files changed, 12 insertions, 0 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. |