From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: [babel] buffer-wide settings for R graphical header arguments Date: Thu, 27 May 2010 14:14:03 -0600 Message-ID: <87aarlayr8.fsf@gmail.com> References: <4BFEB99F.5070202@ccbr.umn.edu> <87y6f5ta2t.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=58715 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHjT4-00040X-Eu for emacs-orgmode@gnu.org; Thu, 27 May 2010 16:14:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHjSz-0000KF-8J for emacs-orgmode@gnu.org; Thu, 27 May 2010 16:14:14 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:65499) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHjSy-0000K8-VR for emacs-orgmode@gnu.org; Thu, 27 May 2010 16:14:09 -0400 Received: by pvc21 with SMTP id 21so355738pvc.0 for ; Thu, 27 May 2010 13:14:07 -0700 (PDT) In-Reply-To: <87y6f5ta2t.fsf@stats.ox.ac.uk> (Dan Davison's message of "Thu, 27 May 2010 15:32:10 -0400") 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: Dan Davison Cc: emacs-orgmode Hi, This sounds like a great idea. I like language specific header arguments, and I like passing the language as an optional argument to `org-babel-params-from-properties'. I downloaded the patch from, http://patchwork.newartisans.com/patch/22/, and tried to apply it to my local git repository, but got the following error --8<---------------cut here---------------start------------->8--- git am ~/Downloads/Orgmode-Re-babel-buffer-wide-settings-for-R-graphical-header-arguments.patch Applying: buffer-wide settings for R graphical header arguments error: patch failed: contrib/babel/lisp/org-babel.el:603 error: contrib/babel/lisp/org-babel.el: patch does not apply --8<---------------cut here---------------end--------------->8--- was that patch against the latest git head? Aside form some minor tweaks to the implementation in `org-babel-params-from-properties' -- I'd want the save-match-data on the outside of the function and I'd want to play around with the nested let statements -- it looks great to me. Best -- Eric Dan Davison writes: > 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. > > 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) ""))))))) > > 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))) > > > 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