emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/vundo 7c64a07705 5/7: Merge branch 'pr-enter-exit-hooks


From: ELPA Syncer
Subject: [elpa] externals/vundo 7c64a07705 5/7: Merge branch 'pr-enter-exit-hooks'
Date: Sun, 24 Apr 2022 18:57:53 -0400 (EDT)

branch: externals/vundo
commit 7c64a077055d61cbdc8f698154f5283c307c8bbc
Merge: fd780553f3 5718b635e9
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Merge branch 'pr-enter-exit-hooks'
---
 vundo.el | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/vundo.el b/vundo.el
index 787f0f1918..7ab9b3c29a 100644
--- a/vundo.el
+++ b/vundo.el
@@ -253,6 +253,18 @@ characters."
                        :value-type (character :tag "Draw using")
                        :options ,(mapcar #'car vundo-unicode-symbols)))
 
+(defcustom vundo-pre-enter-hook nil
+  "List of functions to call when entering vundo.
+This hook runs immediately after ‘vundo’ is called, in the buffer
+the user invoked ‘vundo’, before every setup ‘vundo’ does."
+  :type 'hook)
+
+(defcustom vundo-post-exit-hook nil
+  "List of functions to call when entering vundo.
+This hook runs after every clean up the exiting function does.
+Ie, it is the very last thing that happens when vundo exists."
+  :type 'hook)
+
 ;;; Undo list to mod list
 
 (cl-defstruct vundo-m
@@ -732,6 +744,7 @@ This function modifies ‘vundo--prev-mod-list’,
   (interactive)
   (when (not (consp buffer-undo-list))
     (user-error "There is no undo history"))
+  (run-hooks 'vundo-pre-enter-hook)
   (let ((vundo-buf (vundo-1 (current-buffer))))
     (select-window
      (display-buffer-in-side-window
@@ -805,14 +818,20 @@ Roll back changes if `vundo-roll-back-on-quit' is 
non-nil."
       vundo--orig-buffer vundo--prev-mod-list))
    (with-current-buffer vundo--orig-buffer
      (setq-local buffer-read-only nil))
-   (kill-buffer-and-window)))
+   (let ((orig-buffer vundo--orig-buffer))
+     (kill-buffer-and-window)
+     (with-current-buffer orig-buffer
+       (run-hooks 'vundo-post-exit-hook)))))
 
 (defun vundo-confirm ()
   "Confirm change and close vundo window."
   (interactive)
   (with-current-buffer vundo--orig-buffer
     (setq-local buffer-read-only nil))
-  (kill-buffer-and-window))
+  (let ((orig-buffer vundo--orig-buffer))
+    (kill-buffer-and-window)
+    (with-current-buffer orig-buffer
+      (run-hooks 'vundo-post-exit-hook))))
 
 ;;; Traverse undo tree
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]