[Top][All Lists]

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

[elpa] externals/gnorb 43fbd55 176/449: New function for restoring windo

From: Stefan Monnier
Subject: [elpa] externals/gnorb 43fbd55 176/449: New function for restoring window layout
Date: Fri, 27 Nov 2020 23:15:33 -0500 (EST)

branch: externals/gnorb
commit 43fbd550294cfa93efeee7cee0d6c4b585a58588
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    New function for restoring window layout
    * lisp/gnorb-utils.el (gnorb-restore-layout): Interactive function for
      restoring window layout.
    * lisp/gnorb-gnus.el (gnorb-gnus-incoming-do-todo): Delete other
      windows, so we're left with a clear frame. `gnorb-restore-layout' can
      bring us back.
    * README.org: Document.
 README.org          |  4 ++++
 lisp/gnorb-gnus.el  |  3 +++
 lisp/gnorb-utils.el | 12 ++++++++++++
 3 files changed, 19 insertions(+)

diff --git a/README.org b/README.org
index cee1d66..1dc0872 100644
--- a/README.org
+++ b/README.org
@@ -168,6 +168,10 @@ you use on mail messages, and you'll be queried to 
re-attach the
 message's attachments onto the newly-captured heading. Or set
 `gnorb-gnus-capture-always-attach' to "t" to have Gnorb do this for
 all capture templates.
+** Restoring window layout
+Many Gnorb functions alter the window layout and value of point. In
+most of these cases, you can restore the previous layout using the
+interactive function `gnorb-restore-layout'.
 ** Gnorb-BBDB
 *** Interactive Functions
 **** gnorb-bbdb-tag-agenda
diff --git a/lisp/gnorb-gnus.el b/lisp/gnorb-gnus.el
index 78e6e4d..ec8aa3a 100644
--- a/lisp/gnorb-gnus.el
+++ b/lisp/gnorb-gnus.el
@@ -541,6 +541,9 @@ to t (it is, by default)."
              (sit-for 1))))
     (gnorb-gnus-collect-all-attachments nil t)
+    ;; Delete other windows, users can restore with
+    ;; `gnorb-restore-layout'.
+    (delete-other-windows)
     (if id
        (gnorb-trigger-todo-action arg id)
       (if (and offer-heading
diff --git a/lisp/gnorb-utils.el b/lisp/gnorb-utils.el
index 538bdc3..9289f91 100644
--- a/lisp/gnorb-utils.el
+++ b/lisp/gnorb-utils.el
@@ -112,6 +112,18 @@ with `gnorb-window-conf'.")
              'identity ign-headers-list "|")))))
+(defun gnorb-restore-layout ()
+  "Restore window layout and value of point after a Gnorb command.
+Some Gnorb commands change the window layout (ie `gnorb-org-view'
+or incoming email triggering). This command restores the layout
+to what it was. Bind it to a global key, or to local keys in Org
+and Gnus and BBDB maps."
+  (interactive)
+  (when (window-configuration-p gnorb-window-conf)
+    (set-window-configuration gnorb-window-conf)
+    (goto-char gnorb-return-marker)))
 (defun gnorb-trigger-todo-action (arg &optional id)
   "Do the actual restore action. Two main things here. First: if
 we were in the agenda when this was called, then keep us in the

reply via email to

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