* [babel] buffer-wide settings for R graphical header arguments @ 2010-05-27 18:27 Erik Iverson 2010-05-27 19:32 ` Dan Davison 0 siblings, 1 reply; 4+ messages in thread From: Erik Iverson @ 2010-05-27 18:27 UTC (permalink / raw) To: emacs-orgmode 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? Thanks! Erik ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [babel] buffer-wide settings for R graphical header arguments 2010-05-27 18:27 [babel] buffer-wide settings for R graphical header arguments Erik Iverson @ 2010-05-27 19:32 ` Dan Davison 2010-05-27 20:14 ` Eric Schulte 0 siblings, 1 reply; 4+ messages in thread From: Dan Davison @ 2010-05-27 19:32 UTC (permalink / raw) To: Erik Iverson; +Cc: emacs-orgmode Erik Iverson <eriki@ccbr.umn.edu> 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 <davison@stats.ox.ac.uk> 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 <davison@stats.ox.ac.uk> 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [babel] buffer-wide settings for R graphical header arguments 2010-05-27 19:32 ` Dan Davison @ 2010-05-27 20:14 ` Eric Schulte 2010-05-27 21:13 ` Dan Davison 0 siblings, 1 reply; 4+ messages in thread From: Eric Schulte @ 2010-05-27 20:14 UTC (permalink / raw) 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 <davison@stats.ox.ac.uk> writes: > Erik Iverson <eriki@ccbr.umn.edu> 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 <davison@stats.ox.ac.uk> > 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 <davison@stats.ox.ac.uk> > 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [babel] buffer-wide settings for R graphical header arguments 2010-05-27 20:14 ` Eric Schulte @ 2010-05-27 21:13 ` Dan Davison 0 siblings, 0 replies; 4+ messages in thread From: Dan Davison @ 2010-05-27 21:13 UTC (permalink / raw) To: Eric Schulte; +Cc: emacs-orgmode "Eric Schulte" <schulte.eric@gmail.com> 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 <davison@stats.ox.ac.uk> writes: > >> Erik Iverson <eriki@ccbr.umn.edu> 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 <davison@stats.ox.ac.uk> >> 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 <davison@stats.ox.ac.uk> >> 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-27 21:13 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-05-27 18:27 [babel] buffer-wide settings for R graphical header arguments Erik Iverson 2010-05-27 19:32 ` Dan Davison 2010-05-27 20:14 ` Eric Schulte 2010-05-27 21:13 ` Dan Davison
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).