[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] Re: [Babel] Need for an extra literal block construct
From: |
Eric Schulte |
Subject: |
Re: [Orgmode] Re: [Babel] Need for an extra literal block construct |
Date: |
Mon, 22 Nov 2010 17:42:45 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Hi Seb,
Sébastien Vauban <address@hidden> writes:
[...]
>
> Tested it (yesterday) for HTML. Per-fect! Thanks a lot... It's of great use.
>
great, thanks for testing
>
> Tried to test it (now) for LaTeX. Can't, for the same reason as
> described in:
>
> [[http://mid.gmane.org/80eiadw0dh.fsf%40missioncriticalit.com][Email from
> Sébastien Vauban: Debugger entered--Lisp error: ]]** TODO Debugger
> entered--Lisp error: (void-function -mode)
> [2010-11-22 Mon 21:48]
>
After looking at this message I don't understand what the error is, are
you getting a "void-function -mode" error when exporting to LaTeX? The
following exports fine to LaTeX for me w/o error.
** introducing =wrap= header argument
#+begin_src emacs-lisp :results wrap :exports both
(mapcar (lambda (el) (list el (+ 1 (* el el)))) (number-sequence 0 10))
#+end_src
#+results:
#+BEGIN_RESULT
| 0 | 1 |
| 1 | 2 |
| 2 | 5 |
| 3 | 10 |
| 4 | 17 |
| 5 | 26 |
| 6 | 37 |
| 7 | 50 |
| 8 | 65 |
| 9 | 82 |
| 10 | 101 |
#+END_RESULT
now indented
- first
- second
#+begin_src emacs-lisp :results wrap :exports both
"something else"
#+end_src
#+results:
#+BEGIN_RESULT
: something else
#+END_RESULT
>
> Though, already a couple of comments:
>
> 1. I guess there is one little typo in your patch:
> + (wrap "#+BEGIN_LaTe\n" "#+END_LaTeX"))
> ^
>
Fixed version attached, Thanks
>
> 2. Could you make the wrap on by default?
>
No, but you can by adding (:results . "wrap") to
`org-babel-default-header-args' in your personal configuration.
Although I guess if this is turned on by default then there should be a
way to turn it off, either a "nowrap" header argument or a "plain"
header argument or something that would be on by default.
So do you think this could be applied to the core? If not what changes
would you recommend?
Thanks -- Eric
>
> Best regards,
> Seb
>From e2589d43280164dbcb2e1d3b18ef6bf23ac99b6b Mon Sep 17 00:00:00 2001
From: Eric Schulte <address@hidden>
Date: Fri, 19 Nov 2010 16:04:59 -0700
Subject: [PATCH] "wrap" :results header argument wraps code block results
* lisp/ob.el (org-babel-insert-result): Responds to new "wrap" header
argument.
(org-babel-merge-params): Includes new "wrap" header argument in
one of the results header argument exclusive groups.
---
lisp/ob.el | 72 +++++++++++++++++++++++++++++------------------------------
1 files changed, 35 insertions(+), 37 deletions(-)
diff --git a/lisp/ob.el b/lisp/ob.el
index 3689619..9feb0a6 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -1433,11 +1433,11 @@ code ---- the results are extracted in the syntax of
the source
(delete-region (point) (org-babel-result-end)))
((member "append" result-params)
(goto-char (org-babel-result-end)) (setq beg (point)))
- ((member "prepend" result-params) ;; already there
- )))
+ ((member "prepend" result-params)))) ; already there
(setq results-switches
(if results-switches (concat " " results-switches) ""))
- (cond
+ ;; insert results based on type
+ (cond
;; do nothing for an empty result
((= (length result) 0))
;; insert a list if preferred
@@ -1449,6 +1449,7 @@ code ---- the results are extracted in the syntax of the
source
'(:splicep nil :istart "- " :iend "\n")))))
;; assume the result is a table if it's not a string
((not (stringp result))
+ (goto-char beg)
(insert (concat (orgtbl-to-orgtbl
(if (or (eq 'hline (car result))
(and (listp (car result))
@@ -1458,24 +1459,30 @@ code ---- the results are extracted in the syntax of
the source
(goto-char beg) (when (org-at-table-p) (org-table-align)))
((member "file" result-params)
(insert result))
- ((member "html" result-params)
- (insert (format "#+BEGIN_HTML%s\n%s#+END_HTML\n"
- results-switches result)))
- ((member "latex" result-params)
- (insert (format "#+BEGIN_LaTeX%s\n%s#+END_LaTeX\n"
- results-switches result)))
- ((member "code" result-params)
- (insert (format "#+BEGIN_SRC %s%s\n%s#+END_SRC\n"
- (or lang "none") results-switches result)))
- ((member "org" result-params)
- (insert (format "#+BEGIN_SRC org\n%s#+END_SRC\n" result)))
- ((member "raw" result-params)
- (save-excursion (insert result)) (if (org-at-table-p) (org-cycle)))
- (t
- (org-babel-examplize-region
- (point) (progn (insert result) (point)) results-switches)))
- ;; possibly indent the results to match the #+results line
+ (t (goto-char beg)
+ (org-babel-examplize-region
+ (point) (progn (insert result) (point)) results-switches)))
(setq end (if (listp result) (org-table-end) (point)))
+ ;; possibly wrap result
+ (flet ((wrap (start finish)
+ (goto-char beg) (insert start)
+ (goto-char (+ (if (listp result) 0 (length start)) end))
+ (insert finish) (setq end (point))))
+ (cond
+ ((member "html" result-params)
+ (wrap "#+BEGIN_HTML\n" "#+END_HTML"))
+ ((member "latex" result-params)
+ (wrap "#+BEGIN_LaTeX\n" "#+END_LaTeX"))
+ ((member "code" result-params)
+ (wrap (format "#+BEGIN_SRC %s%s\n" (or lang "none")
results-switches)
+ "#+END_SRC"))
+ ((member "org" result-params)
+ (wrap "#+BEGIN_ORG\n" "#+END_ORG"))
+ ((member "raw" result-params)
+ (goto-char beg) (if (org-at-table-p) (org-cycle)))
+ ((member "wrap" result-params)
+ (wrap "#+BEGIN_RESULT\n" "#+END_RESULT"))))
+ ;; possibly indent the results to match the #+results line
(when (and indent (> indent 0)
;; in this case `table-align' does the work for us
(not (and (listp result)
@@ -1503,22 +1510,13 @@ code ---- the results are extracted in the syntax of
the source
((org-at-table-p) (progn (goto-char (org-table-end)) (point)))
((org-in-item-p) (- (org-list-bottom-point) 1))
(t
- (let ((case-fold-search t))
- (cond
- ((looking-at "[ \t]*#\\+begin_latex")
- (re-search-forward "[ \t]*#\\+end_latex" nil t)
- (forward-line 1))
- ((looking-at "[ \t]*#\\+begin_html")
- (re-search-forward "[ \t]*#\\+end_html" nil t)
- (forward-line 1))
- ((looking-at "[ \t]*#\\+begin_example")
- (re-search-forward "[ \t]*#\\+end_example" nil t)
- (forward-line 1))
- ((looking-at "[ \t]*#\\+begin_src")
- (re-search-forward "[ \t]*#\\+end_src" nil t)
- (forward-line 1))
- (t (progn (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
- (forward-line 1))))))
+ (let ((case-fold-search t)
+ (blocks-re (regexp-opt
+ (list "latex" "html" "example" "src" "result"))))
+ (if (looking-at (concat "[ \t]*#\\+begin_" blocks-re))
+ (re-search-forward (concat "[ \t]*#\\+end_" blocks-re) nil t)
+ (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
+ (forward-line 1))))
(point)))))
(defun org-babel-result-to-file (result)
@@ -1570,7 +1568,7 @@ This takes into account some special considerations for
certain
parameters when merging lists."
(let ((results-exclusive-groups
'(("file" "list" "vector" "table" "scalar" "raw" "org"
- "html" "latex" "code" "pp")
+ "html" "latex" "code" "pp" "wrap")
("replace" "silent" "append" "prepend")
("output" "value")))
(exports-exclusive-groups
--
1.7.0.4
- [Orgmode] Re: [Babel] Need for an extra literal block construct, (continued)
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/19
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/19
- Re: [Orgmode] Re: [Babel] Need for an extra literal block construct, Thomas S. Dye, 2010/11/19
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/19
- Re: [Orgmode] Re: [Babel] Need for an extra literal block construct, Thomas S. Dye, 2010/11/19
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/19
- Re: [Orgmode] Re: [Babel] Need for an extra literal block construct, Eric Schulte, 2010/11/19
- Re: [Orgmode] Re: [Babel] Need for an extra literal block construct, Eric Schulte, 2010/11/19
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/20
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/22
- Re: [Orgmode] Re: [Babel] Need for an extra literal block construct,
Eric Schulte <=
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/23
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/19
- Re: [Orgmode] Re: [Babel] Need for an extra literal block construct, Christian Moe, 2010/11/19
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/19
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Dan Davison, 2010/11/20
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/20
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Dan Davison, 2010/11/21
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/22
- Re: [Orgmode] Re: [Babel] Need for an extra literal block construct, Nicolas Goaziou, 2010/11/21
- [Orgmode] Re: [Babel] Need for an extra literal block construct, Sébastien Vauban, 2010/11/22