emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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-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

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-07 14:52 edit-src on read-only files 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
  -- strict thread matches above, loose matches on Subject: below --
2013-02-12  0:17 Greg Minshall

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