Function: org--paragraph-at-point
org--paragraph-at-point is a byte-compiled function defined in
org.el.gz.
Signature
(org--paragraph-at-point)
Documentation
Return paragraph, or equivalent, element at point.
Paragraph element at point is the element at point, with the following special cases:
- treat table rows (resp. node properties) as the table
(resp. property drawer) containing them.
- treat plain lists with an item every line as a whole.
- treat consecutive keywords, clocks, and diary-sexps as a single
block.
Function may return a real element, or a pseudo-element with type
pseudo-paragraph.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org--paragraph-at-point ()
"Return paragraph, or equivalent, element at point.
Paragraph element at point is the element at point, with the
following special cases:
- treat table rows (resp. node properties) as the table
\(resp. property drawer) containing them.
- treat plain lists with an item every line as a whole.
- treat consecutive keywords, clocks, and diary-sexps as a single
block.
Function may return a real element, or a pseudo-element with type
`pseudo-paragraph'."
(let* ((e (org-element-at-point))
(type (org-element-type e))
;; If we need to fake a new pseudo-element, triplet is
;;
;; (BEG END PARENT)
;;
;; where BEG and END are element boundaries, and PARENT the
;; element containing it, or nil.
(triplet
(cond
((memq type '(table property-drawer))
(list (org-element-begin e)
(org-element-end e)
(org-element-parent e)))
((memq type '(node-property table-row))
(let ((e (org-element-parent e)))
(list (org-element-begin e)
(org-element-end e)
(org-element-parent e))))
((memq type '(clock diary-sexp keyword))
(let* ((regexp (pcase type
(`clock org-clock-line-re)
(`diary-sexp "%%(")
(_ org-keyword-regexp)))
(end (if (< 0 (org-element-post-blank e))
(org-element-end e)
(org-with-wide-buffer
(forward-line)
(while (looking-at regexp) (forward-line))
(skip-chars-forward " \t\n")
(line-beginning-position))))
(begin (org-with-point-at (org-element-begin e)
(while (and (not (bobp)) (looking-at regexp))
(forward-line -1))
;; We may have gotten one line too far.
(if (looking-at regexp)
(point)
(line-beginning-position 2)))))
(list begin end (org-element-parent e))))
;; Find the full plain list containing point, the check it
;; contains exactly one line per item.
((let ((l (org-element-lineage e 'plain-list t)))
(while (org-element-type-p
(org-element-parent l)
'(item plain-list))
(setq l (org-element-parent l)))
(and l org--single-lines-list-is-paragraph
(org-with-point-at (org-element-post-affiliated l)
(forward-line (length (org-element-property :structure l)))
(= (point) (org-element-contents-end l)))
;; Return value.
(list (org-element-begin l)
(org-element-end l)
(org-element-parent l)))))
(t nil)))) ;no triplet: return element
(pcase triplet
(`(,b ,e ,p)
(org-element-create
'pseudo-paragraph
(list :begin b :end e :parent p :post-blank 0 :post-affiliated b)))
(_ e))))