When calling org-capture in gnus virtual groups (for instance, groups
created through searches), I found that the region captured was
different than the region I had selected. This is because one of the
functions called in org-gnus-store-link moves the point to the end of
the buffer. The attached patch fixes the issue.

Thanks,
Matt

>From 7f41fbb98c7cbaa09af8f78b06a57587e4f583a1 Mon Sep 17 00:00:00 2001
From: Matt Lundin <[email protected]>
Date: Wed, 29 Nov 2017 09:17:55 -0600
Subject: [PATCH] Preserve position of point in gnus virtual group

* lisp/org-gnus.el: (org-gnus-store-link) Add a save-excursion to
  protect the position of point. Otherwise, when calling org-capture
  in an article with a virtual group, the point is moved and the
  region captured is incorrect.
---
 lisp/org-gnus.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-gnus.el b/lisp/org-gnus.el
index 687bc08b1..27a968f75 100644
--- a/lisp/org-gnus.el
+++ b/lisp/org-gnus.el
@@ -120,7 +120,8 @@ If `org-store-link' was called with a prefix arg the meaning of
      (let* ((group
 	     (pcase (gnus-find-method-for-group gnus-newsgroup-name)
 	       (`(nnvirtual . ,_)
-		(car (nnvirtual-map-article (gnus-summary-article-number))))
+		(save-excursion
+		  (car (nnvirtual-map-article (gnus-summary-article-number)))))
 	       (`(nnir . ,_)
 		(nnir-article-group (gnus-summary-article-number)))
 	       (_ gnus-newsgroup-name)))
-- 
2.15.0

Reply via email to