浏览代码

Properly save source blocks with `save-some-buffers'

* lisp/org-src.el (org-src-mode-configure-edit-buffer): Set
  `write-contents-functions' so that saving a remote editing buffer
  always call `org-edit-src-save'.
(org-edit-src-save): Return a non-nil value explicitly.

Reported-by: Thibault Polge <thibault@thb.lt>
<http://permalink.gmane.org/gmane.emacs.orgmode/112201>
Nicolas Goaziou 8 年之前
父节点
当前提交
bf601016dc
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      lisp/org-src.el

+ 6 - 2
lisp/org-src.el

@@ -646,7 +646,8 @@ See also `org-src-mode-hook'."
 	  (setq buffer-offer-save t)
 	  (setq buffer-file-name
 		(concat (buffer-file-name (marker-buffer org-src--beg-marker))
-			"[" (buffer-name) "]")))
+			"[" (buffer-name) "]"))
+	  (setq-local write-contents-functions '(org-edit-src-save)))
       (setq buffer-read-only t))))
 
 (add-hook 'org-src-mode-hook #'org-src-mode-configure-edit-buffer)
@@ -1032,7 +1033,10 @@ Throw an error if there is no such buffer."
 	(insert edited-code)
 	(when (and expecting-bol (not (bolp))) (insert "\n")))
       (save-buffer)
-      (move-overlay overlay beg (point)))))
+      (move-overlay overlay beg (point))))
+  ;; `write-contents-functions' require the function to return
+  ;; a non-nil value so that other functions are not called.
+  t)
 
 (defun org-edit-src-exit ()
   "Kill current sub-editing buffer and return to source buffer."