Browse Source

tangled files should not be writable

  Hopefully this will help keep people from editing tangled source files
  by accident.

* lisp/ob-tangle.el (org-babel-tangle): Tangled files should not be
  writable.
Eric Schulte 8 years ago
parent
commit
5e3b8259c7
1 changed files with 6 additions and 2 deletions
  1. 6 2
      lisp/ob-tangle.el

+ 6 - 2
lisp/ob-tangle.el

@@ -259,8 +259,12 @@ exported source code blocks by language."
 			    (goto-char (point-max))
 			    (insert content)
 			    (write-region nil nil file-name))))
-		      ;; if files contain she-bangs, then make the executable
-		      (when she-bang (set-file-modes file-name #o755))
+		      (set-file-modes
+		       file-name
+		       ;; never writable (don't accidentally edit tangled files)
+		       (if she-bang
+			   #o555 ;; files with she-bangs should be executable
+			 #o444)) ;; those without should not
 		      ;; update counter
 		      (setq block-counter (+ 1 block-counter))
 		      (add-to-list 'path-collector file-name)))))