From 2c9ea31999d2f69f8bca4fe352dd0f74c6766c54 Mon Sep 17 00:00:00 2001 From: Andrew G Cohen Date: Thu, 9 Mar 2023 16:05:31 +0800 Subject: [PATCH] Reset 'gnus-current-window-configuration' on edit-form exit. * lisp/gnus/gnus.el: New variable gnus-prev-cwc. * lisp/gnus/gnus-art.el (gnus-article-edit-mode): New local variable gnus-prev-cwc. (gnus-article-edit-article): Store original gnus-current-window-configuration as gnus-prev-cwc. (gnus-article-edit-done, gnus-article-edit-exit): Restore gnus-current-window-configuration from gnus-prev-cwc. * lisp/gnus/gnus-eform.el (gnus-edit-form-mode): New local variable gnus-prev-cwc. (gnus-edit-form): Store original gnus-current-window-configuration as gnus-prev-cwc. (gnus-edit-form-done, gnus-edit-form-exit): Restore gnus-current-window-configuration from gnus-prev-cwc. --- lisp/gnus/gnus-art.el | 13 ++++++++++--- lisp/gnus/gnus-eform.el | 13 +++++++++---- lisp/gnus/gnus.el | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index ce7a4488a7f..6a7a3f41746 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -7390,6 +7390,7 @@ This is an extended text-mode. \\{gnus-article-edit-mode-map}" (make-local-variable 'gnus-article-edit-done-function) (make-local-variable 'gnus-prev-winconf) + (make-local-variable 'gnus-prev-cwc) (setq-local font-lock-defaults '(message-font-lock-keywords t)) (setq-local mail-header-separator "") (setq-local gnus-article-edit-mode t) @@ -7420,7 +7421,8 @@ groups." (defun gnus-article-edit-article (start-func exit-func &optional quiet) "Start editing the contents of the current article buffer." - (let ((winconf (current-window-configuration))) + (let ((winconf (current-window-configuration)) + (cwc gnus-current-window-configuration)) (set-buffer gnus-article-buffer) (let ((message-auto-save-directory ;; Don't associate the article buffer with a draft file. @@ -7431,6 +7433,7 @@ groups." (gnus-configure-windows 'edit-article) (setq gnus-article-edit-done-function exit-func) (setq gnus-prev-winconf winconf) + (setq gnus-prev-cwc cwc) (unless quiet (gnus-message 6 "C-c C-c to end edits")))) @@ -7440,7 +7443,8 @@ groups." (let ((func gnus-article-edit-done-function) (buf (current-buffer)) (start (window-start)) - (winconf gnus-prev-winconf)) + (winconf gnus-prev-winconf) + (cwc gnus-prev-cwc)) (widen) ;; Widen it in case that users narrowed the buffer. (funcall func arg) (set-buffer buf) @@ -7458,6 +7462,7 @@ groups." (set-text-properties (point-min) (point-max) nil) (gnus-article-mode) (set-window-configuration winconf) + (setq gnus-current-window-configuration cwc) (set-buffer buf) (set-window-start (get-buffer-window buf) start) (set-window-point (get-buffer-window buf) (point))) @@ -7479,10 +7484,12 @@ groups." (erase-buffer) (if (gnus-buffer-live-p gnus-original-article-buffer) (insert-buffer-substring gnus-original-article-buffer)) - (let ((winconf gnus-prev-winconf)) + (let ((winconf gnus-prev-winconf) + (cwc gnus-prev-cwc)) (kill-all-local-variables) (gnus-article-mode) (set-window-configuration winconf) + (setq gnus-current-window-configuration cwc) ;; Tippy-toe some to make sure that point remains where it was. (with-current-buffer curbuf (set-window-start (get-buffer-window (current-buffer)) window-start) diff --git a/lisp/gnus/gnus-eform.el b/lisp/gnus/gnus-eform.el index 958d819048f..cc5beb16a34 100644 --- a/lisp/gnus/gnus-eform.el +++ b/lisp/gnus/gnus-eform.el @@ -70,17 +70,20 @@ It is a slightly enhanced `lisp-data-mode'. (when (gnus-visual-p 'group-menu 'menu) (gnus-edit-form-make-menu-bar)) (make-local-variable 'gnus-edit-form-done-function) - (make-local-variable 'gnus-prev-winconf)) + (make-local-variable 'gnus-prev-winconf) + (make-local-variable 'gnus-prev-cwc)) (defun gnus-edit-form (form documentation exit-func &optional layout) "Edit FORM in a new buffer. Call EXIT-FUNC on exit. Display DOCUMENTATION in the beginning of the buffer. The optional LAYOUT overrides the `edit-form' window layout." - (let ((winconf (current-window-configuration))) + (let ((winconf (current-window-configuration)) + (cwc gnus-current-window-configuration)) (set-buffer (gnus-get-buffer-create gnus-edit-form-buffer)) (gnus-configure-windows (or layout 'edit-form)) (gnus-edit-form-mode) + (setq gnus-prev-cwc cwc) (setq gnus-prev-winconf winconf) (setq gnus-edit-form-done-function exit-func) (erase-buffer) @@ -113,9 +116,11 @@ The optional LAYOUT overrides the `edit-form' window layout." (defun gnus-edit-form-exit () "Kill the current buffer." (interactive nil gnus-edit-form-mode) - (let ((winconf gnus-prev-winconf)) + (let ((winconf gnus-prev-winconf) + (cwc gnus-prev-cwc)) (kill-buffer (current-buffer)) - (set-window-configuration winconf))) + (set-window-configuration winconf) + (setq gnus-current-window-configuration cwc))) (provide 'gnus-eform) diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index efab58437e9..fc8518512ee 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el @@ -2445,6 +2445,7 @@ are always t.") ;; Save window configuration. (defvar gnus-prev-winconf nil) +(defvar gnus-prev-cwc nil) (defvar gnus-reffed-article-number nil) -- 2.39.2