Browse Source

org-cite-insert: Allow citations at the beginning of empty heading

* lisp/oc.el (org-cite--allowed-p): When heading is empty, allow
to insert citations after priority/todo/stars.

Reported-by: Scott Otterson <scotto@sharpleaf.org>
Link: https://orgmode.org/list/CAPY3P0TBuoU2AJX78Qi2FevGuCx6KW1YSoSGQQZrzusTiuphRA@mail.gmail.com
Ihor Radchenko 1 year ago
parent
commit
3d1f4e0af0
1 changed files with 9 additions and 2 deletions
  1. 9 2
      lisp/oc.el

+ 9 - 2
lisp/oc.el

@@ -1507,8 +1507,15 @@ CONTEXT is the element or object at point, as returned by `org-element-context'.
 			(not (looking-at-p "\\*+ END[ \t]*$")))
 		      (let ((case-fold-search nil))
 			(looking-at org-complex-heading-regexp))))
-	       (match-beginning 4)
-	       (>= (point) (match-beginning 4))
+	       (>= (point) (or
+                           ;; Real heading.
+                           (match-beginning 4)
+                           ;; If no heading, end of priority.
+                           (match-end 3)
+                           ;; ... end of todo keyword.
+                           (match-end 2)
+                           ;; ... after stars.
+                           (1+ (match-end 1))))
 	       (or (not (match-beginning 5))
 		   (< (point) (match-beginning 5))))))
      ;; White spaces after an object or blank lines after an element