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 17:13:37 -0400 Message-ID: <87ljb5t5dq.fsf@stats.ox.ac.uk> References: <4BFEB99F.5070202@ccbr.umn.edu> <87y6f5ta2t.fsf@stats.ox.ac.uk> <87aarlayr8.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=49522 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHkOg-000770-MI for emacs-orgmode@gnu.org; Thu, 27 May 2010 17:13:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHkOc-0000dG-KX for emacs-orgmode@gnu.org; Thu, 27 May 2010 17:13:43 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:55073) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHkOc-0000d8-Al for emacs-orgmode@gnu.org; Thu, 27 May 2010 17:13:42 -0400 In-Reply-To: <87aarlayr8.fsf@gmail.com> (Eric Schulte's message of "Thu, 27 May 2010 14:14:03 -0600") 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: Eric Schulte Cc: emacs-orgmode "Eric Schulte" writes: > 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 My message contained two patches, each delimited by the hideous --8<-----cut here----end-->8--- stuff. It looks like patchwork has not presented that in a way that can be digested by git-am. Perhaps delimiting them both as a single chunk is the way to go. > > 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 > > 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. OK, great. I'll finalise that off line. Dan > > 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 > > _______________________________________________ > 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