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

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

[elpa] externals/agitate ae200ade05 1/8: Fix how windows are saved


From: ELPA Syncer
Subject: [elpa] externals/agitate ae200ade05 1/8: Fix how windows are saved
Date: Wed, 19 Oct 2022 09:57:26 -0400 (EDT)

branch: externals/agitate
commit ae200ade05ded96cc0480006dd7b3c353722fe5e
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Fix how windows are saved
    
    This addresses the underlying problem with the storing and restoring
    of the window configuration.  It also simplifies the code.
---
 agitate.el | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/agitate.el b/agitate.el
index c4e11fef55..b840fb5b9f 100644
--- a/agitate.el
+++ b/agitate.el
@@ -255,22 +255,24 @@ Restore the last window configuration when finalising 
log-view."
   :global t
   (if agitate-log-edit-informative-mode
       (progn
+        (add-hook 'vc-before-checkin-hook 
#'agitate--log-edit-informative-save-windows)
         (add-hook 'log-edit-hook #'agitate--log-edit-informative-setup)
-        (add-hook 'log-edit-mode-hook 
#'agitate--log-edit-informative-handle-kill-buffer))
+        (advice-add #'log-edit-done :after 
#'agitate--log-edit-informative-restore))
+    (remove-hook 'vc-before-checkin-hook 
#'agitate--log-edit-informative-save-windows)
     (remove-hook 'log-edit-hook #'agitate--log-edit-informative-setup)
-    (remove-hook 'log-edit-mode-hook 
#'agitate--log-edit-informative-handle-kill-buffer)))
+    (advice-remove #'log-edit-done #'agitate--log-edit-informative-restore)))
+
+(defun agitate--log-edit-informative-save-windows ()
+  "Save `current-window-configuration'."
+  (setq agitate--previous-window-configuration (current-window-configuration)))
 
 (defun agitate--log-edit-informative-setup ()
   "Set up informative `log-edit' window configuration."
-  ;; FIXME 2022-10-13: The window configuration needs to be saved at
-  ;; an earlier stage.  Hooking it to 'vc-before-checkin-hook' or
-  ;; `vc-checkin-hook' seems appropriate, though it then breaks the
-  ;; C-c C-c in log-edit buffers (the C-c C-k works).
-  (setq agitate--previous-window-configuration (current-window-configuration))
   (delete-other-windows)
-  (add-hook 'log-edit-done-hook #'agitate--log-edit-informative-restore nil t)
-  (add-hook 'log-edit-hook #'agitate--log-edit-informative-restore nil t)
-  ;; FIXME 2022-10-18: Fails in an empty repo.
+  (add-hook 'kill-buffer-hook #'agitate--log-edit-informative-restore nil t)
+  ;; FIXME 2022-10-18: Fails in an empty repo.  It is not nice to use
+  ;; `ignore-errors', as we should not display any window in such a
+  ;; scenario.
   (save-selected-window
     (log-edit-show-diff))
   (if agitate-log-edit-informative-show-files
@@ -289,11 +291,6 @@ Restore the last window configuration when finalising 
log-view."
   "Restore `agitate--previous-window-configuration'."
   (set-window-configuration agitate--previous-window-configuration))
 
-(defun agitate--log-edit-informative-handle-kill-buffer ()
-  "Restore `agitate--previous-window-configuration' if killed."
-  (when (derived-mode-p 'log-edit-mode)
-    (add-hook 'kill-buffer-hook #'agitate--log-edit-informative-restore 0 t)))
-
 ;;;; Commands for log-view (listings of commits)
 
 ;;;###autoload



reply via email to

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