mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-26 15:02:52 +00:00
merge Eric's notes and mine
This commit is contained in:
commit
f173099443
90
existing_tools/exp-blocks/example-for-r.html
Normal file
90
existing_tools/exp-blocks/example-for-r.html
Normal file
|
@ -0,0 +1,90 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>a <- 3</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
|
||||
<meta name="generator" content="Org-mode"/>
|
||||
<meta name="generated" content="2009-02-05 15:26:32 PST"/>
|
||||
<meta name="author" content="Eric Schulte"/>
|
||||
<style type="text/css">
|
||||
<!--/*--><![CDATA[/*><!--*/
|
||||
html { font-family: Times, serif; font-size: 12pt; }
|
||||
.title { text-align: center; }
|
||||
.todo { color: red; }
|
||||
.done { color: green; }
|
||||
.tag { background-color:lightblue; font-weight:normal }
|
||||
.target { }
|
||||
.timestamp { color: grey }
|
||||
.timestamp-kwd { color: CadetBlue }
|
||||
p.verse { margin-left: 3% }
|
||||
pre {
|
||||
border: 1pt solid #AEBDCC;
|
||||
background-color: #F3F5F7;
|
||||
padding: 5pt;
|
||||
font-family: courier, monospace;
|
||||
font-size: 90%;
|
||||
overflow:auto;
|
||||
}
|
||||
table { border-collapse: collapse; }
|
||||
td, th { vertical-align: top; }
|
||||
dt { font-weight: bold; }
|
||||
div.figure { padding: 0.5em; }
|
||||
div.figure p { text-align: center; }
|
||||
.linenr { font-size:smaller }
|
||||
.code-highlighted {background-color:#ffff00;}
|
||||
.org-info-js_info-navigation { border-style:none; }
|
||||
#org-info-js_console-label { font-size:10px; font-weight:bold;
|
||||
white-space:nowrap; }
|
||||
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
|
||||
font-weight:bold; }
|
||||
/*]]>*/-->
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
<!--/*--><![CDATA[/*><!--*/
|
||||
function CodeHighlightOn(elem, id)
|
||||
{
|
||||
var target = document.getElementById(id);
|
||||
if(null != target) {
|
||||
elem.cacheClassElem = elem.className;
|
||||
elem.cacheClassTarget = target.className;
|
||||
target.className = "code-highlighted";
|
||||
elem.className = "code-highlighted";
|
||||
}
|
||||
}
|
||||
function CodeHighlightOff(elem, id)
|
||||
{
|
||||
var target = document.getElementById(id);
|
||||
if(elem.cacheClassElem)
|
||||
elem.className = elem.cacheClassElem;
|
||||
if(elem.cacheClassTarget)
|
||||
target.className = elem.cacheClassTarget;
|
||||
}
|
||||
/*]]>*/-->
|
||||
</script>
|
||||
</head><body>
|
||||
<h1 class="title">a <- 3</h1>
|
||||
|
||||
|
||||
<div id="R-1">
|
||||
<pre>
|
||||
> a
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
the value of a is 3
|
||||
</li>
|
||||
<li>
|
||||
the value of a + 3 is 6
|
||||
</li>
|
||||
</ul>
|
||||
<div id="postamble"><p class="author"> Author: Eric Schulte
|
||||
<a href="mailto:schulte.eric@gmail.com"><schulte.eric@gmail.com></a>
|
||||
</p>
|
||||
<p class="date"> Date: 2009-02-05 15:26:32 PST</p>
|
||||
<p>HTML generated by org-mode 6.20f in emacs 23</p>
|
||||
</div></body>
|
||||
</html>
|
12
existing_tools/exp-blocks/example-for-r.org
Normal file
12
existing_tools/exp-blocks/example-for-r.org
Normal file
|
@ -0,0 +1,12 @@
|
|||
#+BEGIN_R
|
||||
a <- 3
|
||||
a
|
||||
#+END_R
|
||||
|
||||
- the value of a is \R{a}
|
||||
- the value of a + 3 is \R{a + 3}
|
||||
|
||||
#+BEGIN_R hidden_block, echo=FALSE, results=HIDE
|
||||
a <- 3
|
||||
b <- 6
|
||||
#+END_R
|
|
@ -80,8 +80,10 @@ Each block export function should accept three argumets..."
|
|||
:type 'alist)
|
||||
|
||||
(defcustom org-export-interblocks
|
||||
'((r org-export-interblocks-format-R)
|
||||
(R org-export-interblocks-format-R))
|
||||
'(
|
||||
(r org-export-interblocks-format-R)
|
||||
(R org-export-interblocks-format-R)
|
||||
)
|
||||
"Use this a-list to associate block types with block exporting
|
||||
functions. The type of a block is determined by the text
|
||||
immediately following the '#+BEGIN_' portion of the block header.
|
||||
|
@ -316,8 +318,9 @@ export."
|
|||
(goto-char start)
|
||||
(interblock-initiate-R-buffer)
|
||||
(let (code replacement)
|
||||
(while (and (< (point) end) (re-search-forward "\\\\R{\\(.*\\)}" end t))
|
||||
(while (and (< (point) end) (re-search-forward "\\\\R{\\([^}]*\\)}" end t))
|
||||
(save-match-data (setf code (match-string 1)))
|
||||
(message (format "\R{%s}" code))
|
||||
(setf replacement (interblock-R-command-to-string code))
|
||||
(setf replacement (cond
|
||||
(htmlp replacement)
|
9
existing_tools/exp-blocks/running.el
Normal file
9
existing_tools/exp-blocks/running.el
Normal file
|
@ -0,0 +1,9 @@
|
|||
(load "org-exp-blocks.el")
|
||||
|
||||
(defun org-exp-preprocess ()
|
||||
"This is a simple helper to preprocess a file without actually
|
||||
exporting to html or latex. Useful for debugging."
|
||||
(interactive)
|
||||
(let ((htmlp t))
|
||||
(org-export-blocks-preprocess)))
|
||||
|
73
existing_tools/exp-blocks/testing.Rorg
Normal file
73
existing_tools/exp-blocks/testing.Rorg
Normal file
|
@ -0,0 +1,73 @@
|
|||
# -*- mode: org -*-
|
||||
#+OPTIONS: LaTeX:t
|
||||
|
||||
* Sweave and org-mode
|
||||
If you're reading a PDF version of this document, you should also
|
||||
look at [[file:testing.Rorg][testing.Rorg]] (the source file) and [[file:testing.org][testing.org]] (the output
|
||||
of the Sweave process).
|
||||
|
||||
Keep in mind that one of the advantages of a block-based approach is
|
||||
using \texttt{C-'} to edit code in its native mode.
|
||||
|
||||
** Use the Sweave package for latex formatting
|
||||
Org allows us to issue commands to be included in \{LaTeX} export.
|
||||
#+LATEX_HEADER \usepackage{Sweave}
|
||||
|
||||
** R blocks
|
||||
The first argument to an R block when using Sweave is the label for
|
||||
that block.
|
||||
|
||||
Not all R blocks are printed. Sweave options allow the printing of
|
||||
the evaluated code, the output of the code, both, or neither.
|
||||
|
||||
*** R code that is not printed
|
||||
#+BEGIN_R hidden_block, echo=FALSE, results=HIDE
|
||||
a <- 3
|
||||
b <- 6
|
||||
#+END_R
|
||||
|
||||
*** R code that is printed
|
||||
#+BEGIN_R visible_block
|
||||
c <- 4
|
||||
#+END_R
|
||||
|
||||
We can use block labels to embed blocks by reference (even if they
|
||||
weren't printed before).
|
||||
*** R code that references other blocks
|
||||
#+BEGIN_R combined_block
|
||||
#+R_CODEREF: hidden_block
|
||||
#+R_CODEREF: visible_block
|
||||
a + b +c
|
||||
#+END_R
|
||||
|
||||
** Inline references to R data
|
||||
We can evaluate R code inline.
|
||||
*** Used in text
|
||||
The value of =a= is 3.
|
||||
|
||||
*** Used in a table
|
||||
| a | b | c | TOTAL |
|
||||
|-------+-------+-------+---------------|
|
||||
| \R{a} | \R{b} | \R{c} | \R{a + b + c} |
|
||||
|
||||
** Single-line R commands
|
||||
If we want a line of R code to be evaluated but not printed,
|
||||
there's a convenient shorthand. This only works for single lines
|
||||
of R code, but you can have more than one in a row.
|
||||
#+R library(lattice)
|
||||
#+R data(cars)
|
||||
|
||||
** Graphics
|
||||
We use values defined elsewhere in the buffer to produce this
|
||||
graph. The new CAPTION and LABEL arguments work just fine.
|
||||
|
||||
#+CAPTION: speed by distance
|
||||
#+LABEL: fig:speed_by_distance
|
||||
#+BEGIN_R figure.eps
|
||||
print(xyplot(speed ~ dist, cars,
|
||||
panel = function (x, y, ...) {
|
||||
panel.xyplot(x, y, ...)
|
||||
panel.abline(h=a)
|
||||
panel.abline(v=b)
|
||||
}))
|
||||
#+END_R
|
276
existing_tools/exp-blocks/testing.html
Normal file
276
existing_tools/exp-blocks/testing.html
Normal file
|
@ -0,0 +1,276 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>testing</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
|
||||
<meta name="generator" content="Org-mode"/>
|
||||
<meta name="generated" content="2009-02-05 15:41:29 PST"/>
|
||||
<meta name="author" content="Eric Schulte"/>
|
||||
<style type="text/css">
|
||||
<!--/*--><![CDATA[/*><!--*/
|
||||
html { font-family: Times, serif; font-size: 12pt; }
|
||||
.title { text-align: center; }
|
||||
.todo { color: red; }
|
||||
.done { color: green; }
|
||||
.tag { background-color:lightblue; font-weight:normal }
|
||||
.target { }
|
||||
.timestamp { color: grey }
|
||||
.timestamp-kwd { color: CadetBlue }
|
||||
p.verse { margin-left: 3% }
|
||||
pre {
|
||||
border: 1pt solid #AEBDCC;
|
||||
background-color: #F3F5F7;
|
||||
padding: 5pt;
|
||||
font-family: courier, monospace;
|
||||
font-size: 90%;
|
||||
overflow:auto;
|
||||
}
|
||||
table { border-collapse: collapse; }
|
||||
td, th { vertical-align: top; }
|
||||
dt { font-weight: bold; }
|
||||
div.figure { padding: 0.5em; }
|
||||
div.figure p { text-align: center; }
|
||||
.linenr { font-size:smaller }
|
||||
.code-highlighted {background-color:#ffff00;}
|
||||
.org-info-js_info-navigation { border-style:none; }
|
||||
#org-info-js_console-label { font-size:10px; font-weight:bold;
|
||||
white-space:nowrap; }
|
||||
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
|
||||
font-weight:bold; }
|
||||
/*]]>*/-->
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
<!--/*--><![CDATA[/*><!--*/
|
||||
function CodeHighlightOn(elem, id)
|
||||
{
|
||||
var target = document.getElementById(id);
|
||||
if(null != target) {
|
||||
elem.cacheClassElem = elem.className;
|
||||
elem.cacheClassTarget = target.className;
|
||||
target.className = "code-highlighted";
|
||||
elem.className = "code-highlighted";
|
||||
}
|
||||
}
|
||||
function CodeHighlightOff(elem, id)
|
||||
{
|
||||
var target = document.getElementById(id);
|
||||
if(elem.cacheClassElem)
|
||||
elem.className = elem.cacheClassElem;
|
||||
if(elem.cacheClassTarget)
|
||||
target.className = elem.cacheClassTarget;
|
||||
}
|
||||
/*]]>*/-->
|
||||
</script>
|
||||
</head><body>
|
||||
<h1 class="title">testing</h1>
|
||||
|
||||
|
||||
<div id="table-of-contents">
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#sec-1">1 Sweave and org-mode </a>
|
||||
<ul>
|
||||
<li><a href="#sec-1.1">1.1 Use the Sweave package for latex formatting </a></li>
|
||||
<li><a href="#sec-1.2">1.2 R blocks </a>
|
||||
<ul>
|
||||
<li><a href="#sec-1.2.1">1.2.1 R code that is not printed </a></li>
|
||||
<li><a href="#sec-1.2.2">1.2.2 R code that is printed </a></li>
|
||||
<li><a href="#sec-1.2.3">1.2.3 R code that references other blocks </a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#sec-1.3">1.3 Inline references to R data </a>
|
||||
<ul>
|
||||
<li><a href="#sec-1.3.1">1.3.1 Used in text </a></li>
|
||||
<li><a href="#sec-1.3.2">1.3.2 Used in a table </a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#sec-1.4">1.4 Single-line R commands </a></li>
|
||||
<li><a href="#sec-1.5">1.5 Graphics </a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1" class="outline-2">
|
||||
<h2 id="sec-1">1 Sweave and org-mode </h2>
|
||||
<div id="text-1">
|
||||
|
||||
<p>If you're reading a PDF version of this document, you should also
|
||||
look at <a href="testing.Rorg">testing.Rorg</a> (the source file) and <a href="testing.html">testing.org</a> (the output
|
||||
of the Sweave process).
|
||||
</p>
|
||||
<p>
|
||||
Keep in mind that one of the advantages of a block-based approach is
|
||||
using \texttt{C-'} to edit code in its native mode.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.1" class="outline-3">
|
||||
<h3 id="sec-1.1">1.1 Use the Sweave package for latex formatting </h3>
|
||||
<div id="text-1.1">
|
||||
|
||||
<p>Org allows us to issue commands to be included in \{LaTeX} export.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.2" class="outline-3">
|
||||
<h3 id="sec-1.2">1.2 R blocks </h3>
|
||||
<div id="text-1.2">
|
||||
|
||||
<p>The first argument to an R block when using Sweave is the label for
|
||||
that block.
|
||||
</p>
|
||||
<p>
|
||||
Not all R blocks are printed. Sweave options allow the printing of
|
||||
the evaluated code, the output of the code, both, or neither.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.2.1" class="outline-4">
|
||||
<h4 id="sec-1.2.1">1.2.1 R code that is not printed </h4>
|
||||
<div id="text-1.2.1">
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="R-1">
|
||||
<pre>
|
||||
> a <- 3
|
||||
> b <- 6
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.2.2" class="outline-4">
|
||||
<h4 id="sec-1.2.2">1.2.2 R code that is printed </h4>
|
||||
<div id="text-1.2.2">
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="R-2">
|
||||
<pre>
|
||||
> c <- 4
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
We can use block labels to embed blocks by reference (even if they
|
||||
weren't printed before).
|
||||
</p></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.2.3" class="outline-4">
|
||||
<h4 id="sec-1.2.3">1.2.3 R code that references other blocks </h4>
|
||||
<div id="text-1.2.3">
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="R-3">
|
||||
<pre>
|
||||
> #+R_CODEREF: hidden_block
|
||||
> #+R_CODEREF: visible_block
|
||||
> a + b +c
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.3" class="outline-3">
|
||||
<h3 id="sec-1.3">1.3 Inline references to R data </h3>
|
||||
<div id="text-1.3">
|
||||
|
||||
<p>We can evaluate R code inline.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.3.1" class="outline-4">
|
||||
<h4 id="sec-1.3.1">1.3.1 Used in text </h4>
|
||||
<div id="text-1.3.1">
|
||||
|
||||
<p>The value of <code>a</code> is 3.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.3.2" class="outline-4">
|
||||
<h4 id="sec-1.3.2">1.3.2 Used in a table </h4>
|
||||
<div id="text-1.3.2">
|
||||
|
||||
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
|
||||
<col align="left"></col><col align="left"></col><col align="left"></col><col align="left"></col>
|
||||
<thead>
|
||||
<tr><th>a</th><th>b</th><th>c</th><th>TOTAL</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>3</td><td>6</td><td>4</td><td>13</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.4" class="outline-3">
|
||||
<h3 id="sec-1.4">1.4 Single-line R commands </h3>
|
||||
<div id="text-1.4">
|
||||
|
||||
<p>If we want a line of R code to be evaluated but not printed,
|
||||
there's a convenient shorthand. This only works for single lines
|
||||
of R code, but you can have more than one in a row.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-1.5" class="outline-3">
|
||||
<h3 id="sec-1.5">1.5 Graphics </h3>
|
||||
<div id="text-1.5">
|
||||
|
||||
<p>We use values defined elsewhere in the buffer to produce this
|
||||
graph. The new CAPTION and LABEL arguments work just fine.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<div id="R-4">
|
||||
<pre>
|
||||
> print(xyplot(speed ~ dist, cars,
|
||||
> panel = function (x, y, ...) {
|
||||
> panel.xyplot(x, y, ...)
|
||||
> panel.abline(h=a)
|
||||
> panel.abline(v=b)
|
||||
> }))
|
||||
</pre>
|
||||
</div>
|
||||
<p>
|
||||
<a href="e.eps">file:e.eps</a>
|
||||
</p></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="postamble"><p class="author"> Author: Eric Schulte
|
||||
<a href="mailto:schulte.eric@gmail.com"><schulte.eric@gmail.com></a>
|
||||
</p>
|
||||
<p class="date"> Date: 2009-02-05 15:41:29 PST</p>
|
||||
<p>HTML generated by org-mode 6.20f in emacs 23</p>
|
||||
</div></body>
|
||||
</html>
|
25
rorg.org
25
rorg.org
|
@ -58,7 +58,30 @@ a
|
|||
** evaluate R code and make the output available for processing in an org buffer
|
||||
** evaluate R code and format the output for export
|
||||
|
||||
Special editing and evaluation of source code in R blocks.
|
||||
Unfortunately org-mode how two different block types. Source code
|
||||
blocks which look like the following allow for the special editing of
|
||||
code inside of the block through `org-edit-special'.
|
||||
|
||||
#+begin_src R
|
||||
|
||||
#+end_src
|
||||
|
||||
dblocks, which look like the following allow for evaluation of the
|
||||
code inside of the block by calling =\C-c\C-c= on the header of the
|
||||
block. This is handy, as org-mode will automatically call
|
||||
`org-dblock-write:dblock-type' where dblock-type is the string
|
||||
following the =#+BEGIN:= portion of the line.
|
||||
|
||||
#+BEGIN: dblock-type
|
||||
#+END:
|
||||
|
||||
Note that upper and lower case are not relevant in block headings.
|
||||
|
||||
I'm leaning towards using the =#+begin_src= blocks, as that is really
|
||||
what these blocks contain is source code.
|
||||
|
||||
* tasks
|
||||
|
||||
|
||||
* buffer dictionary
|
||||
LocalWords: DBlocks dblocks
|
||||
|
|
Loading…
Reference in a new issue