From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: org-tree-to-indirect-buffer: multiple buffers; buffer name containing ID Date: Wed, 06 Nov 2013 13:51:54 +0100 Message-ID: <87ob5xae1h.fsf@bzg.ath.cx> References: <2013-10-25T09-34-51@devnull.Karl-Voit.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve2aa-00081m-Vt for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 07:52:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve2aW-00080s-8V for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 07:52:04 -0500 Received: from mail-wg0-x22b.google.com ([2a00:1450:400c:c00::22b]:39423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve2aW-00080m-0f for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 07:52:00 -0500 Received: by mail-wg0-f43.google.com with SMTP id b13so4774597wgh.34 for ; Wed, 06 Nov 2013 04:51:59 -0800 (PST) In-Reply-To: <2013-10-25T09-34-51@devnull.Karl-Voit.at> (Karl Voit's message of "Fri, 25 Oct 2013 09:54:50 +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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Karl Voit Cc: news1142@Karl-Voit.at, emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Karl, Karl Voit writes: > How about using IDs of the sub-tree headings (if found) in order to > name the buffer? In case someone is using custom IDs (like me), the > list would look like: > > - myorgmode.org-1 (-> no ID found for this sub-heading) > - myorgmode.org-project-foobar (-> :ID: project-foobar) > - myorgmode.org-2013-10-25-customerX (-> :ID: 2013-10-25-customerX) The attached patch does name indirect buffers after the current tree heading -- thanks for this idea. Would anyone else find this useful? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org.el-org-get-indirect-buffer-New-argument-heading.patch >From b5da8fa8ad7c9dc7b4f3c2d177c1aada685e520c Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 6 Nov 2013 13:50:39 +0100 Subject: [PATCH] org.el (org-get-indirect-buffer): New argument `heading' * org.el (org-get-indirect-buffer): New argument `heading' to name the buffer after the current tree heading. (org-tree-to-indirect-buffer): Use `org-get-indirect-buffer' with a `heading' argument. Thanks to Karl Voit for suggesting this. --- lisp/org.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 7c2a316..7e47891 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7466,7 +7466,7 @@ frame is not changed." (not (eq org-indirect-buffer-display 'new-frame)) (not arg)) (kill-buffer org-last-indirect-buffer)) - (setq ibuf (org-get-indirect-buffer cbuf) + (setq ibuf (org-get-indirect-buffer cbuf heading) org-last-indirect-buffer ibuf) (cond ((or (eq org-indirect-buffer-display 'new-frame) @@ -7497,11 +7497,11 @@ frame is not changed." (run-hook-with-args 'org-cycle-hook 'all) (and (window-live-p cwin) (select-window cwin)))) -(defun org-get-indirect-buffer (&optional buffer) +(defun org-get-indirect-buffer (&optional buffer heading) (setq buffer (or buffer (current-buffer))) (let ((n 1) (base (buffer-name buffer)) bname) (while (buffer-live-p - (get-buffer (setq bname (concat base "-" (number-to-string n))))) + (get-buffer (setq bname (concat base "-" (or heading (number-to-string n)))))) (setq n (1+ n))) (condition-case nil (make-indirect-buffer buffer bname 'clone) -- 1.8.4.2 --=-=-= Content-Type: text/plain -- Bastien --=-=-=--