aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-11-24 10:43:13 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-11-24 10:43:13 +0000
commit315c8ad1673e5925a67dcf8b821917a623660603 (patch)
treedb8e4f0eedbea9d5df649ae6283ebd2949124a67
parenta8312b07d225900f3b45bf030dd72369d7477fdb (diff)
Moving above the top or below the end refreshes
-rw-r--r--sx-question-list.el24
1 files changed, 23 insertions, 1 deletions
diff --git a/sx-question-list.el b/sx-question-list.el
index ffbb584..6775a27 100644
--- a/sx-question-list.el
+++ b/sx-question-list.el
@@ -370,7 +370,29 @@ that may currently be there."
"Move cursor down N questions.
This does not update `sx-question-mode--window'."
(interactive "p")
- (forward-line n))
+ (if (and (< n 0) (bobp))
+ (sx-question-list-refresh 'redisplay)
+ (let ((line (line-number-at-pos (point))))
+ (forward-line n)
+ ;; If we were trying to move forward, but we hit the end.
+ (when (and (> n 0) (= line (line-number-at-pos (point))))
+ ;; Try to get more questions.
+ (sx-question-list-next-page)))))
+
+(defun sx-question-list-next-page ()
+ "Fetch and display the next page of questions."
+ (interactive)
+ (let ((list (when sx-question-list--next-page-function
+ (funcall sx-question-list--next-page-function))))
+ (if (null list)
+ (progn (message "No further questions.")
+ (forward-line 0))
+ ;; Try to be at the right place.
+ (goto-char (point-max))
+ (setq sx-question-list--dataset
+ (append sx-question-list--dataset list))
+ (sx-question-list-refresh 'redisplay 'no-update)
+ (forward-line 1))))
(defun sx-question-list-previous (n)
"Move cursor up N questions.