[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 7ea9099 1/2: oc: Allow inserting citations in table
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 7ea9099 1/2: oc: Allow inserting citations in table cells (part 2) |
Date: |
Thu, 29 Jul 2021 15:57:17 -0400 (EDT) |
branch: externals/org
commit 7ea909972557705ed9fa116cfa0086a2bc86a59f
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>
oc: Allow inserting citations in table cells (part 2)
* lisp/oc.el (org-cite--allowed-p): Allow inserting a citation after
two or more spaces at the end of a table cell.
* testing/lisp/test-oc.el (test-org-cite/insert-capability): Add
tests.
---
lisp/oc.el | 3 ++-
testing/lisp/test-oc.el | 28 ++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/lisp/oc.el b/lisp/oc.el
index 4e21a09..3383481 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 80831f2..fc90a21 100644
--- a/testing/lisp/test-oc.el
+++ b/testing/lisp/test-oc.el
@@ -1778,6 +1778,34 @@ arguments. Replace citation with \"@\" character in the
output."
(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 "| <point>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<point> |"
+ (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 <point> |"
+ (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)))))))
(provide 'test-oc)