aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-12-01 01:46:34 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-12-01 02:01:53 +0000
commit867224348a5d979af7a965c9bbe476dea3c3638f (patch)
tree2015e5465ca3f1b32d4c8294037e6dd3900ad23d
parentf0d788a34a6d3e9ea564299703c35eee26f64374 (diff)
Refactor sx-question-mode--window into a function.
It made little sense the way it was, and it was complicated. Now that it's a function, it's always up to date.
-rw-r--r--sx-question-mode.el11
1 files changed, 8 insertions, 3 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el
index 6423ad8..bee3e29 100644
--- a/sx-question-mode.el
+++ b/sx-question-mode.el
@@ -38,15 +38,20 @@ This is not used when navigating the question list with `\\[sx-question-list-vie
:type 'function
:group 'sx-question-mode)
-(defvar sx-question-mode--window nil
- "Window where the content of questions is displayed.")
-
(defvar sx-question-mode--buffer nil
"Buffer being used to display questions.")
(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.