From fac55324accbcab08dfebbde8295b2f1b4b9f45e Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 5 Nov 2023 14:12:54 +0200 Subject: [PATCH] org-element-at-point: Demote error to warning when called from non-Org buffer * lisp/org-element.el (org-element-at-point): Do not throw an error when `org-element-at-point' is called from non-Org buffer. A number of third-party packages are incorrectly using `org-element-at-point' this way, relying upon `org-element-at-point' working in certain scenarios. Throwing an error (as was done previously) made an urgent call to fix this problem, even when `org-element-at-point' happened to work in a particular scenario. Now, we just display a warning to give package author more time to address or work around this. See https://github.com/alphapapa/org-web-tools/issues/61: @yantar92 I understand why this change was made, but perhaps it was a bit premature, given how much breakage it's causing downstream? It would seem appropriate to at least make it a warning for a full major version before making it an error, to give downstream devs and users a break. --- lisp/org-element.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 2ef4657ad..ea469a8b3 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -8287,8 +8287,8 @@ This function may modify the match data." (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)) + (warn "`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))