org-src: Fix auto-save feature

* lisp/org-src.el (org-src-mode): Do not stop auto save feature when
  current buffer is no longer an edit buffer.

Reported-by: Andreas Leha <andreas.leha@med.uni-goettingen.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/97892>
This commit is contained in:
Nicolas Goaziou 2015-05-26 17:06:53 +02:00
parent a714c3a118
commit 59da320b30
1 changed files with 10 additions and 8 deletions

View File

@ -577,14 +577,16 @@ See also `org-src-mode-hook'."
(run-with-idle-timer
org-edit-src-auto-save-idle-delay t
(lambda ()
(let (edit-flag)
(dolist (b (buffer-list))
(when (org-src-edit-buffer-p)
(unless edit-flag (setq edit-flag t))
(when (buffer-modified-p) (org-edit-src-save))))
(unless edit-flag
(cancel-timer org-src--auto-save-timer)
(setq org-src--auto-save-timer nil))))))))
(save-excursion
(let (edit-flag)
(dolist (b (buffer-list))
(with-current-buffer b
(when (org-src-edit-buffer-p)
(unless edit-flag (setq edit-flag t))
(when (buffer-modified-p) (org-edit-src-save)))))
(unless edit-flag
(cancel-timer org-src--auto-save-timer)
(setq org-src--auto-save-timer nil)))))))))
(defun org-src-mode-configure-edit-buffer ()
(when (org-bound-and-true-p org-src--from-org-mode)