Function: embark-org-target-element-context

embark-org-target-element-context is a byte-compiled function defined in embark-org.el.

Signature

(embark-org-target-element-context)

Documentation

Target all Org elements or objects around point.

Source Code

;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark-org.el
(defun embark-org-target-element-context ()
  "Target all Org elements or objects around point."
  (when (derived-mode-p 'org-mode)
    (cl-loop
     for elt = (org-element-lineage (org-element-context) embark-org--types t)
     then (org-element-lineage elt embark-org--types)
     while elt
     ;; clip bounds to narrowed portion of buffer
     for begin = (max (org-element-property :begin elt) (point-min))
     for end = (min (org-element-property :end elt) (point-max))
     for target = (buffer-substring begin end)
      ;; Adjust table-cell to exclude final |. (Why is that there?)
      ;; Note: We are not doing this as an embark transformer because we
      ;; want to adjust the bounds too.
      ;; TODO? If more adjustments like this become necessary, add a
      ;; nice mechanism for doing them.
      when (and (eq (car elt) 'table-cell) (string-suffix-p "|" target))
      do (setq target (string-trim (string-remove-suffix "|" target))
               end (1- end))
      collect `(,(intern (format "org-%s" (car elt))) ,target ,begin . ,end))))