emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Mark Cox <markcox80@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Unwanted "(progn )" when Tangling Lisp Code
Date: Tue, 31 May 2011 09:57:02 -0600	[thread overview]
Message-ID: <87y61mmk5j.fsf@gmail.com> (raw)
In-Reply-To: BANLkTikGB2UGRD__jmgV9OqzuKQCOasKfA@mail.gmail.com

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/

      reply	other threads:[~2011-06-01  1:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31  1:39 Unwanted "(progn )" when Tangling Lisp Code Mark Cox
2011-05-31 15:57 ` Eric Schulte [this message]

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=87y61mmk5j.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=markcox80@gmail.com \
    /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).