0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-12 07:39:58 +00:00

Merging master into results.

This commit is contained in:
Dan Davison 2009-07-18 13:01:16 -04:00
commit ccc461ef54
4 changed files with 116 additions and 74 deletions

View file

@ -45,7 +45,7 @@
(add-to-list 'org-babel-tangle-langs '("ditaa" "ditaa"))
(defvar org-babel-default-header-args:ditaa '((:results . "file"))
(defvar org-babel-default-header-args:ditaa '((:results . "file") (:exports . "results"))
"Default arguments to use when evaluating a ditaa source block.")
(defun org-babel-execute:ditaa (body params)

View file

@ -41,7 +41,7 @@
(add-to-list 'org-babel-tangle-langs '("gnuplot" "gnuplot"))
(defvar org-babel-default-header-args:gnuplot '((:results . "file"))
(defvar org-babel-default-header-args:gnuplot '((:results . "file") (:exports . "results"))
"Default arguments to use when evaluating a gnuplot source block.")
(defvar org-babel-gnuplot-timestamp-fmt nil)

View file

@ -52,7 +52,7 @@ then run `org-babel-pop-to-session'."
(defvar org-babel-default-header-args '((:session . "none") (:results . "replace"))
"Default arguments to use when evaluating a source block.")
(defvar org-babel-default-inline-header-args '((:results . "silent") (:exports . "results"))
(defvar org-babel-default-inline-header-args '((:results . "silent") (:exports . "code"))
"Default arguments to use when evaluating an inline source block.")
(defvar org-babel-src-block-regexp nil
@ -189,56 +189,6 @@ concerned with creating elisp versions of results. "
(if (and (member "vector" result-params) (not (listp result)))
(list (list result))
result))
;; ;; ruby
;; (if (member "scalar" result-params)
;; results
;; (case result-type ;; process results based on the result-type
;; ('output (let ((tmp-file (make-temp-file "org-babel-ruby")))
;; (with-temp-file tmp-file (insert results))
;; (org-babel-import-elisp-from-file tmp-file)))
;; ('value (org-babel-ruby-table-or-results results))))))
;; python
;; (if (member "scalar" result-params)
;; results
;; (setq result (case result-type ;; process results based on the result-type
;; ('output (let ((tmp-file (make-temp-file "org-babel-python")))
;; (with-temp-file tmp-file (insert results))
;; (org-babel-import-elisp-from-file tmp-file)))
;; ('value (org-babel-python-table-or-results results))))
;; (if (and (member "vector" results) (not (listp results)))
;; (list (list results))
;; results))))
;; ;; sh
;; (if (member "scalar" result-params)
;; results
;; (setq results (let ((tmp-file (make-temp-file "org-babel-shell")))
;; (with-temp-file tmp-file (insert results))
;; (org-babel-import-elisp-from-file tmp-file)))
;; (if (and (member "vector" results) (not (listp results)))
;; (list (list results))
;; results))))
;; ;; R
;; (setq results (if (member "scalar" result-params)
;; results
;; (let ((tmp-file (make-temp-file "org-babel-R")))
;; (with-temp-file tmp-file (insert results))
;; (org-babel-import-elisp-from-file tmp-file))))
;; (if (and (member "vector" result-params) (not (listp results)))
;; (list (list results))
;; results))))
;; ;; rest of org-babel-execute-src-block
;; ;; possibly force result into a vector
;; (if (and (not (listp result)) (cdr (assoc :results params))
;; (member "vector" (split-string (cdr (assoc :results params)))))
;; (setq result (list result)))
;; result))
(defun org-babel-execute-buffer (&optional arg)
"Replace EVAL snippets in the entire buffer."
@ -321,7 +271,7 @@ of the following form. (language body header-arguments-alist)"
(lang-headers (intern (concat "org-babel-default-header-args:" lang))))
(list lang
(org-babel-strip-protective-commas (org-babel-clean-text-properties (match-string 4)))
(org-combine-plists
(org-babel-merge-params
org-babel-default-inline-header-args
(if (boundp lang-headers) (eval lang-headers) nil)
(org-babel-parse-header-arguments (org-babel-clean-text-properties (or (match-string 3) "")))))))
@ -436,9 +386,9 @@ current source block. With optional argument INSERT controls
insertion of results in the org-mode file. INSERT can take the
following values...
t ------ the default options, simply insert the results after the
t ------ the default option, simply insert the results after the
source block
replace - insert results after the source block replacing any
previously inserted results
@ -539,7 +489,7 @@ parameters when merging lists."
vars (cons (cons var ref) (assq-delete-all var vars)))))
(:results
;; maintain list of unique :results specifications
(setq results (org-uniquify (append (split-string (cdr pair)) results))))
(setq results (org-babel-merge-results results (split-string (cdr pair)))))
(t
;; replace: this covers e.g. :session
(setq params (cons pair (assq-delete-all (car pair) params))))))
@ -549,6 +499,26 @@ parameters when merging lists."
(while vars (setq params (cons (cons :var (pop vars)) params)))
(cons (cons :results (mapconcat 'identity results " ")) params)))
(defun org-babel-merge-results (&rest result-params)
"Combine all result parameter lists in RESULT-PARAMS taking
into account the fact that some groups of result params are
mutually exclusive."
(let ((exclusive-groups '(("file" "vector" "scalar")
("replace" "silent")))
output)
(mapc (lambda (new-params)
(mapc (lambda (new-param)
(mapc (lambda (exclusive-group)
(when (member new-param exclusive-group)
(mapcar (lambda (excluded-param)
(setq output (delete excluded-param output)))
exclusive-group)))
exclusive-groups)
(setq output (org-uniquify (cons new-param output))))
new-params))
result-params)
output))
(defun org-babel-clean-text-properties (text)
"Strip all properties from text return."
(set-text-properties 0 (length text) nil text) text)

View file

@ -205,7 +205,7 @@ would then be [[#sandbox][the sandbox]].
but should larger amounts of output be in a
\#+begin_example...\#+end_example block? What's the cutoff? > 1 line?
** TODO make tangle files read-only?
With a file-local variable setting?
With a file-local variable setting?
** TODO take default values for header args from properties
Use file-wide and subtree wide properties to set default values for
header args.
@ -2027,15 +2027,89 @@ This is currently working only with emacs lisp as in the following
example in the [[* emacs lisp source reference][emacs lisp source reference]].
* Bugs [18/23]
** TODO Add languages [1/6]
I'm sure there are many more that aren't listed here. Please add
them, and bubble any that you particularly care about up to the top.
Any new language should be implemented in a org-babel-lang.el file.
Follow the pattern set by [[file:lisp/org-babel-script.el][org-babel-script.el]], [[file:lisp/org-babel-shell.el][org-babel-shell.el]] and
[[file:lisp/org-babel-R.el][org-babel-R.el]].
*** TODO perl
This could probably be added to [[file:lisp/org-babel-script.el][org-babel-script.el]]
*** TODO java
*** DONE ditaa
(see [[* file result types][file result types]])
#+srcname: implementing-ditaa
#+begin_src ditaa :results replace :file blue.png :cmdline -r
+---------+
| cBLU |
| |
| +----+
| |cPNK|
| | |
+----+----+
#+end_src
#+resname:
[[file:blue.png][blue.png]]
*** STARTED gnuplot
(see [[* file result types][file result types]])
- a =file= header argument
- a =cmdline= header argument
- to add variables
- scalar variables should be replaced in the body of the gnuplot code
- vector variables should be exported to tab-separated files, and
the variable names should be replaced with the path to the files
#+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
#+TBLNAME: gnuplot-data
| independent var | first dependent var | second dependent var |
|-----------------+---------------------+----------------------|
| 0.1 | 0.425 | 0.375 |
| 0.2 | 0.3125 | 0.3375 |
| 0.3 | 0.24999993 | 0.28333338 |
| 0.4 | 0.275 | 0.28125 |
| 0.5 | 0.26 | 0.27 |
| 0.6 | 0.25833338 | 0.24999993 |
| 0.7 | 0.24642845 | 0.23928553 |
| 0.8 | 0.23125 | 0.2375 |
| 0.9 | 0.23333323 | 0.2333332 |
| 1 | 0.2225 | 0.22 |
| 1.1 | 0.20909075 | 0.22272708 |
| 1.2 | 0.19999998 | 0.21458333 |
| 1.3 | 0.19615368 | 0.21730748 |
#+srcname: implementing-gnuplot
#+begin_src gnuplot :var data=gnuplot-data
set title "Implementing Gnuplot"
plot "data" using 1:2 with lines
#+end_src
*** TODO dot
(see [[* file result types][file result types]])
*** TODO asymptote
(see [[* file result types][file result types]])
* Bugs [19/30]
** TODO o-b-execute-subtree overwrites some buffer contents
*** Try M-x org-babel-execute-subtree with point at the beginning of this line
#+begin_src sh
b=2
#+end_src
** TODO Allow source blocks to be recognised when #+ are not first characters on the line
I think Carsten has recently altered the core so that #+ can have
preceding whitespace, at least for literal/code examples. org-babel
should support this.
** TODO fold source blocks on #+srcname line?
I.e., as well as on #+begin_src line.
** TODO non-orgtbl formatted lists
for example
@ -2090,21 +2164,20 @@ the same for the other languages. [Dan]
** TODO are the org-babel-trim s necessary?
at the end of e.g. org-babel-R-evaluate, org-babel-python-evaluate, but
not org-babel-ruby-evaluate
** results branch bugs
*** TODO elisp reference fails for literal number
** TODO elisp reference fails for literal number
#+srcname: elisp-test(a=4)
#+begin_src emacs-lisp
(message a)
#+end_src
*** TODO use new merge function [[file:lisp/org-babel-ref.el::t%20nil%20org%20combine%20plists%20args%20nil][here]] and [[file:lisp/org-babel.el::params%20org%20combine%20plists%20params%20third%20info][here]]?
And at other occurrences of org-combine-plists?
*** TODO LoB: with output to buffer, not working in buffers other than library-of-babel.org
I haven't fixed this yet. org-babel-ref-resolve-reference moves
point around, inside a save-excursion. Somehow when it comes to
inserting the results (after possible further recursive calls to
org-babel-ref-resolve-reference), point hasn't gone back to the
lob line.
*** TODO LoB: output to buffer adds creeping blank lines
** TODO use new merge function [[file:lisp/org-babel-ref.el::t%20nil%20org%20combine%20plists%20args%20nil][here]]?
And at other occurrences of org-combine-plists?
** TODO LoB: with output to buffer, not working in buffers other than library-of-babel.org
I haven't fixed this yet. org-babel-ref-resolve-reference moves
point around, inside a save-excursion. Somehow when it comes to
inserting the results (after possible further recursive calls to
org-babel-ref-resolve-reference), point hasn't gone back to the
lob line.
** TODO LoB: output to buffer adds creeping blank lines
Compare the results of
#+lob: python-add(a=5, b=17)
@ -2456,7 +2529,6 @@ As an example eval the following. Adding a line to test
ar.first.first
#+end_src
** DONE space trailing language name
fix regexp so it works when there's a space trailing the language name