* org-babel: [PATCH] allow emacs-lisp results to be pretty-printed
@ 2009-10-03 18:29 Benjamin Andresen
2009-10-03 19:27 ` Benjamin Andresen
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Andresen @ 2009-10-03 18:29 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 350 bytes --]
Hey there,
on irc (#org-mode) someone asked how one would go about to insert the
result of a emacs-lisp function without it being transformed into a
org-mode table.
I didn't see any other way, so I wrote a small patch that allows the
parameter :results to accept 'pp'. Is this the right way? And where
should this special parameter be documented?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: babel-el-results-pp.patch --]
[-- Type: text/x-patch, Size: 1189 bytes --]
diff --git a/contrib/babel/lisp/langs/org-babel-emacs-lisp.el b/contrib/babel/lisp/langs/org-babel-emacs-lisp.el
index 39f5cc7..60671ac 100644
--- a/contrib/babel/lisp/langs/org-babel-emacs-lisp.el
+++ b/contrib/babel/lisp/langs/org-babel-emacs-lisp.el
@@ -39,10 +39,14 @@
"Execute a block of emacs-lisp code with org-babel. This
function is called by `org-babel-execute-src-block' via multiple-value-bind."
(message "executing emacs-lisp code block...")
- (save-window-excursion
- (let ((print-level nil) (print-length nil))
- (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var))) vars)
- ,(read (concat "(progn " body ")")))))))
+ (let ((results (cdr (assoc :results params))))
+ (save-window-excursion
+ (let ((print-level nil) (print-length nil))
+ (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var))) vars)
+ ,(read (concat "(progn " (if (string-match "pp$" results)
+ (concat "(pp " body ")")
+ body)
+ ")"))))))))
(provide 'org-babel-emacs-lisp)
;;; org-babel-emacs-lisp.el ends here
[-- Attachment #3: Type: text/plain, Size: 11 bytes --]
br,
benny
[-- Attachment #4: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-18 16:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-03 18:29 org-babel: [PATCH] allow emacs-lisp results to be pretty-printed Benjamin Andresen
2009-10-03 19:27 ` Benjamin Andresen
[not found] ` <m2tyyfi3oz.fsf@gmail.com>
[not found] ` <87hbufqi8m.fsf@in-ulm.de>
[not found] ` <m2iqevi24b.fsf@gmail.com>
2009-10-18 16:12 ` [babel] " Eric Schulte
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).