emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Add org-agenda-show-indirect variable
Date: Sun, 01 Sep 2019 09:28:00 -0500	[thread overview]
Message-ID: <87pnkkjdlb.fsf@alphapapa.net> (raw)
In-Reply-To: 4fcd74a5.5b9d.16cbc64a272.Coremail.tumashu@163.com

tumashu <tumashu@163.com> 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	other threads:[~2019-09-01 14:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23  2:53 [PATCH] Add org-agenda-show-indirect variable tumashu
2019-09-01 14:28 ` Adam Porter [this message]
2019-09-02  0:59   ` tumashu
2020-02-11 15:41     ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pnkkjdlb.fsf@alphapapa.net \
    --to=adam@alphapapa.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).