[Top][All Lists]

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

[elpa] externals/gnorb 1e071a0 252/449: Further refinements to link foll

From: Stefan Monnier
Subject: [elpa] externals/gnorb 1e071a0 252/449: Further refinements to link following
Date: Fri, 27 Nov 2020 23:15:50 -0500 (EST)

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

    Further refinements to link following
    * gnorb-utils.el (gnorb-reply-to-gnus-link): New function, do the
      replies using this -- also handles news.
      (gnorb-open-gnus-link): New function, now we don't rely on Org's gnus
      link following at all.
    * gnorb-org.el (gnorb-org-setup-message): Edit to use new functions.
 gnorb-org.el   |  5 +----
 gnorb-utils.el | 32 ++++++++++++++++++++++++++------
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/gnorb-org.el b/gnorb-org.el
index a27cc1f..2971dd5 100644
--- a/gnorb-org.el
+++ b/gnorb-org.el
@@ -259,10 +259,7 @@ headings."
     ;; ...or follow link and start reply.
     (condition-case err
-       (progn
-         (gnorb-open-gnus-link (car messages))
-         (call-interactively
-         'gnus-summary-wide-reply-with-original))
+       (gnorb-reply-to-gnus-link (car messages))
       (error (gnorb-restore-layout)
             (signal (car err) (cdr err)))))
   ;; Add MAILS to message To header.
diff --git a/gnorb-utils.el b/gnorb-utils.el
index 880e571..fecf27c 100644
--- a/gnorb-utils.el
+++ b/gnorb-utils.el
@@ -116,7 +116,20 @@ and Gnus and BBDB maps."
     (when (buffer-live-p (marker-buffer gnorb-return-marker))
       (goto-char gnorb-return-marker))))
-(defun gnorb-open-gnus-link (link)
+(defun gnorb-reply-to-gnus-link (link)
+  "Start a reply to the linked message."
+  (let* ((link (org-link-unescape link))
+        (group (car (org-split-string link "#")))
+        (id (second (org-split-string link "#")))
+        (backend
+         (car (gnus-find-method-for-group group))))
+    (gnorb-follow-gnus-link group id)
+    (call-interactively
+     (if (eq backend 'nntp)
+        'gnus-summary-followup-with-original
+       'gnus-summary-wide-reply-with-original))))
+(defun gnorb-follow-gnus-link (group id)
   "Be a little clever about following gnus links.
 The goal here is reuse frames and windows as much as possible, so
@@ -141,10 +154,7 @@ link.
 3. Otherwise just follow the link as usual, in the current
-  (let* ((link (org-link-unescape link))
-        (group (car (org-split-string link "#")))
-        (id (second (org-split-string link "#")))
-        (sum-buffer (gnus-summary-buffer-name group))
+  (let* ((sum-buffer (gnus-summary-buffer-name group))
           ((gnus-buffer-exists-p sum-buffer)
@@ -165,7 +175,17 @@ window."
          (switch-to-buffer target-buffer)))
     (if (gnus-buffer-exists-p sum-buffer)
        (gnus-summary-goto-article id nil t)
-      (org-gnus-open link))))
+      (gnorb-open-gnus-link group id))))
+(defun gnorb-open-gnus-link (group id)
+  "Gnorb version of `org-gnus-follow-link'."
+  (let ((art-no (cdr (gnus-request-head id group)))
+       success)
+    (gnus-activate-group group)
+    (setq success (gnus-group-read-group 1 t group))
+    (if success
+       (gnus-summary-goto-article (or art-no id) nil t)
+      (signal 'error "Group could not be opened."))))
 (defun gnorb-trigger-todo-action (arg &optional id)
   "Do the actual restore action. Two main things here. First: if

reply via email to

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