Function: org-tree-to-indirect-buffer
org-tree-to-indirect-buffer is an interactive and byte-compiled
function defined in org.el.gz.
Signature
(org-tree-to-indirect-buffer &optional ARG)
Documentation
Create indirect buffer and narrow it to current subtree.
With a numerical prefix ARG, go up to this level and then take that tree. If ARG is negative, go up that many levels.
If org-indirect-buffer-display is not new-frame, the command removes the
indirect buffer previously made with this command, to avoid proliferation of
indirect buffers. However, when you call the command with a C-u (universal-argument) prefix, or
when org-indirect-buffer-display is new-frame, the last buffer is kept
so that you can work with several indirect buffers at the same time. If
org-indirect-buffer-display is dedicated-frame, the C-u (universal-argument) prefix also
requests that a new frame be made for the new buffer, so that the dedicated
frame is not changed.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-tree-to-indirect-buffer (&optional arg)
"Create indirect buffer and narrow it to current subtree.
With a numerical prefix ARG, go up to this level and then take that tree.
If ARG is negative, go up that many levels.
If `org-indirect-buffer-display' is not `new-frame', the command removes the
indirect buffer previously made with this command, to avoid proliferation of
indirect buffers. However, when you call the command with a \
`\\[universal-argument]' prefix, or
when `org-indirect-buffer-display' is `new-frame', the last buffer is kept
so that you can work with several indirect buffers at the same time. If
`org-indirect-buffer-display' is `dedicated-frame', the \
`\\[universal-argument]' prefix also
requests that a new frame be made for the new buffer, so that the dedicated
frame is not changed."
(interactive "P")
(let ((cbuf (current-buffer))
(cwin (selected-window))
(pos (point))
beg end level heading ibuf)
(save-excursion
(org-back-to-heading t)
(when (numberp arg)
(setq level (org-outline-level))
(when (< arg 0) (setq arg (+ level arg)))
(while (> (setq level (org-outline-level)) arg)
(org-up-heading-safe)))
(setq beg (point)
heading (org-get-heading 'no-tags))
(org-end-of-subtree t t)
(when (and (not (eobp)) (org-at-heading-p)) (backward-char 1))
(setq end (point)))
(when (and (buffer-live-p org-last-indirect-buffer)
(not (eq org-indirect-buffer-display 'new-frame))
(not arg))
(kill-buffer org-last-indirect-buffer))
(setq ibuf (org-get-indirect-buffer cbuf heading)
org-last-indirect-buffer ibuf)
(cond
((or (eq org-indirect-buffer-display 'new-frame)
(and arg (eq org-indirect-buffer-display 'dedicated-frame)))
(select-frame (make-frame))
(delete-other-windows)
(pop-to-buffer-same-window ibuf)
(org-set-frame-title heading))
((eq org-indirect-buffer-display 'dedicated-frame)
(raise-frame
(select-frame (or (and org-indirect-dedicated-frame
(frame-live-p org-indirect-dedicated-frame)
org-indirect-dedicated-frame)
(setq org-indirect-dedicated-frame (make-frame)))))
(delete-other-windows)
(pop-to-buffer-same-window ibuf)
(org-set-frame-title (concat "Indirect: " heading)))
((eq org-indirect-buffer-display 'current-window)
(pop-to-buffer-same-window ibuf))
((eq org-indirect-buffer-display 'other-window)
(pop-to-buffer ibuf))
(t (error "Invalid value")))
(narrow-to-region beg end)
(org-fold-show-all '(headings drawers blocks))
(goto-char pos)
(run-hook-with-args 'org-cycle-hook 'all)
(and (window-live-p cwin) (select-window cwin))))