forked from mirrors/org-mode
org-element-at-point: Throw an error when not in org-mode
* lisp/org-element.el (org-element-at-point): Explicitly throw an error when not in org-mode buffer. The parser expects certain buffer-local constants and may fail otherwise. It is better to indicate the problem explicitly instead of dealing with cryptic generic errors. (org-element-plain-list-interpreter): * testing/lisp/test-ox.el (test-org-export/expand-include/links): Make sure that we never invoke parser in non-Org buffers.
This commit is contained in:
parent
3ec0933122
commit
f1359546ad
|
@ -1780,6 +1780,7 @@ Assume point is at the beginning of the list."
|
||||||
"Interpret plain-list element as Org syntax.
|
"Interpret plain-list element as Org syntax.
|
||||||
CONTENTS is the contents of the element."
|
CONTENTS is the contents of the element."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
(org-mode)
|
||||||
(insert contents)
|
(insert contents)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(org-list-repair)
|
(org-list-repair)
|
||||||
|
@ -8031,6 +8032,9 @@ This function may modify the match data."
|
||||||
(if (org-element-type epom t) epom
|
(if (org-element-type epom t) epom
|
||||||
(setq epom (or epom (point)))
|
(setq epom (or epom (point)))
|
||||||
(org-with-point-at epom
|
(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.
|
;; Allow re-parsing when the command can benefit from it.
|
||||||
(when (and cached-only
|
(when (and cached-only
|
||||||
(memq this-command org-element--cache-non-modifying-commands))
|
(memq this-command org-element--cache-non-modifying-commands))
|
||||||
|
|
|
@ -1498,6 +1498,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
|
||||||
(let ((buffer (find-file-noselect includer t)))
|
(let ((buffer (find-file-noselect includer t)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
(org-mode)
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
(org-trim (buffer-string)))
|
(org-trim (buffer-string)))
|
||||||
(when (buffer-live-p buffer)
|
(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)))
|
(let ((buffer (find-file-noselect includer t)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
(org-mode)
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
(org-trim (buffer-string)))
|
(org-trim (buffer-string)))
|
||||||
(when (buffer-live-p buffer)
|
(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)))
|
(let ((buffer (find-file-noselect includer t)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
(org-mode)
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
(org-trim (buffer-string)))
|
(org-trim (buffer-string)))
|
||||||
(when (buffer-live-p buffer)
|
(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)))
|
(let ((buffer (find-file-noselect includer t)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
(org-mode)
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
(org-trim (buffer-string)))
|
(org-trim (buffer-string)))
|
||||||
(when (buffer-live-p buffer)
|
(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)))
|
(let ((buffer (find-file-noselect includer t)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
(org-mode)
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
(org-trim (buffer-string)))
|
(org-trim (buffer-string)))
|
||||||
(when (buffer-live-p buffer)
|
(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)))
|
(let ((buffer (find-file-noselect includer t)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
(org-mode)
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
(org-trim (buffer-string)))
|
(org-trim (buffer-string)))
|
||||||
(when (buffer-live-p buffer)
|
(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)))
|
(let ((buffer (find-file-noselect includer t)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
(org-mode)
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
(org-trim (buffer-string)))
|
(org-trim (buffer-string)))
|
||||||
(when (buffer-live-p buffer)
|
(when (buffer-live-p buffer)
|
||||||
|
|
Loading…
Reference in a new issue