branch: elpa/hyperdrive commit 509f72b4f0ef685cedec9c354253b52bced42e58 Author: Joseph Turner <jos...@ushin.org> Commit: Joseph Turner <jos...@ushin.org>
Change: (hyperdrive-history) Display history buffer immediately Previously, this function called hyperdrive-fill-version-ranges before displaying the buffer. Now, the history buffer is displayed immediately to the user. --- hyperdrive-history.el | 135 ++++++++++++++++++++++++-------------------------- 1 file changed, 66 insertions(+), 69 deletions(-) diff --git a/hyperdrive-history.el b/hyperdrive-history.el index 160e631a23..c1a62f4e54 100644 --- a/hyperdrive-history.el +++ b/hyperdrive-history.el @@ -149,75 +149,72 @@ Universal prefix argument \\[universal-argument] forces hyperdrive-current-entry))) ;; TODO: Highlight range for ENTRY (when (hyperdrive--entry-directory-p entry) - (hyperdrive-user-error "Directory history not yet implemented")) - (hyperdrive-fill-version-ranges entry :then - (lambda () - (pcase-let* (((cl-struct hyperdrive-entry hyperdrive path) entry) - (range-entries - (mapcar (lambda (range) - ;; Some entries may not exist at - ;; `range-start', as in the version before - ;; it was created. See manual: - ;; [[info:hyperdrive-manual.info#Versioning]] - (cons range - (hyperdrive-entry-create - :hyperdrive hyperdrive - :path path - ;; Set version to range-start - :version (car range)))) - ;; Display in reverse chronological order - (nreverse (hyperdrive-entry-version-ranges-no-gaps entry)))) - (main-header (hyperdrive-entry-description entry :with-version nil)) - (header (concat main-header "\n" - (format "%7s %13s %6s %s" - (propertize "Exists?" 'face 'hyperdrive-column-header) - (propertize "Version Range" 'face 'hyperdrive-column-header) - (propertize "Size" 'face 'hyperdrive-column-header) - (format (format "%%%ds" hyperdrive-timestamp-width) - (propertize "Last Modified" 'face 'hyperdrive-column-header))))) - (queue) (ewoc)) - (with-current-buffer (get-buffer-create - (format "*Hyperdrive-history: %s %s*" - (hyperdrive--format-host hyperdrive :format hyperdrive-default-host-format - :with-label t) - (url-unhex-string path))) - (with-silent-modifications - (hyperdrive-history-mode) - (setq-local hyperdrive-current-entry entry) - (setf ewoc hyperdrive-ewoc) ; Bind this for the hyperdrive-fill lambda. - (ewoc-filter hyperdrive-ewoc #'ignore) - (erase-buffer) - (ewoc-set-hf hyperdrive-ewoc header "") - (mapc (lambda (range-entry) - (ewoc-enter-last hyperdrive-ewoc range-entry)) - range-entries)) - ;; TODO: Display files in pop-up window, like magit-diff buffers appear when selected from magit-log - (display-buffer (current-buffer) hyperdrive-history-display-buffer-action) - (setf queue (make-plz-queue :limit hyperdrive-queue-size - :finally (lambda () - ;; NOTE: Ensure that the buffer's window is selected, - ;; if it has one. (Workaround a possible bug in EWOC.) - (if-let ((buffer-window (get-buffer-window (ewoc-buffer ewoc)))) - (with-selected-window buffer-window - ;; TODO: Use `ewoc-invalidate' on individual entries - ;; (maybe later, as performance comes to matter more). - (with-silent-modifications (ewoc-refresh hyperdrive-ewoc)) - (goto-char (point-min))) - (with-current-buffer (ewoc-buffer ewoc) - (with-silent-modifications (ewoc-refresh hyperdrive-ewoc)) - (goto-char (point-min)))) - ;; TODO: Accept then argument? - ;; (with-current-buffer (ewoc-buffer ewoc) - ;; (when then - ;; (funcall then))) - ))) - (mapc (lambda (range-entry) - (when (eq t (hyperdrive-range-entry-exists-p range-entry)) - ;; TODO: Handle failures? - (hyperdrive-fill (cdr range-entry) :queue queue :then #'ignore))) - range-entries) - (set-buffer-modified-p nil) - (goto-char (point-min))))))) + (hyperdrive-user-error "Directory history not implemented.")) + (pcase-let* (((cl-struct hyperdrive-entry hyperdrive path) entry) + (range-entries + (mapcar (lambda (range) + ;; Some entries may not exist at `range-start', + ;; as in the version before it was created, see: + ;; (info "(hyperdrive)Versioning") + (cons range + (hyperdrive-entry-create + :hyperdrive hyperdrive + :path path + ;; Set version to range-start + :version (car range)))) + ;; Display in reverse chronological order + (nreverse (hyperdrive-entry-version-ranges-no-gaps entry)))) + (main-header (hyperdrive-entry-description entry :with-version nil)) + (header (concat main-header "\n" + (format "%7s %13s %6s %s" + (propertize "Exists?" 'face 'hyperdrive-column-header) + (propertize "Version Range" 'face 'hyperdrive-column-header) + (propertize "Size" 'face 'hyperdrive-column-header) + (format (format "%%%ds" hyperdrive-timestamp-width) + (propertize "Last Modified" 'face 'hyperdrive-column-header))))) + (queue) (ewoc)) + (with-current-buffer (get-buffer-create + (format "*Hyperdrive-history: %s %s*" + (hyperdrive--format-host hyperdrive :format hyperdrive-default-host-format + :with-label t) + (url-unhex-string path))) + (with-silent-modifications + (hyperdrive-history-mode) + (setq-local hyperdrive-current-entry entry) + (setf ewoc hyperdrive-ewoc) ; Bind this for the hyperdrive-fill lambda. + (ewoc-filter hyperdrive-ewoc #'ignore) + (erase-buffer) + (ewoc-set-hf hyperdrive-ewoc header "") + (mapc (lambda (range-entry) + (ewoc-enter-last hyperdrive-ewoc range-entry)) + range-entries)) + ;; TODO: Display files in pop-up window, like magit-diff buffers appear when selected from magit-log + (display-buffer (current-buffer) hyperdrive-history-display-buffer-action) + (setf queue (make-plz-queue :limit hyperdrive-queue-size + :finally (lambda () + ;; NOTE: Ensure that the buffer's window is selected, + ;; if it has one. (Workaround a possible bug in EWOC.) + (if-let ((buffer-window (get-buffer-window (ewoc-buffer ewoc)))) + (with-selected-window buffer-window + ;; TODO: Use `ewoc-invalidate' on individual entries + ;; (maybe later, as performance comes to matter more). + (with-silent-modifications (ewoc-refresh hyperdrive-ewoc)) + (goto-char (point-min))) + (with-current-buffer (ewoc-buffer ewoc) + (with-silent-modifications (ewoc-refresh hyperdrive-ewoc)) + (goto-char (point-min)))) + ;; TODO: Accept then argument? + ;; (with-current-buffer (ewoc-buffer ewoc) + ;; (when then + ;; (funcall then))) + ))) + (mapc (lambda (range-entry) + (when (eq t (hyperdrive-range-entry-exists-p range-entry)) + ;; TODO: Handle failures? + (hyperdrive-fill (cdr range-entry) :queue queue :then #'ignore))) + range-entries) + (set-buffer-modified-p nil) + (goto-char (point-min))))) (declare-function hyperdrive-diff-file-entries "hyperdrive-diff") (defun hyperdrive-history-diff (old-entry new-entry)