Function: org-copy-subtree
org-copy-subtree is an interactive and byte-compiled function defined
in org.el.gz.
Signature
(org-copy-subtree &optional N CUT FORCE-STORE-MARKERS NOSUBTREES)
Documentation
Copy the current subtree into the clipboard.
With prefix arg N, copy this many sequential subtrees. This is a short-hand for marking the subtree and then copying it. If CUT is non-nil, actually cut the subtree. If FORCE-STORE-MARKERS is non-nil, store the relative locations of some markers in the region, even if CUT is non-nil. This is useful if the caller implements cut-and-paste as copy-then-paste-then-cut.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-copy-subtree (&optional n cut force-store-markers nosubtrees)
"Copy the current subtree into the clipboard.
With prefix arg N, copy this many sequential subtrees.
This is a short-hand for marking the subtree and then copying it.
If CUT is non-nil, actually cut the subtree.
If FORCE-STORE-MARKERS is non-nil, store the relative locations
of some markers in the region, even if CUT is non-nil. This is
useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
(interactive "p")
(org-preserve-local-variables
(let (beg end folded (beg0 (point)))
(if (called-interactively-p 'any)
(org-back-to-heading nil) ; take what looks like a subtree
(org-back-to-heading t)) ; take what is really there
(setq beg (point))
(skip-chars-forward " \t\r\n")
(save-match-data
(if nosubtrees
(outline-next-heading)
(save-excursion (outline-end-of-heading)
(setq folded (org-invisible-p)))
(ignore-errors (org-forward-heading-same-level (1- n) t))
(org-end-of-subtree t t)))
;; Include the end of an inlinetask
(when (and (featurep 'org-inlinetask)
(looking-at-p (concat (org-inlinetask-outline-regexp)
"END[ \t]*$")))
(end-of-line))
(setq end (point))
(goto-char beg0)
(when (> end beg)
(setq org-subtree-clip-folded folded)
(when (or cut force-store-markers)
(org-save-markers-in-region beg end))
(if cut (kill-region beg end) (copy-region-as-kill beg end))
(setq org-subtree-clip (current-kill 0))
(message "%s: Subtree(s) with %d characters"
(if cut "Cut" "Copied")
(length org-subtree-clip))))))