branch: externals/agitate commit 629423345e743061c8374332c19048345e8a436b Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Add revert-buffer-function to agitate-vc-git-show --- agitate.el | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/agitate.el b/agitate.el index 39de35dc02..bfd0c76f79 100644 --- a/agitate.el +++ b/agitate.el @@ -318,18 +318,25 @@ The number of completion candidates is limited to the value of `vc-log-show-limit'." (declare (interactive-only t)) (interactive "P") - (when-let* ((file (caadr (vc-deduce-fileset))) ; FIXME 2022-09-27: Better way to get current file? - (revision (agitate--vc-git-get-hash-from-string - (agitate--vc-git-commit-prompt - (when current-file file)))) - (buf "*agitate-vc-git-show*")) - (apply 'vc-git-command (get-buffer-create buf) nil (when current-file file) - (list "show" "--patch-with-stat" revision)) - ;; TODO 2022-09-27: What else do we need to set up in such a - ;; buffer? - (with-current-buffer (pop-to-buffer buf) - (diff-mode) - (goto-char (point-min))))) + (when-let ((file (caadr (vc-deduce-fileset)))) + (let* ((f (when current-file file)) + (revision (agitate--vc-git-get-hash-from-string + (agitate--vc-git-commit-prompt + f))) + (buf "*agitate-vc-git-show*") + (args (list "show" "--patch-with-stat" revision))) + (apply 'vc-git-command (get-buffer-create buf) nil f args) + ;; TODO 2022-09-27: What else do we need to set up in such a + ;; buffer? + (with-current-buffer (pop-to-buffer buf) + (diff-mode) + (setq-local revert-buffer-function + (lambda (_ignore-auto _noconfirm) + (let ((inhibit-read-only t)) + (erase-buffer) + (apply 'vc-git-command (get-buffer buf) nil f args) + (goto-char (point-min))))) + (goto-char (point-min)))))) (defun agitate--vc-git-format-patch-single-commit () "Help `agitate-vc-git-format-patch-single' with its COMMIT."