diff options
author | Alex Kost <alezost@gmail.com> | 2014-11-10 15:30:21 +0300 |
---|---|---|
committer | Alex Kost <alezost@gmail.com> | 2014-11-10 16:13:41 +0300 |
commit | 37c4ffc2c420885cf7b5933eacee17e17d64933e (patch) | |
tree | 581ef48a4b9e47d1ac78472f0ff5f7a8ce561c65 | |
parent | e718f6cc8fcfaddc730423b7fe4acbd4b85101f8 (diff) | |
download | guix-37c4ffc2c420885cf7b5933eacee17e17d64933e.tar.gz |
emacs: Improve 'guix-redisplay-buffer'.
* emacs/guix-base.el (guix-redisplay-buffer): Allow to display new entries. Restore point position.
-rw-r--r-- | emacs/guix-base.el | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el index 784474e333..a6e56dced1 100644 --- a/emacs/guix-base.el +++ b/emacs/guix-base.el @@ -640,14 +640,41 @@ See `revert-buffer' for the meaning of NOCONFIRM." (guix-set-buffer guix-profile entries guix-buffer-type guix-entry-type search-type search-vals t t)))) -(defun guix-redisplay-buffer () - "Redisplay current information. +(cl-defun guix-redisplay-buffer (&key buffer profile entries buffer-type + entry-type search-type search-vals) + "Redisplay a Guix BUFFER. +Restore the point and window positions after redisplaying if possible. + This function will not update the information, use -\"\\[revert-buffer]\" if you want the full update." +\"\\[revert-buffer]\" if you want the full update. + +If BUFFER is nil, use the current buffer. For the meaning of the +rest arguments, see `guix-set-buffer'." (interactive) - (guix-show-entries guix-entries guix-buffer-type guix-entry-type) - (guix-result-message guix-profile guix-entries guix-entry-type - guix-search-type guix-search-vals)) + (or buffer (setq buffer (current-buffer))) + (with-current-buffer buffer + (or (derived-mode-p 'guix-info-mode 'guix-list-mode) + (error "%S is not a Guix buffer" buffer)) + (let* ((point (point)) + (was-at-button (button-at point)) + ;; For simplicity, ignore an unlikely case when multiple + ;; windows display the same BUFFER. + (window (car (get-buffer-window-list buffer nil t))) + (window-start (and window (window-start window)))) + (guix-set-buffer (or profile guix-profile) + (or entries guix-entries) + (or buffer-type guix-buffer-type) + (or entry-type guix-entry-type) + (or search-type guix-search-type) + (or search-vals guix-search-vals) + t t) + (goto-char point) + (and was-at-button + (not (button-at (point))) + (forward-button 1)) + (when window + (set-window-point window (point)) + (set-window-start window window-start))))) ;;; Generations |