From 01f736b763729e4d1e6a82faa31748f2bd2d1e0a Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 11 Sep 2014 18:19:21 +0200 Subject: [PATCH 1/2] org-src: Fix idle auto-save feature * lisp/org-src.el (org-edit-src-code): Fix regexp. (org-edit-src-exit): Do not remove auto-save timer. This is handled by the timer itself. `org-edit-src-save' calls `org-edit-src-exit', which then clears the auto-save timer, thus preventing any further auto-saves before the next `org-edit-src-code' call. Thanks to Adriaan Sticker for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/90650 --- lisp/org-src.el | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index f870b2c71..752fa30bd 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -376,23 +376,21 @@ the display of windows containing the Org buffer and the code buffer." (when (fboundp edit-prep-func) (funcall edit-prep-func full-info))) (or org-edit-src-code-timer + (zerop org-edit-src-auto-save-idle-delay) (setq org-edit-src-code-timer - (unless (zerop org-edit-src-auto-save-idle-delay) - (run-with-idle-timer - org-edit-src-auto-save-idle-delay t - (lambda () - (cond - ((and (string-match "\*Org Src" (buffer-name)) - (buffer-modified-p)) - (org-edit-src-save)) - ((not - (delq nil (mapcar - (lambda (b) - (string-match "\*Org Src" (buffer-name b))) - (buffer-list)))) - (cancel-timer org-edit-src-code-timer) - (setq org-edit-src-code-timer))))))))) - t))) + (run-with-idle-timer + org-edit-src-auto-save-idle-delay t + (lambda () + (cond + ((org-string-match-p "\\`\\*Org Src" (buffer-name)) + (when (buffer-modified-p) (org-edit-src-save))) + ((not (org-some (lambda (b) + (org-string-match-p "\\`\\*Org Src" + (buffer-name b))) + (buffer-list))) + (cancel-timer org-edit-src-code-timer) + (setq org-edit-src-code-timer nil)))))))) + t))) (defun org-edit-src-continue (e) "Continue editing source blocks." ;; Fixme: be more accurate @@ -757,8 +755,8 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." (delete-region beg (max beg end)) (unless (string-match "\\`[ \t]*\\'" code) (insert code)) - ;; Make sure the overlay stays in place - (when (eq context 'save) (move-overlay ovl beg (point))) + ;; Make sure the overlay stays in place + (when (eq context 'save) (move-overlay ovl beg (point))) (goto-char beg) (if single (just-one-space))) (if (memq t (mapcar (lambda (overlay) @@ -774,9 +772,6 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." (unless (eq context 'save) (move-marker beg nil) (move-marker end nil))) - (when org-edit-src-code-timer - (cancel-timer org-edit-src-code-timer) - (setq org-edit-src-code-timer nil)) (unless (eq context 'save) (when org-edit-src-saved-temp-window-config (set-window-configuration org-edit-src-saved-temp-window-config) From 6eb9827d53fd40927dbca3856dd3d18e051a6b39 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 11 Sep 2014 23:19:22 +0200 Subject: [PATCH 2/2] org-element: Fix cache error on empty drawers * lisp/org-element.el (org-element--cache-for-removal): Handle case when greater element is totally empty. Thanks to Malcolm Purvis for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/90639 --- lisp/org-element.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index f175fbc50..484c37703 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -5492,8 +5492,10 @@ changes." (if (and (memq (org-element-type up) '(center-block drawer dynamic-block quote-block special-block)) - (<= (org-element-property :contents-begin up) beg) - (> (org-element-property :contents-end up) end)) + (let ((cbeg (org-element-property :contents-begin up))) + (and cbeg + (<= cbeg beg) + (> (org-element-property :contents-end up) end)))) ;; UP is a robust greater element containing changes. ;; We only need to extend its ending boundaries. (org-element--cache-shift-positions