* Unwanted "(progn )" when Tangling Lisp Code
@ 2011-05-31 1:39 Mark Cox
2011-05-31 15:57 ` Eric Schulte
0 siblings, 1 reply; 2+ messages in thread
From: Mark Cox @ 2011-05-31 1:39 UTC (permalink / raw)
To: emacs-orgmode
Hi,
When tangling lisp source code blocks, the tangled code is wrapped in
a `(progn ,@body). For example,
the block
#+begin_src lisp :tangle example.lisp
(defun mischief ()
(/ 1 0))
#+end_src
produces
: (progn (defun mischief ()
: (/ 1 0))
: )
With the attached patch, the tangling process now produces
:
: (defun mischief ()
: (/ 1 0))
Thanks
Mark
Here is the patch.
diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el
index a810d86..3382418 100644
--- a/lisp/ob-lisp.el
+++ b/lisp/ob-lisp.el
@@ -54,7 +54,7 @@
(format "(%S (quote %S))" (car var) (cdr var)))
vars "\n ")
")\n" body ")")
- (format "(progn %s)" body)))))
+ body))))
(if (or (member "code" result-params)
(member "pp" result-params))
(format "(pprint %s)" body)
@@ -65,7 +65,7 @@
(require 'slime)
(org-babel-reassemble-table
(with-temp-buffer
- (insert (org-babel-expand-body:lisp body params))
+ (insert (format "(progn\n %s)" (org-babel-expand-body:lisp body params)))
((lambda (result)
(if (member "output" (cdr (assoc :result-params params)))
(car result)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Unwanted "(progn )" when Tangling Lisp Code
2011-05-31 1:39 Unwanted "(progn )" when Tangling Lisp Code Mark Cox
@ 2011-05-31 15:57 ` Eric Schulte
0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2011-05-31 15:57 UTC (permalink / raw)
To: Mark Cox; +Cc: emacs-orgmode
Hi Mark,
Thanks for the suggestion, I've applied a modified version of your patch
which moves the progn wrapping out of the expand-body function and into
the evaluation function. Progn wrapping is required for blocks like the
following.
#+begin_src lisp :results value
(format t "~&eric")
(+ 1 2)
#+end_src
#+results:
: 3
Thanks -- Eric
Mark Cox <markcox80@gmail.com> writes:
> Hi,
>
> When tangling lisp source code blocks, the tangled code is wrapped in
> a `(progn ,@body). For example,
> the block
> #+begin_src lisp :tangle example.lisp
> (defun mischief ()
> (/ 1 0))
> #+end_src
> produces
> : (progn (defun mischief ()
> : (/ 1 0))
> : )
>
> With the attached patch, the tangling process now produces
> :
> : (defun mischief ()
> : (/ 1 0))
>
> Thanks
> Mark
>
> Here is the patch.
>
> diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el
> index a810d86..3382418 100644
> --- a/lisp/ob-lisp.el
> +++ b/lisp/ob-lisp.el
> @@ -54,7 +54,7 @@
> (format "(%S (quote %S))" (car var) (cdr var)))
> vars "\n ")
> ")\n" body ")")
> - (format "(progn %s)" body)))))
> + body))))
> (if (or (member "code" result-params)
> (member "pp" result-params))
> (format "(pprint %s)" body)
> @@ -65,7 +65,7 @@
> (require 'slime)
> (org-babel-reassemble-table
> (with-temp-buffer
> - (insert (org-babel-expand-body:lisp body params))
> + (insert (format "(progn\n %s)" (org-babel-expand-body:lisp body params)))
> ((lambda (result)
> (if (member "output" (cdr (assoc :result-params params)))
> (car result)
>
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-01 1:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-31 1:39 Unwanted "(progn )" when Tangling Lisp Code Mark Cox
2011-05-31 15:57 ` 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).