diff options
author | Bastien Guerry <bzg@altern.org> | 2013-04-16 10:38:01 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2013-04-16 10:38:01 +0200 |
commit | 7790a97cdd22bc82ec2e36a3e26d5662a20ac2ed (patch) | |
tree | 4030773e1d5f4e92ee5e497dda4fa326cfc2fd28 | |
parent | f20de09dcbc1edf57b4c0f691f779ddb6e56981d (diff) | |
download | org-mode-7790a97cdd22bc82ec2e36a3e26d5662a20ac2ed.tar.gz |
org-src.el (org-edit-src-turn-on-auto-save): New option
* org-src.el (org-edit-src-turn-on-auto-save): New option.
(org-edit-src-code): Use it.
(org-edit-src-auto-save-idle-delay): Enhance docstring.
* doc/org.texi (Editing source code): Document
`org-edit-src-auto-save-idle-delay' and
`org-edit-src-turn-on-auto-save'.
Thanks to Charles C. Berry for bringing this up again.
-rw-r--r-- | doc/org.texi | 13 | ||||
-rw-r--r-- | lisp/org-src.el | 21 |
2 files changed, 27 insertions, 7 deletions
diff --git a/doc/org.texi b/doc/org.texi index cc92f0a..d969ff0 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -13465,11 +13465,16 @@ Source code in the specified language. @cindex code block, editing @cindex source code, editing +@vindex org-edit-src-auto-save-idle-delay +@vindex org-edit-src-turn-on-auto-save @kindex C-c ' -Use @kbd{C-c '} to edit the current code block. This brings up -a language major-mode edit buffer containing the body of the code -block. Saving this buffer will write the new contents back to the Org -buffer. Use @kbd{C-c '} again to exit. +Use @kbd{C-c '} to edit the current code block. This brings up a language +major-mode edit buffer containing the body of the code block. Manually +saving this buffer with @key{C-x C-s} will write the contents back to the Org +buffer. You can also set @var{org-edit-src-auto-save-idle-delay} to save the +base buffer after some idle delay, or @code{org-edit-src-turn-on-auto-save} +to auto-save this buffer into a separate file using @code{auto-save-mode}. +Use @kbd{C-c '} again to exit. The @code{org-src-mode} minor mode will be active in the edit buffer. The following variables can be used to configure the behavior of the edit diff --git a/lisp/org-src.el b/lisp/org-src.el index d294796..81b8e40 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -64,10 +64,25 @@ there are kept outside the narrowed region." (const :tag "from `lang' element") (const :tag "from `style' element"))))) +(defcustom org-edit-src-turn-on-auto-save nil + "Non-nil means turn `auto-save-mode' on when editing a source block. +This will save the content of the source code editing buffer into +a newly created file, not the base buffer for this source block. + +If you want to regularily save the base buffer instead of the source +code editing buffer, see `org-edit-src-auto-save-idle-delay' instead." + :group 'org-edit-structure + :version "24.4" + :package-version '(Org . "8.0") + :type 'boolean) + (defcustom org-edit-src-auto-save-idle-delay 0 - "Delay of idle time before auto-saving src code buffers. + "Delay before saving a source code buffer back into its base buffer. When a positive integer N, save after N seconds of idle time. -When 0 (the default), don't auto-save." +When 0 (the default), don't auto-save. + +If you want to save the source code buffer itself, don't use this. +Check `org-edit-src-turn-on-auto-save' instead." :group 'org-edit-structure :version "24.4" :package-version '(Org . "8.0") @@ -351,7 +366,7 @@ the display of windows containing the Org buffer and the code buffer." (org-src-mode) (set-buffer-modified-p nil) (setq buffer-file-name nil) - (when auto-save-default + (when org-edit-src-turn-on-auto-save (setq buffer-auto-save-file-name (concat (make-temp-name "org-src-") (format-time-string "-%Y-%d-%m") ".txt"))) |