diff --git a/lisp/oc.el b/lisp/oc.el index 4e21a0903..338348116 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -1421,7 +1421,8 @@ ARG is the prefix argument received when calling `org-open-at-point', or nil." ((eq type 'table-cell) ;; :contents-begin is not reliable on empty cells, so special ;; case it. - (<= (point) (org-element-property :contents-end context))) + (<= (save-excursion (skip-chars-backward " \t") (point)) + (org-element-property :contents-end context))) ((let ((cbeg (org-element-property :contents-begin context)) (cend (org-element-property :contents-end context))) (and cbeg (>= (point) cbeg) (<= (point) cend))))))) diff --git a/testing/lisp/test-oc.el b/testing/lisp/test-oc.el index 80831f212..fc90a2146 100644 --- a/testing/lisp/test-oc.el +++ b/testing/lisp/test-oc.el @@ -1774,6 +1774,34 @@ arguments. Replace citation with \"@\" character in the output." (eq 'success (catch :exit (org-test-with-temp-text "#+caption: \n| table |" + (let ((org-cite--processors nil) + (org-cite-insert-processor 'foo)) + (org-cite-register-processor 'foo + :insert (lambda (_ _) (throw :exit 'success))) + (call-interactively #'org-cite-insert)))))) + ;; Allow inserting citations in table cells. + (should + (eq 'success + (catch :exit + (org-test-with-temp-text "| table |" + (let ((org-cite--processors nil) + (org-cite-insert-processor 'foo)) + (org-cite-register-processor 'foo + :insert (lambda (_ _) (throw :exit 'success))) + (call-interactively #'org-cite-insert)))))) + (should + (eq 'success + (catch :exit + (org-test-with-temp-text "| table |" + (let ((org-cite--processors nil) + (org-cite-insert-processor 'foo)) + (org-cite-register-processor 'foo + :insert (lambda (_ _) (throw :exit 'success))) + (call-interactively #'org-cite-insert)))))) + (should + (eq 'success + (catch :exit + (org-test-with-temp-text "| table |" (let ((org-cite--processors nil) (org-cite-insert-processor 'foo)) (org-cite-register-processor 'foo