emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] Add org-agenda-show-indirect variable


From: Adam Porter
Subject: Re: [O] [PATCH] Add org-agenda-show-indirect variable
Date: Sun, 01 Sep 2019 09:28:00 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

tumashu <address@hidden> writes:

> +      (when org-agenda-show-indirect
> +     (let ((org-indirect-buffer-display 'current-window))
> +       (org-tree-to-indirect-buffer)
> +       ;; hide indirect buffer in ibuffer
> +       (rename-buffer (concat " " (buffer-name)))))

1.  That does not affect only ibuffer, but most any code that lists
buffers.

2.  Please don't hide indirect buffers this way.  The user won't be able
to switch back to it without enabling the display of hidden buffers.
That will be unexpected, and many users wouldn't even know that such a
thing can be done.  So if the user was working in that indirect buffer,
how will he get back to it?

Also, indirect buffers are not automatically cleaned up; according to
the manual, if their base buffer is killed, they merely cannot be made
active again, so hiding them is not a good idea.

3.  What if such an indirect buffer already exists?  i.e. what if the
user activates the command more than once?  It would be good to avoid
creating multiple indirect buffers pointing to the same subtree.

4.  You could give the indirect buffer a useful name, which would also
make it possible to reuse indirect buffers if the user activates the
command more than once.  For example, I use this code in my config:

#+BEGIN_SRC elisp
(defun ap/org-tree-to-indirect-buffer (&optional arg)
  "Create indirect buffer and narrow it to current subtree.
The buffer is named after the subtree heading, with the filename
appended.  If a buffer by that name already exists, it is
selected instead of creating a new buffer."
  (interactive "P")
  (let* ((new-buffer-p)
         (buffer-name
          (let* ((level (org-outline-level))
                 (heading-string (org-link-display-format
                                  (org-get-heading t t))))
            (concat heading-string "::" (buffer-name))))
         (new-buffer
          (or (get-buffer buffer-name)
              (prog1 (condition-case nil
                         (make-indirect-buffer (current-buffer)
                                               buffer-name 'clone)
                       (error (make-indirect-buffer (current-buffer)
                                                    buffer-name)))
                (setq new-buffer-p t)))))
    (switch-to-buffer new-buffer)
    (when new-buffer-p
      (rename-buffer buffer-name)
      (org-narrow-to-subtree))))

(advice-add 'org-tree-to-indirect-buffer
            :override 'ap/org-tree-to-indirect-buffer)
#+END_SRC




reply via email to

[Prev in Thread] Current Thread [Next in Thread]