From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: [BABEL] "unset" :var definitions for subtree Date: Sat, 12 Feb 2011 15:54:11 -0700 Message-ID: <87lj1k4ziy.fsf@gmail.com> References: <4D500BEC.1080300@gmail.com> <87bp2koeir.fsf@gmail.com> <4D53A2D2.2080300@gmail.com> <87r5bfn8dg.fsf@gmail.com> <4D54FAA0.3040309@gmail.com> <4D550DCB.3070305@gmail.com> <4D552BC6.7070400@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=56871 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoOez-0001oJ-I8 for emacs-orgmode@gnu.org; Sat, 12 Feb 2011 18:13:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PoOey-0005gg-FA for emacs-orgmode@gnu.org; Sat, 12 Feb 2011 18:13:49 -0500 Received: from mail-pz0-f41.google.com ([209.85.210.41]:33395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PoOey-0005gZ-7j for emacs-orgmode@gnu.org; Sat, 12 Feb 2011 18:13:48 -0500 Received: by pzk27 with SMTP id 27so806327pzk.0 for ; Sat, 12 Feb 2011 15:13:46 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: emacs-orgmode , Rainer M Krug Dan Davison writes: > [...] >>> 2. It should be possible somehow to include the options together with >>> the shebang, or to replace :shebang with a more general "preamble" >>> concept. Or to make :shebang accept a code block as its value. >>> >>> -------------------------------------------- >>> #+BABEL: :var A=13 >>> #+BABEL: :var B=14 >>> >>> #+header: :shebang #!/bin/bash #$ -cwd >>> #+begin_src sh :tangle script.sh >>> # empty >>> #+end_src >>> -------------------------------------------- >> >> Similar to above - should work, but now the options for torque are >> hidden in the shebang - which is not to nice, but should work - although >> changing the options is not nearly as nice as if the options are in the >> source block. > > It seems that we should be able to put the preamble lines in a src > block. This works, but only after making an alteration to the sbe > function (below) so that it will allow multiple line results. Maybe Eric > will have some ideas here. > I'm happy for your patch below to be applied, although maybe replace org-babel-table-truncate-at-newline with org-babel-trim, so that leading/trailing newlines are still removed. It would be nice to retain org-babel-table-truncate-at-newline if we could tell which evaluations were headed for a variable -- although this behavior doesn't seem worth the addition of a new argument to sbe. > > --------------------------------------- > #+BABEL: :var A=13 > #+BABEL: :var B=14 > > #+srcname: sheb > #+begin_src sh :results output > echo '#!/bin/bash' > echo '#$ -cwd' > #+end_src > > #+header: :shebang (sbe sheb) > #+begin_src sh :tangle script.sh > # empty > #+end_src > --------------------------------------- > > > (setq source-block (symbol-name source-block))) > - (org-babel-table-truncate-at-newline ;; org-table cells can't be multi-line > (if (and source-block (> (length source-block) 0)) > (let ((params > (eval `(org-babel-parse-header-arguments > @@ -116,7 +115,7 @@ example above." > ")"))))) > (org-babel-execute-src-block > nil (list "emacs-lisp" "results" params) '((:results . "silent")))) > - "")))) > + ""))) > > > Dan