aboutsummaryrefslogtreecommitdiff
path: root/sx-question-mode.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2014-12-03 17:59:02 -0500
committerSean Allred <code@seanallred.com>2014-12-03 17:59:02 -0500
commit6b2ecadd89e31feb994883987c38f6988a140b8c (patch)
treec77890b4800813287f5d2fdf38effd389c219164 /sx-question-mode.el
parent114ca09da984738df2510bc72753a3443d16857c (diff)
parent67b60ea558f0386a1ea3dadcf3a9c4d22d398620 (diff)
Merge branch 'master' into issue-130
Conflicts: sx-request.el Conflict was trivial.
Diffstat (limited to 'sx-question-mode.el')
-rw-r--r--sx-question-mode.el20
1 files changed, 17 insertions, 3 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el
index b685ea7..bccb658 100644
--- a/sx-question-mode.el
+++ b/sx-question-mode.el
@@ -30,8 +30,13 @@
;;; Displaying a question
-(defvar sx-question-mode--window nil
- "Window where the content of questions is displayed.")
+(defcustom sx-question-mode-display-buffer-function #'switch-to-buffer
+ "Function used to display the question buffer.
+Called, for instance, when hitting \\<sx-question-list-mode-map>`\\[sx-question-list-display-question]' on an entry in the
+question list.
+This is not used when navigating the question list with `\\[sx-question-list-view-next]."
+ :type 'function
+ :group 'sx-question-mode)
(defvar sx-question-mode--buffer nil
"Buffer being used to display questions.")
@@ -39,6 +44,14 @@
(defvar sx-question-mode--data nil
"The data of the question being displayed.")
+(defun sx-question-mode--get-window ()
+ "Return a window displaying a question, or nil."
+ (car-safe
+ (cl-member-if
+ (lambda (x) (with-selected-window x
+ (derived-mode-p 'sx-question-mode)))
+ (window-list nil 'never nil))))
+
(defun sx-question-mode--display (data &optional window)
"Display question given by DATA on WINDOW.
If WINDOW is nil, use selected one.
@@ -71,7 +84,8 @@ If WINDOW is given, use that to display the buffer."
;; No window, but the buffer is already being displayed somewhere.
((get-buffer-window sx-question-mode--buffer 'visible))
;; Neither, so we create the window.
- (t (switch-to-buffer sx-question-mode--buffer)))
+ (t (funcall sx-question-mode-display-buffer-function
+ sx-question-mode--buffer)))
sx-question-mode--buffer)