From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg Minshall Subject: edit-src on read-only files Date: Thu, 07 Feb 2013 09:52:46 -0500 Message-ID: <7201.1360248766@greg-minshalls-mbp.local> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:53070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3SqK-0006h0-UY for emacs-orgmode@gnu.org; Thu, 07 Feb 2013 09:52:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U3SqH-0006wb-M7 for emacs-orgmode@gnu.org; Thu, 07 Feb 2013 09:52:52 -0500 Received: from relay03.pair.com ([209.68.5.17]:3347) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1U3SqH-0006wI-FH for emacs-orgmode@gnu.org; Thu, 07 Feb 2013 09:52:49 -0500 Received: from greg-minshalls-mbp.local (localhost [127.0.0.1]) by gregair.cliq.com (Postfix) with ESMTP id 8B8226B131EE for ; Thu, 7 Feb 2013 09:52:46 -0500 (EST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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) ----