Function: org-narrow-to-subtree

org-narrow-to-subtree is an interactive and byte-compiled function defined in org.el.gz.

Signature

(org-narrow-to-subtree &optional ELEMENT)

Documentation

Narrow buffer to the current subtree.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-narrow-to-subtree (&optional element)
  "Narrow buffer to the current subtree."
  (interactive)
  (if (org-element--cache-active-p)
      (let* ((heading (org-element-lineage
                       (or element (org-element-at-point))
                       '(headline) t))
             (end (org-element-property :end heading)))
        (if (and heading end)
            (narrow-to-region (org-element-property :begin heading)
                              (if (= end (point-max))
                                  end (1- end)))
          (signal 'outline-before-first-heading nil)))
    (save-excursion
      (save-match-data
        (org-with-limited-levels
         (narrow-to-region
	  (progn (org-back-to-heading t) (point))
	  (progn (org-end-of-subtree t t)
                 (when (and (org-at-heading-p) (not (eobp))) (backward-char 1))
                 (point))))))))