t...@tsdye.com (Thomas S. Dye) writes: > Hi Eric, > > Eric Schulte <schulte.e...@gmail.com> writes: > >> This actually is also an issue with shell code blocks. The fix is to >> customize the org-babel-inline-result-wrap variable (e.g., as follows) >> instead of setting the result type to RAW. >> >> (setq org-babel-inline-result-wrap "%s") >> >> Perhaps a note about this variable should be added to the description of >> inline code blocks (both call and src_*) in the manual. > > AFAICT, this variable has no effect on export of calls to R source code > blocks, where the source code block is set with :results raw. >
Correct, however I believe the following should give the behavior you're after no?
#+Options: ^:{} First set the inline result wrap. #+begin_src emacs-lisp :results silent (setq org-babel-inline-result-wrap "%s") #+end_src * Desirable newline behavior The call_r1() should not export with a newline. #+name: r1 #+begin_src R 2 #+end_src
> > Also, AFAICT, the behavior of R source code blocks differs from others, > including shell. >
#+Options: ^:{} * Undesirable newline behavior :PROPERTIES: :results: raw :END: Both of these *do* introduce undesirable newlines. A shell code block call_shell2() and an R code block call_R2(). #+name: shell2 #+begin_src sh echo 2 #+end_src #+name: R2 #+begin_src R 2 #+end_src
> > With the default value of org-babel-inline-result-wrap I get this > LaTeX > export: > > \section{Export this subtree raw to \LaTeX{}} > \label{sec-1} > Will shell-2 export 2 with a newline? > > Will r-2 export 2 with a newline? > > Will shell-2-raw export 2 with a newline? > > Will r-2-raw export 2 > with a newline? > \section{Export this subtree without raw to \LaTeX{}} > \label{sec-2} > > Will shell-2 export \texttt{2} with a newline? > > Will r-2 export \texttt{2} with a newline? > > Will shell-2-raw export \texttt{2} with a newline? > > \begin{verbatim} > Will r-2-raw export 2 > \end{verbatim} > with a newline? > % Emacs 24.3.1 (Org mode 8.2.5h) > > With org-babel-inline-result-wrap set to "%s" I get this: > > \section{Export this subtree raw to \LaTeX{}} > \label{sec-1} > Will shell-2 export 2 with a newline? > > Will r-2 export 2 with a newline? > > Will shell-2-raw export 2 with a newline? > > Will r-2-raw export 2 > with a newline? > \section{Export this subtree without raw to \LaTeX{}} > \label{sec-2} > > Will shell-2 export 2 with a newline? > > Will r-2 export 2 with a newline? > > Will shell-2-raw export 2 with a newline? > > \begin{verbatim} > Will r-2-raw export 2 > \end{verbatim} > with a newline? > % Emacs 24.3.1 (Org mode 8.2.5h) > > Note that there is no change in the LaTeX export of the R calls. > > I think this is a bug in ob-R.el. From my experiments, it behaves > differently than the other babel languages, including shell. > > For LaTeX export, the workaround is to avoid :results raw with R source > code blocks. Although a spurious newline is inserted into the source, > this is ignored by LaTeX. > I think it is allowable for raw results to include newlines. After if R returns a newline, the purpose of raw results is specifically to *not* change the result. I believe the best approach is to customize the inline results wrap as above, and then use non-raw processed results when inline results without newlines are desired. Does this sound reasonable? Best, > > All the best, > Tom -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D