[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [PATCH 2/3] Mark some org-babel variables as safe locals under p
From: |
Eric Schulte |
Subject: |
Re: [O] [PATCH 2/3] Mark some org-babel variables as safe locals under proper conditions |
Date: |
Tue, 29 Oct 2013 19:50:46 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Could you add documentation strings to `org-babel-one-header-arg-safe-p'
and `org-babel-one-header-arg-safe-p'? Also, would the header argument
list in the latter be better as a defvar which ob-*.el files could
let-bind to add their own additional safe header arguments?
Thanks,
Aaron Ecay <address@hidden> writes:
> * lisp/ob-core.el (org-babel-inline-result-wrap,
> org-babel-default-header-args,
> org-babel-default-inline-header-args): mark as safe local variables
> ---
> lisp/ob-core.el | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/lisp/ob-core.el b/lisp/ob-core.el
> index 8fafd4b..60666fc 100644
> --- a/lisp/ob-core.el
> +++ b/lisp/ob-core.el
> @@ -158,6 +158,11 @@ See also `org-babel-noweb-wrap-start'."
> This string must include a \"%s\" which will be replaced by the results."
> :group 'org-babel
> :type 'string)
> +(put 'org-babel-inline-result-wrap
> + 'safe-local-variable
> + (lambda (value)
> + (and (stringp value)
> + (string-match-p "%s" value))))
>
> (defun org-babel-noweb-wrap (&optional regexp)
> (concat org-babel-noweb-wrap-start
> @@ -484,10 +489,14 @@ specific header arguments as well.")
> '((:session . "none") (:results . "replace") (:exports . "code")
> (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no"))
> "Default arguments to use when evaluating a source block.")
> +(put 'org-babel-default-header-args 'safe-local-variable
> + #'org-babel-default-header-args-safe-p)
>
> (defvar org-babel-default-inline-header-args
> '((:session . "none") (:results . "replace") (:exports . "results"))
> "Default arguments to use when evaluating an inline source block.")
> +(put 'org-babel-default-inline-header-args 'safe-local-variable
> + #'org-babel-default-header-args-safe-p)
>
> (defvar org-babel-data-names '("tblname" "results" "name"))
>
> @@ -2785,6 +2794,28 @@ of `org-babel-temporary-directory'."
>
> (add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory)
>
> +(defun org-babel-one-header-arg-safe-p (pair)
> + (or
> + (memq (car pair) '(:cache :colnames :comments
> + :exports :epilogue
> + :hlines :noeval
> + :noweb :noweb-ref
> + :noweb-sep :padline
> + :prologue :rownames
> + :sep :session :tangle
> + :wrap))
> + (and (eq (car pair) :eval)
> + (member (cdr pair) '("never" "query")))
> + (and (eq (car pair) :results)
> + (not (string-match "file" (cdr pair))))))
> +
> +(defun org-babel-default-header-args-safe-p (value)
> + (and (listp value)
> + (and (mapcar (lambda (pair)
> + (and (consp pair)
> + (org-babel-one-header-arg-safe-p pair)))
> + value))))
> +
> (provide 'ob-core)
>
> ;; Local variables:
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D