* cannot edit two source code examples simultaneously @ 2009-05-15 5:38 Hsiu-Khuern Tang 2009-05-16 17:39 ` Carsten Dominik 0 siblings, 1 reply; 11+ messages in thread From: Hsiu-Khuern Tang @ 2009-05-15 5:38 UTC (permalink / raw) To: emacs-orgmode 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. Thank you for your consideration! -- Best, Hsiu-Khuern. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-15 5:38 cannot edit two source code examples simultaneously Hsiu-Khuern Tang @ 2009-05-16 17:39 ` Carsten Dominik 2009-05-17 17:28 ` Dan Davison 2009-05-19 0:32 ` Hsiu-Khuern Tang 0 siblings, 2 replies; 11+ messages in thread From: Carsten Dominik @ 2009-05-16 17:39 UTC (permalink / raw) To: Hsiu-Khuern Tang; +Cc: emacs-orgmode [-- Attachment #1.1: Type: text/plain, Size: 829 bytes --] 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 [-- Attachment #1.2: Type: text/html, Size: 1209 bytes --] [-- Attachment #2: Type: text/plain, Size: 204 bytes --] _______________________________________________ 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-16 17:39 ` Carsten Dominik @ 2009-05-17 17:28 ` Dan Davison 2009-05-18 5:38 ` Taru Karttunen 2009-05-18 10:48 ` Carsten Dominik 2009-05-19 0:32 ` Hsiu-Khuern Tang 1 sibling, 2 replies; 11+ messages in thread From: Dan Davison @ 2009-05-17 17:28 UTC (permalink / raw) To: Carsten Dominik; +Cc: emacs-orgmode 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 <carsten.dominik@gmail.com> 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 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-17 17:28 ` Dan Davison @ 2009-05-18 5:38 ` Taru Karttunen 2009-05-18 6:07 ` Dan Davison 2009-05-18 10:48 ` Carsten Dominik 1 sibling, 1 reply; 11+ messages in thread From: Taru Karttunen @ 2009-05-18 5:38 UTC (permalink / raw) To: emacs-orgmode Excerpts from Dan Davison's message of Sun May 17 20:28:01 +0300 2009: > 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. Please don't do this. It sounds like a recipe for accidentally losing the source code when careless. - Taru Karttunen ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-18 5:38 ` Taru Karttunen @ 2009-05-18 6:07 ` Dan Davison 2009-05-18 6:27 ` Taru Karttunen 0 siblings, 1 reply; 11+ messages in thread From: Dan Davison @ 2009-05-18 6:07 UTC (permalink / raw) To: Taru Karttunen; +Cc: emacs-orgmode Taru Karttunen <taruti@taruti.net> writes: > Excerpts from Dan Davison's message of Sun May 17 20:28:01 +0300 2009: >> 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. > > Please don't do this. It sounds like a recipe for accidentally losing > the source code when careless. I think it's more complicated than that: source code loss is also the motivation for doing something like this. If you are editing the code in the *Org Edit Src* buffer, and get distracted, you may return to the org buffer and mistakenly decide that it contains the latest content. I've done that two or three times in the last couple of days, resulting in lost work. That mistake cannot be made so easily when there is only ever one current copy of the code. If you close emacs without C-c ', or your laptop power runs out, then I agree that is bad, but I thought perhaps there might be a good solution along these lines. Maybe an alternative would be to maintain a work-in-progress message along with the out-of-date code? Dan > > - Taru Karttunen > > > _______________________________________________ > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-18 6:07 ` Dan Davison @ 2009-05-18 6:27 ` Taru Karttunen 2009-05-18 10:12 ` Carsten Dominik 2009-05-18 15:23 ` Carsten Dominik 0 siblings, 2 replies; 11+ messages in thread From: Taru Karttunen @ 2009-05-18 6:27 UTC (permalink / raw) To: emacs-orgmode Excerpts from Dan Davison's message of Mon May 18 09:07:11 +0300 2009: > I think it's more complicated than that: source code loss is also the > motivation for doing something like this. If you are editing the code in > the *Org Edit Src* buffer, and get distracted, you may return to the org > buffer and mistakenly decide that it contains the latest content. I've > done that two or three times in the last couple of days, resulting in > lost work. That mistake cannot be made so easily when there is only ever > one current copy of the code. If you close emacs without C-c ', or your > laptop power runs out, then I agree that is bad, but I thought perhaps > there might be a good solution along these lines. Maybe an alternative > would be to maintain a work-in-progress message along with the > out-of-date code? How about this - set the source code with a special overlay/property when editing it. The property could turn the code into a link to the buffer and set it read-only. - Taru Karttunen ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-18 6:27 ` Taru Karttunen @ 2009-05-18 10:12 ` Carsten Dominik 2009-05-18 15:23 ` Carsten Dominik 1 sibling, 0 replies; 11+ messages in thread From: Carsten Dominik @ 2009-05-18 10:12 UTC (permalink / raw) To: Taru Karttunen; +Cc: emacs-orgmode On May 18, 2009, at 8:27 AM, Taru Karttunen wrote: > Excerpts from Dan Davison's message of Mon May 18 09:07:11 +0300 2009: >> I think it's more complicated than that: source code loss is also the >> motivation for doing something like this. If you are editing the >> code in >> the *Org Edit Src* buffer, and get distracted, you may return to >> the org >> buffer and mistakenly decide that it contains the latest content. >> I've >> done that two or three times in the last couple of days, resulting in >> lost work. That mistake cannot be made so easily when there is only >> ever >> one current copy of the code. If you close emacs without C-c ', or >> your >> laptop power runs out, then I agree that is bad, but I thought >> perhaps >> there might be a good solution along these lines. Maybe an >> alternative >> would be to maintain a work-in-progress message along with the >> out-of-date code? > > How about this - set the source code with a special overlay/property > when editing it. The property could turn the code into a link to the > buffer and set it read-only. This sounds like a good idea. However, it seems that putting a read- only property using an overlay does not work - does anyone know why? I'd prefer an overlay over text properties here.... - Carsten ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-18 6:27 ` Taru Karttunen 2009-05-18 10:12 ` Carsten Dominik @ 2009-05-18 15:23 ` Carsten Dominik 2009-05-18 17:40 ` Dan Davison 1 sibling, 1 reply; 11+ messages in thread From: Carsten Dominik @ 2009-05-18 15:23 UTC (permalink / raw) To: Taru Karttunen, Dan Davison; +Cc: emacs-orgmode Org-Mode On May 18, 2009, at 8:27 AM, Taru Karttunen wrote: > Excerpts from Dan Davison's message of Mon May 18 09:07:11 +0300 2009: >> I think it's more complicated than that: source code loss is also the >> motivation for doing something like this. If you are editing the >> code in >> the *Org Edit Src* buffer, and get distracted, you may return to >> the org >> buffer and mistakenly decide that it contains the latest content. >> I've >> done that two or three times in the last couple of days, resulting in >> lost work. That mistake cannot be made so easily when there is only >> ever >> one current copy of the code. If you close emacs without C-c ', or >> your >> laptop power runs out, then I agree that is bad, but I thought >> perhaps >> there might be a good solution along these lines. Maybe an >> alternative >> would be to maintain a work-in-progress message along with the >> out-of-date code? > > How about this - set the source code with a special overlay/property > when editing it. The property could turn the code into a link to the > buffer and set it read-only. OK, the source code in the Org buffer is now highlighted while being edited, and you can click on it to go back to the editing buffer. I hope that does solve you problems, Dan? It is not yet read-only, but this feels like an Emacs bug, because I do set read-only in the overlay. > > - Taru Karttunen > > > _______________________________________________ > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-18 15:23 ` Carsten Dominik @ 2009-05-18 17:40 ` Dan Davison 0 siblings, 0 replies; 11+ messages in thread From: Dan Davison @ 2009-05-18 17:40 UTC (permalink / raw) To: Carsten Dominik; +Cc: emacs-orgmode Org-Mode Carsten Dominik <carsten.dominik@gmail.com> writes: > On May 18, 2009, at 8:27 AM, Taru Karttunen wrote: > >> Excerpts from Dan Davison's message of Mon May 18 09:07:11 +0300 2009: >>> I think it's more complicated than that: source code loss is also the >>> motivation for doing something like this. If you are editing the >>> code in >>> the *Org Edit Src* buffer, and get distracted, you may return to >>> the org >>> buffer and mistakenly decide that it contains the latest >>> content. I've >>> done that two or three times in the last couple of days, resulting in >>> lost work. That mistake cannot be made so easily when there is only >>> ever >>> one current copy of the code. If you close emacs without C-c ', or >>> your >>> laptop power runs out, then I agree that is bad, but I thought >>> perhaps >>> there might be a good solution along these lines. Maybe an >>> alternative >>> would be to maintain a work-in-progress message along with the >>> out-of-date code? >> >> How about this - set the source code with a special overlay/property >> when editing it. The property could turn the code into a link to the >> buffer and set it read-only. > > OK, the source code in the Org buffer is now highlighted while > being edited, and you can click on it to go back to the > editing buffer. I hope that does solve you problems, Dan? Hi Carsten, I've given it a quick go and it seems like a very nice solution. Thanks a lot. Dan > > It is not yet read-only, but this feels like an Emacs bug, because I > do set read-only in the overlay. > >> >> - Taru Karttunen >> >> >> _______________________________________________ >> 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 > > > > _______________________________________________ > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-17 17:28 ` Dan Davison 2009-05-18 5:38 ` Taru Karttunen @ 2009-05-18 10:48 ` Carsten Dominik 1 sibling, 0 replies; 11+ messages in thread From: Carsten Dominik @ 2009-05-18 10:48 UTC (permalink / raw) To: Dan Davison; +Cc: emacs-orgmode On May 17, 2009, at 7:28 PM, Dan Davison wrote: > 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. It is totally inappropriate, but I have not yet figured out how to fix this. - Carsten > 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 <carsten.dominik@gmail.com> 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: cannot edit two source code examples simultaneously 2009-05-16 17:39 ` Carsten Dominik 2009-05-17 17:28 ` Dan Davison @ 2009-05-19 0:32 ` Hsiu-Khuern Tang 1 sibling, 0 replies; 11+ messages in thread From: Hsiu-Khuern Tang @ 2009-05-19 0:32 UTC (permalink / raw) To: emacs-orgmode@gnu.org * On Sat 05:39PM +0000, 16 May 2009, Carsten Dominik (carsten.dominik@gmail.com) wrote: > 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. Thanks for implementing this and the subsequent refinements based on Dan's and Taru's inputs! -- Best, Hsiu-Khuern. ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-05-19 0:34 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-05-15 5:38 cannot edit two source code examples simultaneously Hsiu-Khuern Tang 2009-05-16 17:39 ` Carsten Dominik 2009-05-17 17:28 ` Dan Davison 2009-05-18 5:38 ` Taru Karttunen 2009-05-18 6:07 ` Dan Davison 2009-05-18 6:27 ` Taru Karttunen 2009-05-18 10:12 ` Carsten Dominik 2009-05-18 15:23 ` Carsten Dominik 2009-05-18 17:40 ` Dan Davison 2009-05-18 10:48 ` Carsten Dominik 2009-05-19 0:32 ` Hsiu-Khuern Tang
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).