Function: org-kill-is-subtree-p

org-kill-is-subtree-p is a byte-compiled function defined in org.el.gz.

Signature

(org-kill-is-subtree-p &optional TXT)

Documentation

Check if the current kill is an outline subtree, or a set of trees.

Returns nil if kill does not start with a headline, or if the first headline level is not the largest headline level in the tree. So this will actually accept several entries of equal levels as well, which is OK for org-paste-subtree. If optional TXT is given, check this string instead of the current kill.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-kill-is-subtree-p (&optional txt)
  "Check if the current kill is an outline subtree, or a set of trees.
Returns nil if kill does not start with a headline, or if the first
headline level is not the largest headline level in the tree.
So this will actually accept several entries of equal levels as well,
which is OK for `org-paste-subtree'.
If optional TXT is given, check this string instead of the current kill."
  (let* ((kill (or txt (ignore-errors (current-kill 0))))
	 (re (org-get-limited-outline-regexp))
	 (^re (concat "^" re))
	 (start-level (and kill
			   (string-match
			    (concat "\\`\\([ \t\n\r]*?\n\\)?\\(" re "\\)")
			    kill)
			   (- (match-end 2) (match-beginning 2) 1)))
	 (start (1+ (or (match-beginning 2) -1))))
    (if (not start-level)
	(progn
	  nil)  ;; does not even start with a heading
      (catch 'exit
	(while (setq start (string-match ^re kill (1+ start)))
	  (when (< (- (match-end 0) (match-beginning 0) 1) start-level)
	    (throw 'exit nil)))
	t))))