Function: org-capture-place-plain-text

org-capture-place-plain-text is a byte-compiled function defined in org-capture.el.gz.

Signature

(org-capture-place-plain-text)

Documentation

Place the template plainly.

If the target locator points at an Org node, place the template into the text of the entry, before the first child. If not, place the template at the beginning or end of the file. Of course, if exact position has been required, just put it there.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-capture.el.gz
(defun org-capture-place-plain-text ()
  "Place the template plainly.
If the target locator points at an Org node, place the template into
the text of the entry, before the first child.  If not, place the
template at the beginning or end of the file.
Of course, if exact position has been required, just put it there."
  (cond
   ((org-capture-get :exact-position)
    (goto-char (org-capture-get :exact-position)))
   ((org-capture-get :target-entry-p)
    ;; Place the text into this entry.
    (if (org-capture-get :prepend)
	;; Skip meta data and drawers.
	(org-end-of-meta-data t)
      ;; Go to end of the entry text, before the next headline.
      (outline-next-heading)))
   (t
    ;; Beginning or end of file.
    (goto-char (if (org-capture-get :prepend) (point-min) (point-max)))))
  (let ((origin (point-marker)))
    (unless (bolp) (insert "\n"))
    (org-capture-empty-lines-before)
    (org-capture-position-for-last-stored (point))
    (let ((beg (point)))
      (insert (org-capture-get :template))
      (unless (bolp) (insert "\n"))
      ;; Ignore the final newline character so as to not alter data
      ;; after inserted text.  Yet, if the template is empty, make
      ;; sure END matches BEG instead of pointing before it.
      (let ((end (max beg (1- (point)))))
	(org-capture-empty-lines-after)
	(org-capture-mark-kill-region origin (point))
	(org-capture-narrow beg end)
	(org-capture--position-cursor beg end)))))