Eduardo Mercovich <eduardo <at> mercovich.net> writes:

> Also less known that it deserves, for focusing I do use narrowing a lot:

Yeah, that's basically what tree-to-indirect does, it makes an indirect
buffer and then narrows it.  So you can widen the indirect buffer and get
another view of the whole buffer.  

I also use this advice to rename the indirect buffer to the name of the
heading, that way you don't end up with "file.org<1>"-style buffers:

(defun ap/org-rename-tree-to-indirect-buffer (&rest args)
    "Rename the new buffer to the current org heading after using
org-tree-to-indirect-buffer."
    (with-current-buffer (car (buffer-list (car (frame-list))))
      (save-excursion
        (let* ((heading (nth 4 (org-heading-components)))
               (name (if (string-match org-bracket-link-regexp heading)
                         ;; Heading is an org link; use link name
                         ;; TODO: but what if only part of the heading is?
                         (match-string 3 heading)
                       ;; Not a link; use whole heading
                       heading)))
          (rename-buffer name) t))))
  (advice-add 'org-tree-to-indirect-buffer :after
'ap/org-rename-tree-to-indirect-buffer)


Reply via email to