From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [babel] buffer-wide settings for R graphical header arguments Date: Thu, 27 May 2010 15:32:10 -0400 Message-ID: <87y6f5ta2t.fsf@stats.ox.ac.uk> References: <4BFEB99F.5070202@ccbr.umn.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=36933 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHioZ-0000be-NT for emacs-orgmode@gnu.org; Thu, 27 May 2010 15:32:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHioV-0002hV-6v for emacs-orgmode@gnu.org; Thu, 27 May 2010 15:32:23 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:41882) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHioU-0002hL-Vy for emacs-orgmode@gnu.org; Thu, 27 May 2010 15:32:19 -0400 In-Reply-To: <4BFEB99F.5070202@ccbr.umn.edu> (Erik Iverson's message of "Thu, 27 May 2010 13:27:43 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Erik Iverson Cc: emacs-orgmode Erik Iverson writes: > Hello, > > You can specify graphical header args in source blocks for R blocks > that produce graphical output, e.g.: > > #+BEGIN_SRC R :file output.png :width 720 > > You can also set buffer-wide options with the following syntax, for > example, with the tangle header argument. > > #+PROPERTY: tangle yes > > However, this doesn't appear to be working for me if I use, say > width`, in the following fashion. > > #+PROPERTY: width 720 > > Are R graphical header arguments supposed to be able to be set buffer-wide? Hi Erik, Not currently but let's allow this. Currently, when checking org properties we look for general org-babel header args, but not language-specific header args. (And :width is currently R-specific I believe). Eric -- how do you feel about the patches below? This adds the ability for languages to define their own list of header arg names, e.g. org-babel-header-arg-names:R. Then when we check org properties for babel header args, we additionally check for language-specific header args. --8<---------------cut here---------------start------------->8--- commit 13d20f842796406557d2f439853013200ad5dbf8 Author: Dan Davison Date: Thu May 27 15:18:12 2010 -0400 babel: Check properties for language-specific header args diff --git a/contrib/babel/lisp/org-babel.el b/contrib/babel/lisp/org-babel.el index 4f3d09c..ae6f8fa 100644 @@ -571,21 +571,29 @@ with C-c C-c." (goto-char (match-end 0)))) (unless visited-p (kill-buffer (file-name-nondirectory ,file))))) -(defun org-babel-params-from-properties () +(defun org-babel-params-from-properties (&optional lang) "Return an association list of any source block params which may be specified in the properties of the current outline entry." - (save-match-data - (delq nil - (mapcar - (lambda (header-arg) - (let ((val (or (condition-case nil - (org-entry-get (point) header-arg t) - (error nil)) - (cdr (assoc header-arg org-file-properties))))) - (when val - ;; (message "prop %s=%s" header-arg val) ;; debugging - (cons (intern (concat ":" header-arg)) val)))) - (mapcar 'symbol-name org-babel-header-arg-names))))) + (let (lang-header-arg-names) + (when lang + (let ((lang-header-arg-names-symbol + (intern (concat "org-babel-header-arg-names:" lang)))) + (if (boundp lang-header-arg-names-symbol) + (setq lang-header-arg-names + (eval lang-header-arg-names-symbol))))) + (save-match-data + (delq nil + (mapcar + (lambda (header-arg) + (let ((val (or (condition-case nil + (org-entry-get (point) header-arg t) + (error nil)) + (cdr (assoc header-arg org-file-properties))))) + (when val + ;; (message "prop %s=%s" header-arg val) ;; debugging + (cons (intern (concat ":" header-arg)) val)))) + (mapcar 'symbol-name + (append org-babel-header-arg-names lang-header-arg-names))))))) (defun org-babel-parse-src-block-match () (let* ((lang (org-babel-clean-text-properties (match-string 1))) @@ -603,7 +611,7 @@ may be specified in the properties of the current outline entry." (buffer-string))) (org-babel-merge-params org-babel-default-header-args - (org-babel-params-from-properties) + (org-babel-params-from-properties lang) (if (boundp lang-headers) (eval lang-headers) nil) (org-babel-parse-header-arguments (org-babel-clean-text-properties (or (match-string 3) "")))) @@ -617,7 +625,7 @@ may be specified in the properties of the current outline entry." (org-babel-clean-text-properties (match-string 5))) (org-babel-merge-params org-babel-default-inline-header-args - (org-babel-params-from-properties) + (org-babel-params-from-properties lang) (if (boundp lang-headers) (eval lang-headers) nil) (org-babel-parse-header-arguments (org-babel-clean-text-properties (or (match-string 4) ""))))))) --8<---------------cut here---------------end--------------->8--- --8<---------------cut here---------------start------------->8--- commit 55d843bbe63bb32363281c4ad88c2c226928f4c0 Author: Dan Davison Date: Thu May 27 15:18:44 2010 -0400 babel: Define R-specific header arguments diff --git a/contrib/babel/lisp/langs/org-babel-R.el b/contrib/babel/lisp/langs/org-babel-R.el index c1dd67a..6c0a380 100644 --- a/contrib/babel/lisp/langs/org-babel-R.el +++ b/contrib/babel/lisp/langs/org-babel-R.el @@ -35,6 +35,12 @@ (add-to-list 'org-babel-tangle-langs '("R" "R" "#!/usr/bin/env Rscript")) +(defconst org-babel-header-arg-names:R + '(width height bg units pointsize antialias quality compression + res type family title fonts version paper encoding + pagecentre colormodel useDingbats horizontal) + "R-specific header arguments.") + (defun org-babel-expand-body:R (body params &optional processed-params) (let* ((processed-params (or processed-params (org-babel-process-params params))) --8<---------------cut here---------------end--------------->8--- Dan > > Thanks! > Erik > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode