From b87903a14b5b6da5b847ed64de34df00971cbb4a Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 2 Jan 2015 09:00:27 -0500 Subject: 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 --- sx-interaction.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sx-interaction.el') 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. -- cgit v1.2.3 From 57a784d6810ab19771db46d9339b73ab27240b87 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 2 Jan 2015 10:54:26 -0500 Subject: Fix bad docstring Branch: search --- sx-interaction.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index d814485..be9d664 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -347,9 +347,9 @@ from context at point." (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." +If 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 -- cgit v1.2.3