Function: org-cite--allowed-p
org-cite--allowed-p is a byte-compiled function defined in oc.el.gz.
Signature
(org-cite--allowed-p CONTEXT)
Documentation
Non-nil when a citation can be inserted at point.
CONTEXT is the element or object at point, as returned by org-element-context.
Source Code
;; Defined in /usr/src/emacs/lisp/org/oc.el.gz
;;; Meta-command for citation insertion (insert capability)
(defun org-cite--allowed-p (context)
"Non-nil when a citation can be inserted at point.
CONTEXT is the element or object at point, as returned by `org-element-context'."
(let ((type (org-element-type context)))
(cond
;; No citation in attributes, except in parsed ones.
;;
;; XXX: Inserting citation in a secondary value is not allowed
;; yet. Is it useful?
((let ((post (org-element-property :post-affiliated context)))
(and post (< (point) post)))
(let ((case-fold-search t))
(looking-back
(rx-to-string
`(seq line-start (0+ (any " \t"))
"#+"
(or ,@org-element-parsed-keywords)
":"
(0+ nonl))
t)
(line-beginning-position))))
;; Paragraphs and blank lines at top of document are fine.
((memq type '(nil paragraph)))
;; So are contents of verse blocks.
((eq type 'verse-block)
(and (>= (point) (org-element-property :contents-begin context))
(< (point) (org-element-property :contents-end context))))
;; In an headline or inlinetask, point must be either on the
;; heading itself or on the blank lines below.
((memq type '(headline inlinetask))
(or (not (org-at-heading-p))
(and (save-excursion
(beginning-of-line)
(and (let ((case-fold-search t))
(not (looking-at-p "\\*+ END[ \t]*$")))
(let ((case-fold-search nil))
(looking-at org-complex-heading-regexp))))
(match-beginning 4)
(>= (point) (match-beginning 4))
(or (not (match-beginning 5))
(< (point) (match-beginning 5))))))
;; White spaces after an object or blank lines after an element
;; are OK.
((>= (point)
(save-excursion (goto-char (org-element-property :end context))
(skip-chars-backward " \r\t\n")
(if (eq (org-element-class context) 'object) (point)
(line-beginning-position 2)))))
;; At the beginning of a footnote definition, right after the
;; label, is OK.
((eq type 'footnote-definition) (looking-at (rx space)))
;; 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)
(current-indentation)
(if (org-element-property :checkbox context)
5 1))))
;; Other elements are invalid.
((eq (org-element-class context) 'element) nil)
;; Just before object is fine.
((= (point) (org-element-property :begin context)))
;; Within recursive object too, but not in a link.
((eq type 'link) nil)
((eq type 'table-cell)
;; :contents-begin is not reliable on empty cells, so special
;; case it.
(<= (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)))))))