[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Unwanted "(progn )" when Tangling Lisp Code
From: |
Eric Schulte |
Subject: |
Re: [O] Unwanted "(progn )" when Tangling Lisp Code |
Date: |
Tue, 31 May 2011 09:57:02 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
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 <address@hidden> 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/