From 244aca25de91f6b6e5e9d59775ab05f0669df80c Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 26 Nov 2014 12:22:34 +0000 Subject: Preserve visual position when refreshing Both for question list and question mode. --- sx-question-mode.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sx-question-mode.el') 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." -- cgit v1.2.3