diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-24 12:54:42 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-24 12:54:42 +0000 |
commit | dce1f846b63d029a3f4175e5fb95513e2e355bbc (patch) | |
tree | fe2eb00e4520c4ecfcdd8e604935a84703421281 | |
parent | 53ca78edba5cd1210a2996fc29716cf75eafa032 (diff) |
Fix next-page logic
-rw-r--r-- | sx-question-list.el | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sx-question-list.el b/sx-question-list.el index 68bb55b..708c6eb 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -412,23 +412,23 @@ This does not update `sx-question-mode--window'." (interactive "p") (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))))) + (forward-line n) + ;; If we were trying to move forward, but we hit the end. + (when (eobp) + ;; 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)))) + ;; Try to be at the right place. + (goto-char (point-max)) + (forward-line -1) (if (null list) - (progn (message "No further questions.") - (forward-line 0)) - ;; Try to be at the right place. - (goto-char (point-max)) + (message "No further questions.") + ;; @TODO: Check for duplicates. (setq sx-question-list--dataset (append sx-question-list--dataset list)) (sx-question-list-refresh 'redisplay 'no-update) |