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

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

[elpa] externals/gnorb 25aa0f1 173/449: Use a marker in conjunction with


From: Stefan Monnier
Subject: [elpa] externals/gnorb 25aa0f1 173/449: Use a marker in conjunction with window conf
Date: Fri, 27 Nov 2020 23:15:33 -0500 (EST)

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

    Use a marker in conjunction with window conf
    
    We use gnorb-window-conf for returning from various actions. You're
    not supposed to rely on that for position of point, so pair it with a
    marker for finding point.
    
    * lisp/gnorb-utils.el (gnorb-return-marker): New variable pointing at
      marker
    * lisp/gnorb-gnus.el: Use it
    * lisp/gnorb-org.el: Use it
---
 lisp/gnorb-gnus.el  |  1 +
 lisp/gnorb-org.el   | 22 +++++++++++++++-------
 lisp/gnorb-utils.el |  4 ++++
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/lisp/gnorb-gnus.el b/lisp/gnorb-gnus.el
index 0fc2fcd..2a244f4 100644
--- a/lisp/gnorb-gnus.el
+++ b/lisp/gnorb-gnus.el
@@ -513,6 +513,7 @@ to t (it is, by default)."
   ;; present. Take a look at calling it non-interactively.
   (call-interactively 'org-store-link)
   (setq gnorb-window-conf (current-window-configuration))
+  (move-marker gnorb-return-marker (point))
   (let* ((msg-id (mail-header-id headers))
         (sender (mail-header-from headers))
         (subject (mail-header-subject headers))
diff --git a/lisp/gnorb-org.el b/lisp/gnorb-org.el
index 336ee7c..9e8c7e0 100644
--- a/lisp/gnorb-org.el
+++ b/lisp/gnorb-org.el
@@ -192,12 +192,13 @@ might have been in the outgoing message's headers and call
 `gnorb-org-do-restore-action' on each one."
   (when (eq major-mode 'gnus-summary-mode)
     (gnus-summary-exit nil t))
-  (when (window-configuration-p gnorb-window-conf)
-    (set-window-configuration gnorb-window-conf))
+  (when (and (window-configuration-p gnorb-window-conf)
+            gnorb-return-marker)
+    (set-window-configuration gnorb-window-conf)
+    (goto-char gnorb-return-marker))
   (dolist (id gnorb-message-org-ids)
     (gnorb-trigger-todo-action nil id))
   ;; this is a little unnecessary, but it may save grief
-  (setq gnorb-window-conf nil)
   (setq gnorb-gnus-sending-message-info nil)
   (setq gnorb-message-org-ids nil))
 
@@ -417,8 +418,10 @@ headings."
            (message-goto-to)
            (insert ", ")
            (insert (mapconcat 'identity mails ", "))))
-      (error (when (window-configuration-p gnorb-window-conf)
-              (set-window-configuration gnorb-window-conf))
+      (error (when (and (window-configuration-p gnorb-window-conf)
+                       gnorb-return-marker)
+              (set-window-configuration gnorb-window-conf)
+              (goto-char gnorb-return-marker))
             (signal (car err) (cdr err)))))
   ;; Return us after message is sent.
   (add-to-list 'message-exit-actions
@@ -489,6 +492,7 @@ current heading."
   "Handle current headline as a mail TODO."
   (interactive "P")
   (setq gnorb-window-conf (current-window-configuration))
+  (move-marker gnorb-return-marker (point))
   (when (eq major-mode 'org-agenda-mode)
     (org-agenda-check-type t 'agenda 'timeline 'todo 'tags)
     (org-agenda-check-no-diary)
@@ -709,6 +713,7 @@ default set of parameters."
                     ,gnorb-org-email-subtree-file-parameters))))
         text file)
     (setq gnorb-window-conf (current-window-configuration))
+    (move-marker gnorb-return-marker (point))
     (if (bufferp result)
        (setq text result)
       (setq file result))
@@ -835,6 +840,7 @@ your gnus select methods."
   ;; this should also work on the active region, if there is one.
   (interactive)
   (setq gnorb-window-conf (current-window-configuration))
+  (move-marker gnorb-return-marker (point))
   (when (eq major-mode 'org-agenda-mode)
     (org-agenda-check-type t 'agenda 'timeline 'todo 'tags)
     (org-agenda-check-no-diary)
@@ -851,8 +857,10 @@ your gnus select methods."
       (setq id (concat "id+" (org-id-get-create t))))
     (gnorb-gnus-search-messages
      id
-     `(when (window-configuration-p gnorb-window-conf)
-       (set-window-configuration gnorb-window-conf)))))
+     `(when (and (window-configuration-p gnorb-window-conf)
+                gnorb-return-marker)
+       (set-window-configuration gnorb-window-conf)
+       (goto-char gnorb-return-marker)))))
 
 (provide 'gnorb-org)
 ;;; gnorb-org.el ends here
diff --git a/lisp/gnorb-utils.el b/lisp/gnorb-utils.el
index 650b1f5..538bdc3 100644
--- a/lisp/gnorb-utils.el
+++ b/lisp/gnorb-utils.el
@@ -85,6 +85,10 @@
   "Save window configurations here, for restoration after mails
 are sent, or Org headings triggered.")
 
+(defvar gnorb-return-marker (make-marker)
+  "Return point here after various actions, to be used together
+with `gnorb-window-conf'.")
+
 (defcustom gnorb-mail-header "X-Org-ID"
   "Name of the mail header used to store the ID of a related Org
   heading. Only used locally: always stripped when the mail is



reply via email to

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