org-open-at-point: Fix opening multiple file links

* lisp/org.el (org-open-at-point): Keep link selection buffer current
when looping over links to be opened.  Otherwise, opening a link might
change current buffer, breaking the code logic.

Reported-by: cro cefisso <crocefisso@gmx.com>
Link: https://orgmode.org/list/trinity-3a7c01d2-99d9-4b8a-b317-d62c02d75e72-1682242700508@3c-app-mailcom-bs02
This commit is contained in:
Ihor Radchenko 2023-04-23 16:47:02 +02:00
parent 14dccff8b3
commit 92f9135b3c
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 4 additions and 1 deletions

View File

@ -8444,7 +8444,10 @@ a link."
(dolist (link (if (stringp links) (list links) links))
(search-forward link nil links-end)
(goto-char (match-beginning 0))
(org-open-at-point arg)))))))
;; When opening file link, current buffer may be
;; altered.
(save-current-buffer
(org-open-at-point arg))))))))
;; On a footnote reference or at definition's label.
((or (eq type 'footnote-reference)
(and (eq type 'footnote-definition)