diff --git a/lisp/org-element.el b/lisp/org-element.el index 69a62a2f5..58693d4e3 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -1780,6 +1780,7 @@ Assume point is at the beginning of the list." "Interpret plain-list element as Org syntax. CONTENTS is the contents of the element." (with-temp-buffer + (org-mode) (insert contents) (goto-char (point-min)) (org-list-repair) @@ -8031,6 +8032,9 @@ This function may modify the match data." (if (org-element-type epom t) epom (setq epom (or epom (point))) (org-with-point-at epom + (unless (derived-mode-p 'org-mode) + (error "`org-element-at-point' cannot be used in non-Org buffer %S (%s)" + (current-buffer) major-mode)) ;; Allow re-parsing when the command can benefit from it. (when (and cached-only (memq this-command org-element--cache-non-modifying-commands)) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 87c6db8af..4ba0ba032 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -1498,6 +1498,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] (let ((buffer (find-file-noselect includer t))) (unwind-protect (with-current-buffer buffer + (org-mode) (org-export-expand-include-keyword) (org-trim (buffer-string))) (when (buffer-live-p buffer) @@ -1520,6 +1521,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] (let ((buffer (find-file-noselect includer t))) (unwind-protect (with-current-buffer buffer + (org-mode) (org-export-expand-include-keyword) (org-trim (buffer-string))) (when (buffer-live-p buffer) @@ -1542,6 +1544,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] (let ((buffer (find-file-noselect includer t))) (unwind-protect (with-current-buffer buffer + (org-mode) (org-export-expand-include-keyword) (org-trim (buffer-string))) (when (buffer-live-p buffer) @@ -1564,6 +1567,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] (let ((buffer (find-file-noselect includer t))) (unwind-protect (with-current-buffer buffer + (org-mode) (org-export-expand-include-keyword) (org-trim (buffer-string))) (when (buffer-live-p buffer) @@ -1586,6 +1590,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] (let ((buffer (find-file-noselect includer t))) (unwind-protect (with-current-buffer buffer + (org-mode) (org-export-expand-include-keyword) (org-trim (buffer-string))) (when (buffer-live-p buffer) @@ -1608,6 +1613,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] (let ((buffer (find-file-noselect includer t))) (unwind-protect (with-current-buffer buffer + (org-mode) (org-export-expand-include-keyword) (org-trim (buffer-string))) (when (buffer-live-p buffer) @@ -1628,6 +1634,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] (let ((buffer (find-file-noselect includer t))) (unwind-protect (with-current-buffer buffer + (org-mode) (org-export-expand-include-keyword) (org-trim (buffer-string))) (when (buffer-live-p buffer)