From: Benjamin Andresen <benny@in-ulm.de>
To: emacs-orgmode@gnu.org
Subject: org-babel: [PATCH] allow emacs-lisp results to be pretty-printed
Date: Sat, 03 Oct 2009 20:29:15 +0200 [thread overview]
Message-ID: <87r5tkqqkk.fsf@in-ulm.de> (raw)
[-- 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
next reply other threads:[~2009-10-03 18:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-03 18:29 Benjamin Andresen [this message]
2009-10-03 19:27 ` allow emacs-lisp results to be pretty-printed 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r5tkqqkk.fsf@in-ulm.de \
--to=benny@in-ulm.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).