From e1bc9aefd4fd0080012c172d1c21c684a5b2fe51 Mon Sep 17 00:00:00 2001 From: farblos <43711228+farblos@users.noreply.github.com> Date: Sat, 22 Jul 2023 10:30:19 +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. --- 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