From 74d5c1f5caf4ce425eb888340c2115276b4ddf8a Mon Sep 17 00:00:00 2001 From: Jens Schmidt Date: Sun, 30 Jul 2023 17:51:27 +0200 Subject: [PATCH] ol-gnus.el: Fix issue when storing links from Gnus article buffers * lisp/ol-gnus.el (org-gnus-store-link): Switch to `gnus-summary-buffer' when calling functions that are intended to be called only there. Link: https://list.orgmode.org/orgmode/2fa5914d-2cbf-f41f-8be6-e79e77794140@vodafonemail.de --- lisp/ol-gnus.el | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lisp/ol-gnus.el b/lisp/ol-gnus.el index 7c07ce045..f0e04ce66 100644 --- a/lisp/ol-gnus.el +++ b/lisp/ol-gnus.el @@ -137,27 +137,23 @@ 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 . ,_) - (save-excursion - (car (nnvirtual-map-article (gnus-summary-article-number))))) + (with-current-buffer gnus-summary-buffer + (save-excursion + (car (nnvirtual-map-article (gnus-summary-article-number)))))) (`(,(or `nnselect `nnir) . ,_) ; nnir is for Emacs < 28. - (save-excursion - (cond - ((fboundp 'nnselect-article-group) - (nnselect-article-group (gnus-summary-article-number))) - ((fboundp 'nnir-article-group) - (nnir-article-group (gnus-summary-article-number))) - (t - (error "No article-group variant bound"))))) + (with-current-buffer gnus-summary-buffer + (save-excursion + (cond + ((fboundp 'nnselect-article-group) + (nnselect-article-group (gnus-summary-article-number))) + ((fboundp 'nnir-article-group) + (nnir-article-group (gnus-summary-article-number))) + (t + (error "No article-group variant bound")))))) (_ gnus-newsgroup-name))) - (header (if (eq major-mode 'gnus-article-mode) - ;; When in an article, first move to summary - ;; buffer, with point on the summary of the - ;; current article before extracting headers. - (save-window-excursion - (save-excursion - (gnus-article-show-summary) - (gnus-summary-article-header))) - (gnus-summary-article-header))) + (header (with-current-buffer gnus-summary-buffer + (save-excursion + (gnus-summary-article-header)))) (from (mail-header-from header)) (message-id (org-unbracket-string "<" ">" (mail-header-id header))) (date (org-trim (mail-header-date header))) -- 2.30.2