From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: cannot edit two source code examples simultaneously Date: Sun, 17 May 2009 13:28:01 -0400 Message-ID: <87hbzjmyfy.fsf@stats.ox.ac.uk> References: <20090515053802.GE13183@hplhtang1> <4FBDF50D-609C-4816-952C-54A83854F528@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M5k9l-0008Fn-Lb for emacs-orgmode@gnu.org; Sun, 17 May 2009 13:28:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M5k9g-0008FV-52 for emacs-orgmode@gnu.org; Sun, 17 May 2009 13:28:12 -0400 Received: from [199.232.76.173] (port=33426 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M5k9f-0008FS-Ud for emacs-orgmode@gnu.org; Sun, 17 May 2009 13:28:07 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:60050) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M5k9f-0002SJ-Ga for emacs-orgmode@gnu.org; Sun, 17 May 2009 13:28:07 -0400 In-Reply-To: <4FBDF50D-609C-4816-952C-54A83854F528@gmail.com> (Carsten Dominik's message of "Sat, 16 May 2009 19:39:35 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: emacs-orgmode@gnu.org Following on from this, I'd like to suggest that, while it is being edited, the source code is removed from the org buffer, to avoid concurrency problems. I just had a go at that -- the patch below replaces the source code with a work-in-progress message that contains a link to the edit buffer. That brought up a couple of related questions: 1. Is there a dedicated format for an org-link to an emacs buffer? (I used an elisp: link) 2. Now I'm going to be confusing. Despite me using a link inside a code block in that, I had previously wondered about how appropriate it is that org conducts its special formatting operations inside source code blocks. E.g. in R code, x[[3]] means the 3rd element of list x. But that gets magically formatted by org as a link, which looks weird. Do we think that the current behaviour is desirable? If not, should org be prevented from formatting stuff in literal blocks, or is it too inefficient or messy to implement that? (If it were changed, the work-in-progress message could go outside the block.) Dan diff --git a/lisp/org.el b/lisp/org.el index b9df6ec..25973be 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6394,6 +6394,7 @@ the edited version." nil (setq beg (move-marker beg (nth 0 info)) end (move-marker end (nth 1 info)) + org-buffer (buffer-name) code (buffer-substring-no-properties beg end) lang (nth 2 info) single (nth 3 info) @@ -6409,6 +6410,14 @@ the edited version." (and buffer (kill-buffer buffer)) (switch-to-buffer (generate-new-buffer "*Org Edit Src Example*")) (insert code) + (save-excursion + (let ((src-buffer (buffer-name))) + (set-buffer org-buffer) + (goto-char beg) + (delete-region beg end) + (insert (format "<<%s [[elisp:(switch-to-buffer \"%s\")][%s]]>>" + "Contents are currently being edited" src-buffer "here")) + (setq end (move-marker end (point))))) (remove-text-properties (point-min) (point-max) '(display nil invisible nil intangible nil)) (let ((org-inhibit-startup t)) Carsten Dominik writes: > Hi Hsiu-Khuern, > > On May 15, 2009, at 7:38 AM, Hsiu-Khuern Tang wrote: > > Hi Carsten, > > You recently changed org-edit-src-code to use a separate buffer instead of an > indirect buffer. One side effect of this is that I can no longer edit several > code examples at the same time: opening the second buffer will silently discard > any changes made in the first. I would prefer this behavior: when opening the > second edit source buffer, write any changes in the first buffer to the > originating Org buffer (but don't save it, of course). > > Another approach is to use different buffer names. > > I think the second idea is better, provided that a mechanism > ensures that not two editing instances of the same region > are created. This is what I have implemented now. Thank > you for your report. > > - Carsten > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode