Explorar el Código

ob-tangle.el (org-babel-tangle): Fix readonly tangle

* lisp/ob-tangle.el (org-babel-tangle): Fix readonly tangle.
Sébastien Miquel hace 4 años
padre
commit
d59f35fbb7
Se han modificado 1 ficheros con 4 adiciones y 4 borrados
  1. 4 4
      lisp/ob-tangle.el

+ 4 - 4
lisp/ob-tangle.el

@@ -268,11 +268,11 @@ matching a regular expression."
 		    lspecs)
 		   (when make-dir
 		     (make-directory fnd 'parents))
-                   ;; erase previous file and set permissions on empty
-                   ;; file before writing
-                   (write-region "" nil file-name nil 0)
-		   (mapc (lambda (mode) (set-file-modes file-name mode)) modes)
+                   ;; erase previous file
+                   (when (file-exists-p file-name)
+                     (delete-file file-name))
 		   (write-region nil nil file-name)
+		   (mapc (lambda (mode) (set-file-modes file-name mode)) modes)
                    (push file-name path-collector))))))
 	 (if (equal arg '(4))
 	     (org-babel-tangle-single-block 1 t)