From: Greg Minshall <minshall@umich.edu>
To: emacs-orgmode@gnu.org
Subject: edit-src on read-only files
Date: Thu, 07 Feb 2013 09:52:46 -0500 [thread overview]
Message-ID: <7201.1360248766@greg-minshalls-mbp.local> (raw)
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)
----
next reply other threads:[~2013-02-07 14:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-07 14:52 Greg Minshall [this message]
2013-02-08 23:48 ` edit-src on read-only files 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7201.1360248766@greg-minshalls-mbp.local \
--to=minshall@umich.edu \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.