From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [PATCH 2/3] Mark some org-babel variables as safe locals under proper conditions Date: Tue, 29 Oct 2013 19:50:46 -0600 Message-ID: <8761sfcykv.fsf@gmail.com> References: <1382991543-14273-1-git-send-email-aaronecay@gmail.com> <1382991543-14273-3-git-send-email-aaronecay@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbL0L-0002g5-Vz for emacs-orgmode@gnu.org; Tue, 29 Oct 2013 21:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbL0G-0005pL-L9 for emacs-orgmode@gnu.org; Tue, 29 Oct 2013 21:55:29 -0400 Received: from mail-pd0-x233.google.com ([2607:f8b0:400e:c02::233]:34620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbL0G-0005pC-Dw for emacs-orgmode@gnu.org; Tue, 29 Oct 2013 21:55:24 -0400 Received: by mail-pd0-f179.google.com with SMTP id y10so252140pdj.38 for ; Tue, 29 Oct 2013 18:55:23 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Aaron Ecay Cc: emacs-orgmode@gnu.org 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 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