summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2013-06-08 12:29:02 -0600
committerEric Schulte <schulte.eric@gmail.com>2013-06-08 12:29:02 -0600
commit2a73e06a6d5ce0cc9744fc18f91c601dd7869bad (patch)
treedbe7c00a8cce70d6b4910c4d4c98d3780096badf
parent805d1e63d692744cd704b640286b9a107c712f50 (diff)
downloadorg-mode-2a73e06a6d5ce0cc9744fc18f91c601dd7869bad.tar.gz
adding a new global tangle-mode header argument
* doc/org.texi (Top): Documentation for new tangle-mode header argument. (Specific header arguments): Documentation for new tangle-mode header argument. (rownames): Documentation for new tangle-mode header argument. (tangle-mode): Documentation for new tangle-mode header argument. * lisp/ob-core.el (org-babel-common-header-args-w-values): Adding the new :tangle-mode header argument. (org-babel-read): Read values starting with a "#" character as emacs lisp. * lisp/ob-tangle.el (org-babel-tangle): Use the new :tangle-mode header argument. * lisp/org-pcomplete.el (pcomplete/org-mode/block-option/src): Use the new :tangle-mode header argument.
-rw-r--r--doc/org.texi20
-rw-r--r--lisp/ob-core.el11
-rw-r--r--lisp/ob-tangle.el8
-rw-r--r--lisp/org-pcomplete.el2
4 files changed, 31 insertions, 10 deletions
diff --git a/doc/org.texi b/doc/org.texi
index 6d5eca0..2297202 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -722,6 +722,7 @@ Specific header arguments
* colnames:: Handle column names in tables
* rownames:: Handle row names in tables
* shebang:: Make tangled files executable
+* tangle-mode:: Set permission of tangled files
* eval:: Limit evaluation of specific code blocks
* wrap:: Mark source block evaluation results
* post:: Post processing of code block results
@@ -14167,6 +14168,7 @@ argument in lowercase letters. The following header arguments are defined:
* colnames:: Handle column names in tables
* rownames:: Handle row names in tables
* shebang:: Make tangled files executable
+* tangle-mode:: Set permission of tangled files
* eval:: Limit evaluation of specific code blocks
* wrap:: Mark source block evaluation results
* post:: Post processing of code block results
@@ -15061,7 +15063,7 @@ variable indexing @xref{var, Indexable variable values}.
@end itemize
-@node shebang, eval, rownames, Specific header arguments
+@node shebang, tangle-mode, rownames, Specific header arguments
@subsubsection @code{:shebang}
Setting the @code{:shebang} header argument to a string value
@@ -15069,7 +15071,21 @@ Setting the @code{:shebang} header argument to a string value
first line of any tangled file holding the code block, and the file
permissions of the tangled file are set to make it executable.
-@node eval, wrap, shebang, Specific header arguments
+
+@node tangle-mode, eval, shebang, Specific header arguments
+@subsubsection @code{:tangle-mode}
+
+The @code{tangle-mode} header argument controls the permission set on tangled
+files. The value of this header argument will be passed to
+@code{set-file-modes}. For example, to set a tangled file as read only use
+@code{:tangle-mode #o444}, or to set a tangled file as executable use
+@code{:tangle-mode #o755}. Files with @ref{shebang} header arguments will
+automatically be made executable unless the @code{tangle-mode} header
+argument is also used. The behavior is undefined if multiple code blocks
+with different values for the @code{tangle-mode} header argument are tangled
+to the same file.
+
+@node eval, wrap, tangle-mode, Specific header arguments
@subsubsection @code{:eval}
The @code{:eval} header argument can be used to limit the evaluation of
specific code blocks. The @code{:eval} header argument can be useful for
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 3e28cef..c3b1333 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -464,6 +464,7 @@ then run `org-babel-switch-to-session'."
(session . :any)
(shebang . :any)
(tangle . ((tangle yes no :any)))
+ (tangle-mode . ((#o755 #o555 #o444 :any)))
(var . :any)
(wrap . :any)))
@@ -2527,14 +2528,14 @@ block but are passed literally to the \"example-block\"."
(defun org-babel-read (cell &optional inhibit-lisp-eval)
"Convert the string value of CELL to a number if appropriate.
Otherwise if cell looks like lisp (meaning it starts with a
-\"(\", \"'\", \"`\" or a \"[\") then read it as lisp, otherwise
-return it unmodified as a string. Optional argument NO-LISP-EVAL
-inhibits lisp evaluation for situations in which is it not
-appropriate."
+\"(\", \"'\", \"`\" \"#\" or a \"[\") then read it as lisp,
+otherwise return it unmodified as a string. Optional argument
+NO-LISP-EVAL inhibits lisp evaluation for situations in which is
+it not appropriate."
(if (and (stringp cell) (not (equal cell "")))
(or (org-babel-number-p cell)
(if (and (not inhibit-lisp-eval)
- (or (member (substring cell 0 1) '("(" "'" "`" "["))
+ (or (member (substring cell 0 1) '("(" "'" "`" "[" "#"))
(string= cell "*this*")))
(eval (read cell))
(if (string= (substring cell 0 1) "\"")
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 82f2c10..9b7129e 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -210,6 +210,7 @@ used to limit the exported source code blocks by language."
(let* ((tangle (funcall get-spec :tangle))
(she-bang ((lambda (sheb) (when (> (length sheb) 0) sheb))
(funcall get-spec :shebang)))
+ (tangle-mode (funcall get-spec :tangle-mode))
(base-name (cond
((string= "yes" tangle)
(file-name-sans-extension
@@ -244,8 +245,11 @@ used to limit the 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 permissions on the tangled file
+ (if tangle-mode
+ (set-file-modes file-name tangle-mode)
+ ;; if files contain she-bangs, then make the executable
+ (when she-bang (set-file-modes file-name #o755)))
;; update counter
(setq block-counter (+ 1 block-counter))
(add-to-list 'path-collector file-name)))))
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 43b5f46..77e2b3b 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -391,7 +391,7 @@ Complete a language in the first field, the header arguments and switches."
'("-n" "-r" "-l"
":cache" ":colnames" ":comments" ":dir" ":eval" ":exports"
":file" ":hlines" ":no-expand" ":noweb" ":results" ":rownames"
- ":session" ":shebang" ":tangle" ":var"))))
+ ":session" ":shebang" ":tangle" ":tangle-mode" ":var"))))
(defun pcomplete/org-mode/block-option/clocktable ()
"Complete keywords in a clocktable line."