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)
----

Reply via email to