From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Re: [babel] Executing sh-code Date: Mon, 30 Nov 2009 08:44:55 -0700 Message-ID: References: <87k4xey99s.fsf@mundaneum.com> <200911271900.08393.torsten.wagner@googlemail.com> <87ws1cgsd6.fsf@mundaneum.com> <877htb4uow.fsf@stats.ox.ac.uk> <87638tnivd.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NF8Qn-0006YA-3O for emacs-orgmode@gnu.org; Mon, 30 Nov 2009 10:44:53 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NF8Qi-0006Wc-W6 for emacs-orgmode@gnu.org; Mon, 30 Nov 2009 10:44:52 -0500 Received: from [199.232.76.173] (port=52538 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NF8Qi-0006WV-PG for emacs-orgmode@gnu.org; Mon, 30 Nov 2009 10:44:48 -0500 Received: from mail-pz0-f181.google.com ([209.85.222.181]:51040) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NF8Qi-0007gH-A1 for emacs-orgmode@gnu.org; Mon, 30 Nov 2009 10:44:48 -0500 Received: by pzk11 with SMTP id 11so2347132pzk.14 for ; Mon, 30 Nov 2009 07:44:47 -0800 (PST) In-Reply-To: <87638tnivd.fsf@mundaneum.com> (=?utf-8?Q?=22S=C3=A9bastien?= Vauban"'s message of "Sun, 29 Nov 2009 22:03:50 +0100") 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: =?utf-8?Q?S=C3=A9bastien?= Vauban Cc: emacs-orgmode@gnu.org Hi S=C3=A9bastien, S=C3=A9bastien Vauban writes: [...] > > Just for my information (maybe being able to be more accurate next time, = or > even finding a solution myself), how do you debug such a problem? > > With which debugger, with tracing/stepping? With stack trace? > I'm almost embarrassed to admit that I do most of my elisp debugging with the `message' function. I embed `message' debug statements to print the values of key variables at key points, and I run through problems looking at the output. I'd be interested to hear if anyone can recommend a better elisp debugging solution. > > Let's assume the following Org file: > > #+begin_src sh :session "ecm" > cd ~/Personal > #+end_src > > #+begin_src sh :session "ecm" > ls *.org > #+end_src > > I C-c C-c the first snippet. Nothing special, except it doesn't hang anym= ore. > So, it already looks much better. > > Second snippet. C-c C-c. There, it still hangs=C2=A0;-(( > > Though, C-x C-b shows me the contents of the "ecm" buffer: > > cd ~/Personal > > ~ % ~/Personal % ls *.org > echo 'org_babel_sh_eoe' > Bookmarks.org Scorpios.org Tickler.org Voice= -over-IP.org* > Home.org* Succession.org Using-startx-for-Remote-Display.org refil= e.org > ~/Personal % org_babel_sh_eoe > ~/Personal %=20 > > Looks closer to what it should... > > Still a little problem, though, as explained above. > So the fix here is to fix the value of the `comint-prompt-regexp' variable in your shell. Org-babel uses this variable to digest output from the shell. I have mine set with the following --8<---------------cut here---------------start------------->8--- (defun schulte/set-shell-prompt-regexp () (setq comint-prompt-regexp "^\(.+\)")) (add-hook 'shell-mode-hook 'schulte/set-shell-prompt-regexp) --8<---------------cut here---------------end--------------->8--- You'll have to change the regexp ("^\(.+\)" in my example) to match your prompt. I was unable to create your prompt locally. I find the `regexp-builder' function to be very handy for these situations. If you are unable to build a working regexp please send me a string of your prompt and I'd be happy to return an appropriate regexp. on a related topic: I've also noticed that org-babel has difficulty digesting shell output when it is ansi-colorized. I'm not sure what the best fix here would be. We could probably start piping all org-babel session results through something like `ansi-color-filter-region' but that feels a little bit too heavy. I'd be interested to hear other peoples thoughts/suggestions. > > BTW, what's the impact of specifying "sh" or "bash" for the snippet? > While "sh" blocks should work "bash" blocks will not be recognized. In org-babel "sh" doesn't explicitly mean the "sh" command, but rather means 'run shell' which will default to whatever shell you have configured. Thanks -- Eric > > Best regards, > Seb