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-list.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 2965ede..bb49b54 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -371,19 +371,21 @@ a new list before redisplaying." (setq sx-question-list--unread-count 0) (unless no-update (setq sx-question-list--pages-so-far 1)) - (let ((question-list - (or (and no-update sx-question-list--dataset) - (and (functionp sx-question-list--refresh-function) - (funcall sx-question-list--refresh-function)) - (and (functionp sx-question-list--next-page-function) - (funcall sx-question-list--next-page-function 1)) - sx-question-list--dataset))) + (cl-letf ((question-list + (or (and no-update sx-question-list--dataset) + (and (functionp sx-question-list--refresh-function) + (funcall sx-question-list--refresh-function)) + (and (functionp sx-question-list--next-page-function) + (funcall sx-question-list--next-page-function 1)) + sx-question-list--dataset)) + ;; Preserve window positioning. + ((window-start))) (setq sx-question-list--dataset question-list) ;; Print the result. (setq tabulated-list-entries (mapcar sx-question-list--print-function - (cl-remove-if #'sx-question--hidden-p question-list)))) - (when redisplay (tabulated-list-print 'remember))) + (cl-remove-if #'sx-question--hidden-p question-list))) + (when redisplay (tabulated-list-print 'remember)))) (defcustom sx-question-list-ago-string " ago" "String appended to descriptions of the time since something happened. -- cgit v1.2.3 From 16952fa49769398bf47373e7585812ac06392ee8 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 26 Nov 2014 12:24:14 +0000 Subject: Give feedback on finished refresh. Now that position is preserved, refreshing is so discreet that we need some feedback. :) --- sx-question-list.el | 3 ++- sx-question-mode.el | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index bb49b54..98e7736 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -385,7 +385,8 @@ a new list before redisplaying." (setq tabulated-list-entries (mapcar sx-question-list--print-function (cl-remove-if #'sx-question--hidden-p question-list))) - (when redisplay (tabulated-list-print 'remember)))) + (when redisplay (tabulated-list-print 'remember)) + (sx-message "Done."))) (defcustom sx-question-list-ago-string " ago" "String appended to descriptions of the time since something happened. diff --git a/sx-question-mode.el b/sx-question-mode.el index c90e3e1..b2f4604 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -606,7 +606,8 @@ query the api." (goto-char point) (when (equal (selected-window) (get-buffer-window (current-buffer))) - (recenter line)))) + (recenter line))) + (sx-message "Done.")) (defun sx-question-mode--ensure-mode () "Ensures we are in question mode, erroring otherwise." -- cgit v1.2.3 From a104916864ab053fff81dcdcba71e6b8af219913 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 26 Nov 2014 12:28:01 +0000 Subject: Use let instead of letf Older letfs are bugged. --- sx-question-list.el | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 98e7736..fbed4ea 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -371,22 +371,25 @@ a new list before redisplaying." (setq sx-question-list--unread-count 0) (unless no-update (setq sx-question-list--pages-so-far 1)) - (cl-letf ((question-list - (or (and no-update sx-question-list--dataset) - (and (functionp sx-question-list--refresh-function) - (funcall sx-question-list--refresh-function)) - (and (functionp sx-question-list--next-page-function) - (funcall sx-question-list--next-page-function 1)) - sx-question-list--dataset)) - ;; Preserve window positioning. - ((window-start))) + (let* ((question-list + (or (and no-update sx-question-list--dataset) + (and (functionp sx-question-list--refresh-function) + (funcall sx-question-list--refresh-function)) + (and (functionp sx-question-list--next-page-function) + (funcall sx-question-list--next-page-function 1)) + sx-question-list--dataset)) + ;; Preserve window positioning. + (window (get-buffer-window (current-buffer))) + (old-start (when window (window-start window)))) (setq sx-question-list--dataset question-list) ;; Print the result. (setq tabulated-list-entries (mapcar sx-question-list--print-function (cl-remove-if #'sx-question--hidden-p question-list))) (when redisplay (tabulated-list-print 'remember)) - (sx-message "Done."))) + (when window + (set-window-start window old-start))) + (sx-message "Done.")) (defcustom sx-question-list-ago-string " ago" "String appended to descriptions of the time since something happened. -- cgit v1.2.3