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

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

[elpa] externals/gnorb 2be4a71 240/449: Save point with marker when addi


From: Stefan Monnier
Subject: [elpa] externals/gnorb 2be4a71 240/449: Save point with marker when adding headers to replies
Date: Fri, 27 Nov 2020 23:15:47 -0500 (EST)

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

    Save point with marker when adding headers to replies
    
    * gnorb-gnus.el (gnorb-gnus-outgoing-do-todo): Don't use
      message-goto-body, because there's a good chance that wasn't where
      point was originally.
    
    * nngnorb.el (gnorb-summary-reply-hook): Don't use save-excursion,
      because that saves point, and point probably has moved.
    
    In both cases, it's safest to preserve point using a marker.
---
 gnorb-gnus.el |  6 +++++-
 nngnorb.el    | 24 +++++++++++++-----------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/gnorb-gnus.el b/gnorb-gnus.el
index 5ebb2b9..e6c6a1d 100644
--- a/gnorb-gnus.el
+++ b/gnorb-gnus.el
@@ -324,6 +324,7 @@ the outgoing message will still be available -- nothing 
else will
 work."
   (interactive "P")
   (let ((org-refile-targets gnorb-gnus-trigger-refile-targets)
+       (compose-marker (make-marker))
        header-ids ref-ids rel-headings gnorb-window-conf
        reply-id reply-group in-reply-to)
     (when arg
@@ -363,6 +364,9 @@ work."
       ;; to, if this is actually a reply.
       (when message-reply-headers
        (setq reply-id (aref message-reply-headers 4)))
+      ;; Save-excursion won't work, because point will move if we
+      ;; insert headings.
+      (move-marker compose-marker (point))
       (save-restriction
        (widen)
        (message-narrow-to-headers-or-head)
@@ -404,7 +408,7 @@ work."
              ;; tell the rest of the function that this is a relevant
              ;; message
              (push h header-ids)))))
-      (message-goto-body)
+      (goto-char compose-marker)
       (add-to-list
        'message-exit-actions
        (if header-ids
diff --git a/nngnorb.el b/nngnorb.el
index 8048304..930f8e2 100644
--- a/nngnorb.el
+++ b/nngnorb.el
@@ -239,19 +239,21 @@ continue to provide tracking of sent messages."
   "Function that runs after any command that creates a reply."
   ;; Not actually a "hook"
   (let* ((msg-id (aref message-reply-headers 4))
-        (org-id (car-safe (gnus-registry-get-id-key msg-id 'gnorb-ids))))
+        (org-id (car-safe (gnus-registry-get-id-key msg-id 'gnorb-ids)))
+        (compose-marker (make-marker)))
     (when org-id
+      (move-marker compose-marker (point))
       (save-restriction
-       (save-excursion
-         (widen)
-         (message-narrow-to-headers-or-head)
-         (goto-char (point-at-bol))
-         (open-line 1)
-         (message-insert-header
-          (intern gnorb-mail-header)
-          org-id)
-         (add-to-list 'message-exit-actions
-                      'gnorb-org-restore-after-send t))))))
+       (widen)
+       (message-narrow-to-headers-or-head)
+       (goto-char (point-at-bol))
+       (open-line 1)
+       (message-insert-header
+        (intern gnorb-mail-header)
+        org-id)
+       (add-to-list 'message-exit-actions
+                    'gnorb-org-restore-after-send t))
+      (goto-char compose-marker))))
 
 (defun gnorb-summary-exit ()
   "Like `gnus-summary-exit', but restores the gnorb window conf."



reply via email to

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