diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-26 12:22:34 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-26 12:22:34 +0000 |
commit | 244aca25de91f6b6e5e9d59775ab05f0669df80c (patch) | |
tree | 14bf81c230f64ad630588d99377d1af7716a7fbc /sx-question-mode.el | |
parent | e9f03bfb583d514ff9c930c551f8e0760f29a598 (diff) |
Preserve visual position when refreshing
Both for question list and question mode.
Diffstat (limited to 'sx-question-mode.el')
-rw-r--r-- | sx-question-mode.el | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el index 70b8866..c90e3e1 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -595,15 +595,18 @@ With non-nil prefix argument NO-UPDATE, just redisplay, don't query the api." (interactive "P") (sx-question-mode--ensure-mode) - (let ((point (point))) + (let ((point (point)) + (line (count-screen-lines + (window-start) (point)))) (sx-question-mode--erase-and-print-question (if no-update sx-question-mode--data (sx-assoc-let sx-question-mode--data (sx-question-get-question .site .question_id)))) (goto-char point) - (when (get-buffer-window (current-buffer)) - (recenter)))) + (when (equal (selected-window) + (get-buffer-window (current-buffer))) + (recenter line)))) (defun sx-question-mode--ensure-mode () "Ensures we are in question mode, erroring otherwise." |