* edit-src on read-only files
@ 2013-02-07 14:52 Greg Minshall
2013-02-08 23:48 ` Eric S Fraga
2013-02-11 15:22 ` Bastien
0 siblings, 2 replies; 10+ messages in thread
From: Greg Minshall @ 2013-02-07 14:52 UTC (permalink / raw)
To: emacs-orgmode
hi. i use RCS on my .org files. it's happened to me more than once (>1
==> "shame on me") that i've entered "C-c '" on a read-only .org file,
spent some time editing the source code fragment, then done "C-c '",
only to lose my edits, as the original buffer was read-only.
it seems like org-mode should prevent that. but, in the meantime, i've
put the following in my .emacs, which seems to prevent this.
note that this *also* prevents "C-c '" in cases where it isn't harmful:
looking at included files, following links, etc. (i.e., functions that
don't -- as far as i know -- modify the file whence they were invoked.)
i tried putting the advice around the main culprits
(org-table-edit-formulas, org-edit-src-code, and
org-edit-fixed-width-region), but 1) i don't know how to "loop" in elisp
'special' mode (so i didn't have to repeat the same lines three times);
2) for some reason (wasn't loaded?), org-table-edit-formulas wasn't
taking the advice; 3) i don't use those other functions.
anyway, fwiw, here's this:
----
;; in org-mode, make sure we don't edit-special a read-only file...
(defadvice org-edit-special (around make-sure-writable)
"make sure the source buffer is writable before allowing src-edit"
(if buffer-read-only
(display-warning :error "attempting to src-edit a read-only file...")
ad-do-it))
(ad-activate 'org-edit-special)
----
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
2013-02-07 14:52 Greg Minshall
@ 2013-02-08 23:48 ` Eric S Fraga
2013-02-09 12:58 ` Andreas Leha
2013-02-11 15:22 ` Bastien
1 sibling, 1 reply; 10+ messages in thread
From: Eric S Fraga @ 2013-02-08 23:48 UTC (permalink / raw)
To: Greg Minshall; +Cc: emacs-orgmode
Greg Minshall <minshall@umich.edu> writes:
> hi. i use RCS on my .org files. it's happened to me more than once (>1
> ==> "shame on me") that i've entered "C-c '" on a read-only .org file,
> spent some time editing the source code fragment, then done "C-c '",
> only to lose my edits, as the original buffer was read-only.
Yes, I share your shame... this has happened to me more than once as
well. Thank you for the simple solution which I have installed!
But you are correct that org should check for this case. Or at least
provide a mechanism for saving the source code block elsewhere...
eric
--
: Eric S Fraga, GnuPG: 0xC89193D8FFFCF67D
: in Emacs 24.3.50.1 and Org 7.9.3e-904-g338046
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
2013-02-08 23:48 ` Eric S Fraga
@ 2013-02-09 12:58 ` Andreas Leha
2013-02-16 10:36 ` Bastien
0 siblings, 1 reply; 10+ messages in thread
From: Andreas Leha @ 2013-02-09 12:58 UTC (permalink / raw)
To: emacs-orgmode
Hi all,
Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> Greg Minshall <minshall@umich.edu> writes:
>
>> hi. i use RCS on my .org files. it's happened to me more than once (>1
>> ==> "shame on me") that i've entered "C-c '" on a read-only .org file,
>> spent some time editing the source code fragment, then done "C-c '",
>> only to lose my edits, as the original buffer was read-only.
>
> Yes, I share your shame... this has happened to me more than once as
> well. Thank you for the simple solution which I have installed!
>
I have installed that as well. Very nice thanks.
> But you are correct that org should check for this case. Or at least
> provide a mechanism for saving the source code block elsewhere...
Seconded.
On a related note: I'd also love to see the changes in the
source code buffers be autosaved in the org file. I've lost some big
edits already due to power loss on my (old) laptop.
Cheers,
Andreas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
2013-02-07 14:52 Greg Minshall
2013-02-08 23:48 ` Eric S Fraga
@ 2013-02-11 15:22 ` Bastien
1 sibling, 0 replies; 10+ messages in thread
From: Bastien @ 2013-02-11 15:22 UTC (permalink / raw)
To: Greg Minshall; +Cc: emacs-orgmode
Hi Greg,
Greg Minshall <minshall@umich.edu> writes:
> hi. i use RCS on my .org files. it's happened to me more than once (>1
> ==> "shame on me") that i've entered "C-c '" on a read-only .org file,
> spent some time editing the source code fragment, then done "C-c '",
> only to lose my edits, as the original buffer was read-only.
>
> it seems like org-mode should prevent that.
Yes, this is now the case in master. Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
@ 2013-02-12 0:17 Greg Minshall
0 siblings, 0 replies; 10+ messages in thread
From: Greg Minshall @ 2013-02-12 0:17 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
>> it seems like org-mode should prevent that.
>Yes, this is now the case in master. Thanks!
great -- thank you!!
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
2013-02-09 12:58 ` Andreas Leha
@ 2013-02-16 10:36 ` Bastien
2013-02-27 20:40 ` Andreas Leha
0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2013-02-16 10:36 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
Hi Andreas,
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> On a related note: I'd also love to see the changes in the
> source code buffers be autosaved in the org file. I've lost some big
> edits already due to power loss on my (old) laptop.
There is now `org-edit-src-auto-save-idle-delay' which you can
set to >0 so that the edit src buffer will be saved after N secs
of idle time.
Thanks for suggesting this,
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
2013-02-16 10:36 ` Bastien
@ 2013-02-27 20:40 ` Andreas Leha
2013-03-02 15:11 ` Bastien
0 siblings, 1 reply; 10+ messages in thread
From: Andreas Leha @ 2013-02-27 20:40 UTC (permalink / raw)
To: emacs-orgmode
Hi Bastien,
Bastien <bzg@altern.org> writes:
> Hi Andreas,
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> On a related note: I'd also love to see the changes in the
>> source code buffers be autosaved in the org file. I've lost some big
>> edits already due to power loss on my (old) laptop.
>
> There is now `org-edit-src-auto-save-idle-delay' which you can
> set to >0 so that the edit src buffer will be saved after N secs
> of idle time.
>
> Thanks for suggesting this,
thanks for taking this up! But I am not sure, whether I like the
current implementation too much. Instead of saving the org-file itself,
I'd prefer the org-file to be auto-saved. More importantly, the current
implementation prevents me from discarding the edit with the new C-c C-k
(org-edit-src-abort).
I am not sure how to overcome those limitations (especially the second
one), though. So I fear, I won't be able to provide a patch
implementing my preferred behaviour.
Regards,
Andreas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
2013-02-27 20:40 ` Andreas Leha
@ 2013-03-02 15:11 ` Bastien
2013-03-18 20:36 ` Andreas Leha
2013-03-18 22:22 ` Andreas Leha
0 siblings, 2 replies; 10+ messages in thread
From: Bastien @ 2013-03-02 15:11 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
Hi Andreas,
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> thanks for taking this up! But I am not sure, whether I like the
> current implementation too much. Instead of saving the org-file itself,
> I'd prefer the org-file to be auto-saved.
You can use auto-save-mode then.
I changed the `buffer-auto-save-file-name' so that
it's unique and shows the date of the auto-save.
I also deactivated the timer for auto-saving into
the buffer where the source code lives, as it is
a bit too intrusive IMO.
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
2013-03-02 15:11 ` Bastien
@ 2013-03-18 20:36 ` Andreas Leha
2013-03-18 22:22 ` Andreas Leha
1 sibling, 0 replies; 10+ messages in thread
From: Andreas Leha @ 2013-03-18 20:36 UTC (permalink / raw)
To: emacs-orgmode
Hi Bastien,
thanks again for implementing this!
Bastien <bzg@altern.org> writes:
> Hi Andreas,
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> thanks for taking this up! But I am not sure, whether I like the
>> current implementation too much. Instead of saving the org-file itself,
>> I'd prefer the org-file to be auto-saved.
>
> You can use auto-save-mode then.
> I changed the `buffer-auto-save-file-name' so that
> it's unique and shows the date of the auto-save.
This is very nice! I've actually meant to have the parent org-buffer
auto-saved including the changes in any open source buffer. But this is
really good as well. And a much simpler solution.
>
> I also deactivated the timer for auto-saving into
> the buffer where the source code lives, as it is
> a bit too intrusive IMO.
I agree. I've also disabled this and -- given the better auto-saving
mechanism (which gets disabled by saving) -- won't use any more.
Thanks again,
Andreas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: edit-src on read-only files
2013-03-02 15:11 ` Bastien
2013-03-18 20:36 ` Andreas Leha
@ 2013-03-18 22:22 ` Andreas Leha
1 sibling, 0 replies; 10+ messages in thread
From: Andreas Leha @ 2013-03-18 22:22 UTC (permalink / raw)
To: emacs-orgmode
Hi Bastien,
thanks again for implementing this!
Bastien <bzg@altern.org> writes:
> Hi Andreas,
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> thanks for taking this up! But I am not sure, whether I like the
>> current implementation too much. Instead of saving the org-file itself,
>> I'd prefer the org-file to be auto-saved.
>
> You can use auto-save-mode then.
> I changed the `buffer-auto-save-file-name' so that
> it's unique and shows the date of the auto-save.
This is very nice! I've actually meant to have the parent org-buffer
auto-saved including the changes in any open source buffer. But this is
really good as well. And a much simpler solution.
>
> I also deactivated the timer for auto-saving into
> the buffer where the source code lives, as it is
> a bit too intrusive IMO.
I agree. I've also disabled this and -- given the better auto-saving
mechanism (which gets disabled by saving) -- won't use any more.
Thanks again,
Andreas
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-04-08 16:03 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-12 0:17 edit-src on read-only files Greg Minshall
-- strict thread matches above, loose matches on Subject: below --
2013-02-07 14:52 Greg Minshall
2013-02-08 23:48 ` Eric S Fraga
2013-02-09 12:58 ` Andreas Leha
2013-02-16 10:36 ` Bastien
2013-02-27 20:40 ` Andreas Leha
2013-03-02 15:11 ` Bastien
2013-03-18 20:36 ` Andreas Leha
2013-03-18 22:22 ` Andreas Leha
2013-02-11 15:22 ` Bastien
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).