emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@gnu.org>
To: Karl Voit <devnull@Karl-Voit.at>
Cc: news1142@Karl-Voit.at, emacs-orgmode@gnu.org
Subject: Re: org-tree-to-indirect-buffer: multiple buffers; buffer name containing ID
Date: Wed, 06 Nov 2013 13:51:54 +0100	[thread overview]
Message-ID: <87ob5xae1h.fsf@bzg.ath.cx> (raw)
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")

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

Hi Karl,

Karl Voit <devnull@Karl-Voit.at> 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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-org-get-indirect-buffer-New-argument-heading.patch --]
[-- Type: text/x-diff, Size: 1664 bytes --]

From b5da8fa8ad7c9dc7b4f3c2d177c1aada685e520c Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
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


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

  reply	other threads:[~2013-11-06 12:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25  7:54 org-tree-to-indirect-buffer: multiple buffers; buffer name containing ID Karl Voit
2013-11-06 12:51 ` Bastien [this message]
2013-11-06 16:53   ` Adam Porter
2013-11-13 13:04   ` Bastien
2013-11-13 14:01     ` Karl Voit

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=87ob5xae1h.fsf@bzg.ath.cx \
    --to=bzg@gnu.org \
    --cc=devnull@Karl-Voit.at \
    --cc=emacs-orgmode@gnu.org \
    --cc=news1142@Karl-Voit.at \
    /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).