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

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

[elpa] externals/vundo 0bb5c24658 1/2: Quit the vundo-diff window automa


From: ELPA Syncer
Subject: [elpa] externals/vundo 0bb5c24658 1/2: Quit the vundo-diff window automatically.
Date: Fri, 16 Feb 2024 00:59:00 -0500 (EST)

branch: externals/vundo
commit 0bb5c246589bef0a87729ce0adad24901912545e
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>

    Quit the vundo-diff window automatically.
    
    * vundo.el (vundo-quit, vundo-confirm): call vundo-diff--quit on
      quitting vundo.
    
    * vundo-diff.el: new custom option vundo-diff-quit, to specify whether
      to quit or quit and kill the vund-diff buffer.
    
      New function vundo-diff--quit.
---
 vundo-diff.el | 16 ++++++++++++++++
 vundo.el      |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/vundo-diff.el b/vundo-diff.el
index 97207439d9..ffbc153195 100644
--- a/vundo-diff.el
+++ b/vundo-diff.el
@@ -34,6 +34,14 @@
 (require 'diff-mode)
 (eval-when-compile (require 'cl-lib))
 
+(defcustom vundo-diff-quit t
+  "If non-nil, bury the `vundo-diff' window when vundo is quit.
+If set to \\='kill, the diff buffer will also be killed."
+  :group 'vundo
+  :type '(choice (const :tag "Do not quit" nil)
+                 (const :tag "Quit window" t)
+                 (const :tag "Quit window and kill buffer" kill)))
+
 (defface vundo-diff-highlight
   '((((background light)) .
      (:inherit vundo-highlight :foreground "DodgerBlue4"))
@@ -121,6 +129,14 @@ NODE defaults to the current node."
       (delete-overlay vundo-diff--highlight-overlay)
       (setq vundo-diff--highlight-overlay nil))))
 
+(defun vundo-diff--quit ()
+  "Quit the `vundo-diff' window and possibly kill buffer."
+  (let* ((buf (get-buffer (concat "*vundo-diff-" (buffer-name) "*")))
+        (win (and buf (get-buffer-window buf)))
+         (kill (eq vundo-diff-quit 'kill)))
+    (if win (quit-window kill win)
+      (when (and buf kill) (kill-buffer buf)))))
+
 ;;;###autoload
 (defun vundo-diff ()
   "Perform diff between marked and current buffer state.
diff --git a/vundo.el b/vundo.el
index ba423bd187..281ef474c8 100644
--- a/vundo.el
+++ b/vundo.el
@@ -745,6 +745,7 @@ WINDOW is the window that was/is displaying the vundo 
buffer."
 (declare-function vundo-diff "vundo-diff")
 (declare-function vundo-diff-mark "vundo-diff")
 (declare-function vundo-diff-unmark "vundo-diff")
+(declare-function vundo-diff--quit "vundo-diff")
 (defvar vundo-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "f") #'vundo-forward)
@@ -1028,6 +1029,7 @@ Roll back changes if `vundo-roll-back-on-quit' is 
non-nil."
      (when (window-live-p orig-window)
        (select-window orig-window))
      (with-current-buffer orig-buffer
+       (vundo-diff--quit)
        (run-hooks 'vundo-post-exit-hook)))))
 
 (defun vundo-confirm ()
@@ -1041,6 +1043,7 @@ Roll back changes if `vundo-roll-back-on-quit' is 
non-nil."
     (when (window-live-p orig-window)
       (select-window orig-window))
     (with-current-buffer orig-buffer
+      (vundo-diff--quit)
       (run-hooks 'vundo-post-exit-hook))))
 
 ;;; Traverse undo tree



reply via email to

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