Yuu Yin <yuu...@protonmail.com> writes:

> Invoking ~org-cite-insert~ after list bullets (e.g. ~-~ and ~1.~ )
> doesn't work.

I did a little test myself, and can confirm that it's not currently
possible to insert a citation *immediately* after a bullet and space.
This can be checked with `org-cite--allowed-p'.

Thinking about this situation, inserting citations should be fine as
long as the `point' isn't before or immediately after the bullet itself
(i.e. no space).

I've prepared a patch that fixes this (attached). This is the test case
that I'm adding:

+     ((eq type 'item)
+      (> (point) (+ (org-element-property :begin context)
+                    (org-get-indentation)
+                    1)))

As this is so simple, if nobody has any comments I'll push this in a
week or so.

--
Timothy

>From 8a242b6c80c2ec2b384f12c16bb9f70c2d44c9c7 Mon Sep 17 00:00:00 2001
From: TEC <t...@tecosaur.com>
Date: Tue, 31 Aug 2021 19:03:19 +0800
Subject: [PATCH] oc: allow citations following an item bullet

* lisp/oc.el (org-cite--allowed-p): Expand the allowed cases to include
"item", which lets one insert a citation following a bullet, e.g. "- ".
We just have to check to make sure the citation actually is at least one
character away from the bullet.
---
 lisp/oc.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/oc.el b/lisp/oc.el
index 5fcb9da62..7ffe37e57 100644
--- a/lisp/oc.el
+++ b/lisp/oc.el
@@ -1426,6 +1426,11 @@ (defun org-cite--allowed-p (context)
      ((= (point) (org-element-property :begin context)))
      ;; Within recursive object too, but not in a link.
      ((eq type 'link) nil)
+     ;; At the start of a list item is fine, as long as the bullet is unaffected.
+     ((eq type 'item)
+      (> (point) (+ (org-element-property :begin context)
+                    (org-get-indentation)
+                    1)))
      ((eq type 'table-cell)
       ;; :contents-begin is not reliable on empty cells, so special
       ;; case it.
-- 
2.33.0

Reply via email to