From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Porter Subject: Re: [PATCH] Add org-agenda-show-indirect variable Date: Sun, 01 Sep 2019 09:28:00 -0500 Message-ID: <87pnkkjdlb.fsf@alphapapa.net> References: <4fcd74a5.5b9d.16cbc64a272.Coremail.tumashu@163.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:40151) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4Qpw-0002xr-V5 for emacs-orgmode@gnu.org; Sun, 01 Sep 2019 10:28:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i4Qpv-0002jv-RE for emacs-orgmode@gnu.org; Sun, 01 Sep 2019 10:28:12 -0400 Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:58654 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i4Qpv-0002jD-KP for emacs-orgmode@gnu.org; Sun, 01 Sep 2019 10:28:11 -0400 Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1i4Qps-00166s-9z for emacs-orgmode@gnu.org; Sun, 01 Sep 2019 16:28:08 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org tumashu 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