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.
This commit is contained in:
Eric Schulte 2012-12-11 20:20:50 -07:00
parent ff0081847c
commit 5e3b8259c7
1 changed files with 6 additions and 2 deletions

View File

@ -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)))))