branch: externals/org
commit f7aa4984a8abeada8d863b10ec331c831943d528
Merge: 791c2285e5 da69c444cc
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    Merge branch 'bugfix'
---
 lisp/org-src.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 6cdffc2084..1f29a87198 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -339,10 +339,14 @@ Return nil if there is no such buffer."
     (dolist (b (buffer-list))
       (with-current-buffer b
        (and (org-src-edit-buffer-p)
-            (= beg org-src--beg-marker)
             (eq (marker-buffer beg) (marker-buffer org-src--beg-marker))
-            (= end org-src--end-marker)
             (eq (marker-buffer end) (marker-buffer org-src--end-marker))
+             ;; Do it after comparing buffers.  In some scenarios
+             ;; (namely, when Org buffer is generated as a copy and
+             ;; the source buffer gets killed), these markers may
+             ;; point nowhere making `=' throw an error.
+            (= beg org-src--beg-marker)
+            (= end org-src--end-marker)
             (throw 'exit b))))))
 
 (defun org-src--coordinates (pos beg end)

Reply via email to