From: "Eric Schulte" <schulte.eric@gmail.com>
To: Dan Davison <davison@stats.ox.ac.uk>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [babel] buffer-wide settings for R graphical header arguments
Date: Thu, 27 May 2010 14:14:03 -0600 [thread overview]
Message-ID: <87aarlayr8.fsf@gmail.com> (raw)
In-Reply-To: <87y6f5ta2t.fsf@stats.ox.ac.uk> (Dan Davison's message of "Thu, 27 May 2010 15:32:10 -0400")
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
next prev parent reply other threads:[~2010-05-27 20:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2010-05-27 21:13 ` Dan Davison
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87aarlayr8.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=davison@stats.ox.ac.uk \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).