From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Literate Programming - Continue a Source Block? Date: Mon, 13 Jun 2011 14:57:18 -0700 Message-ID: <87zkllie03.fsf@gmail.com> References: <87pqmokh6d.fsf@fester.com> <80k4cw22uf.fsf@somewhere.org> <87fwnkjqoh.fsf@fester.com> <87mxhsnmcf.fsf@gmail.com> <877h8wj9za.fsf@fester.com> <877h8tv6yh.fsf@gmail.com> <87fwnhgps2.fsf@fester.com> <871uz0m8q9.fsf@gmail.com> <87oc238vby.fsf@fester.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:43094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWFG8-0001ES-PS for emacs-orgmode@gnu.org; Mon, 13 Jun 2011 18:05:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWFG5-0007ga-Sw for emacs-orgmode@gnu.org; Mon, 13 Jun 2011 18:05:24 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:50263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWFG5-0007gR-Bc for emacs-orgmode@gnu.org; Mon, 13 Jun 2011 18:05:21 -0400 Received: by pvc12 with SMTP id 12so2787907pvc.0 for ; Mon, 13 Jun 2011 15:05:20 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Neeum Zawan Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Neeum, Neeum Zawan writes: > Eric Schulte writes: > >> Hi Neeum, >> >> Thanks for your feedback. Your point is well taken about the >> flexibility of header arguments, and the ability of a header argument >> based solution to overwrite blocks. >> >> I would mention that variables such as the newly introduced >> `org-babel-tangle-named-block-combination' may be easily set on a >> per-file bases using file local variables---basically adding a line like >> the following to the top of your Org-mode file. > > Somehow I couldn't get your new function to work. The variable is set to > append, and I removed all org-modes from my system except the latest > from git. I even ensured that this code gets executed: > > (append (mapconcat #'identity > named "\n")) > > However, the output I get is the same as before - it just uses the first > source block. > Could you try the attached example file? I first evaluated the following elisp code to set the combination variable's value to append. #+begin_src emacs-lisp (setq org-babel-tangle-named-block-combination 'append) #+end_src I then call org-babel-tangle in the attached Org-mode file to generate the attached elisp file. --=-=-= Content-Type: text/x-org Content-Disposition: attachment; filename=combined-tangle-example.org * continued code blocks :PROPERTIES: :tangle: yes :comments: yes :END: #+source: foo #+begin_src emacs-lisp (message "foo:%S" 1) #+end_src #+begin_src emacs-lisp (message "un-named") #+end_src #+source: bar #+begin_src emacs-lisp (message "bar:%S" 1) #+end_src #+source: foo #+begin_src emacs-lisp (message "foo:%S" 2) #+end_src #+source: bar #+begin_src emacs-lisp (message "bar:%S" 2) #+end_src #+begin_src emacs-lisp :tangle no :results silent (with-temp-buffer (insert-file-contents "scraps.el") (eval-buffer)) #+end_src --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=combined-tangle-example.el Content-Transfer-Encoding: quoted-printable ;; [[file:~/Desktop/combined-tangle-example.org::*continued%2520code%2520bl= ocks][foo]] (message "foo:%S" 1) (message "foo:%S" 2) ;; foo ends here ;; [[file:~/Desktop/combined-tangle-example.org::*continued%2520code%2520bl= ocks][continued-code-blocks:2]] (message "un-named") ;; continued-code-blocks:2 ends here ;; [[file:~/Desktop/combined-tangle-example.org::*continued%2520code%2520bl= ocks][bar]] (message "bar:%S" 1) (message "bar:%S" 2) ;; bar ends here --=-=-= Content-Type: text/plain > > Incidentally, why do we need "\n" as a separator? What if I wanted to > do (in Python) > > def func(a, b, <>): > stuff > > In other words, I want to add more arguments later on. Wouldn't a \n > mess things up here? > Ah, this is a good point. I've just changed the code to avoid inserting superfluous newlines. Thanks! Cheers -- Eric > > > Thanks. > > -- Eric Schulte http://cs.unm.edu/~eschulte/ --=-=-=--