From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: Creating new org headers from code blocks Date: Fri, 19 Sep 2014 14:15:13 +0200 Message-ID: References: <87zjdval5t.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUx65-0002km-Qp for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 08:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUx60-0003eG-RC for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 08:15:33 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:56910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUx60-0003dn-Ic for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 08:15:28 -0400 Received: by mail-wg0-f48.google.com with SMTP id m15so2329342wgh.7 for ; Fri, 19 Sep 2014 05:15:23 -0700 (PDT) In-Reply-To: <87zjdval5t.fsf@gmail.com> (Thorsten Jolitz's message of "Fri, 19 Sep 2014 13:45:34 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thorsten Jolitz Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Thorsten Jolitz writes: > Rainer M Krug writes: > > Hi, > >> I have some R code which generates several graphics. I would now like to >> generate in R text which is then interpreted by org, upon export, as >> normal org code. Furthermore, I would like to create new org headers from >> the R code. Imagine I have the R code block below. Executed, I get the >> results below: >> >> --8<---------------cut here---------------start------------->8--- >> * Some code block >> #+begin_src R :results raw :wrap :exports both >> c("** New header", "[[./graph1.pdf]]", "", "** and second header", "and = some text" ) >> #+end_src >> >> #+RESULTS: >> #+BEGIN_RESULTS >> ,** New header >> [[./graph1.pdf]] >> >> ,** and second header >> and some text >> #+END_RESULTS >> --8<---------------cut here---------------end--------------->8--- >> >> I can leave the :wrap, but then the results are not overwritten, but >> appended - otherwise it works as expected. >> >> How can I achieve that I get=20 >> >> ,---- >> | ** New header >> | [[./graph1.pdf]] >> |=20 >> | ** and second header >> | and some text >> `---- >> >> in the org file, but also that the result gets overwritten upon repeated >> execution? > > I asked about this ':results raw' limitation before and was told to RTFM > ;) > > (although its not really on the page where I would look for it: > http://orgmode.org/manual/results.html). Thanks for pointing me to RTFM - there I found "drawer" and ,---- | #+begin_src R :results raw drawer=20 | c("*** Mean", "[[file:./netimpacts_mean.pdf]]","", "*** Mode","[[file:./n= etimpacts_mode.pdf]]") | #+end_src `---- results in ,---- | #+RESULTS: | :RESULTS: | *** Mean | [[file:./netimpacts_mean.pdf]] |=20 | *** Mode | [[file:./netimpacts_mode.pdf]] | :END: `---- which is nicely highlighted as headers, exported as headers and replaced. Perfect. I don't quite understand your code below and what it is supposed to do. Thanks, Rainer > > You could look-up that thread in the mailing-list for some tips, and/or > use this on a temporary buffer-copy just before you want to act on the > raw results: > > #+BEGIN_SRC emacs-lisp :results none > (defvar tj/fixed-width-to-raw-langs '("R") > "List of Babel langs for `tj/fixed-width-to-raw-results'.") > > (defun tj/fixed-width-to-raw-results () > "Call `org-toggle-fixed-width' on ':results pp'." > (org-babel-map-src-blocks nil > (and (member lang tj/toggle-fixed-width-src-block-langs) > (member "pp" (split-string header-args " " t)) > (save-excursion > (goto-char (org-babel-where-is-src-block-result)) > (forward-line) > (while (org-in-fixed-width-region-p) > (org-toggle-fixed-width) > (forward-line)))))) > > #+END_SRC > #+begin_src R :results pp replace > c("** New header2", "[[./graph1.pdf]]", "", "** and second header", "and= some text" ) > #+end_src > > #+results: > : ** New header2 > : [[./graph1.pdf]] > :=20 > : ** and second header > : and some text =2D-=20 Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBAgAGBQJUHB5XAAoJENvXNx4PUvmCV2cH/0P90OBdrqpWdLuhjCkyAqrL VTAiN/AVCfrbL3Zd8qj2CnVi7ip6e2MgxR42vftovBOYO6PA7qEkgXxsXDIzNSEF +ytR/tGwCCUHMsLwwivnypSpJm/r4QWYSJOgHuEBQ/7yghxbmdM/c2TG7cjXPSAU cEYYtkanEcJMT+6z6KrOVNoG/rOOUuVUH7+O4ibZiVsMIgH5/TQuDD+WT64xGahq 6cBmjc6+hXzkd1hfgh9b50VDu+dCKDszY0Sq+7PymOK0SHpGsedzOUIU4MjICP70 2V0shWWNYu5bBM9/y9xL9DStY+S9V4/+VD5knw/gzWoZ88rQb9R+w12NZUk3MF8= =No26 -----END PGP SIGNATURE----- --=-=-=--