emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: [babel] Executing sh-code
Date: Sun, 29 Nov 2009 22:03:50 +0100	[thread overview]
Message-ID: <87638tnivd.fsf@mundaneum.com> (raw)
In-Reply-To: 877htb4uow.fsf@stats.ox.ac.uk

Hi Eric and Dan,

Dan Davison wrote:
> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>> Torsten Wagner wrote:
>>> This works for me (I changed the folder name). There is a error line in my
>>> message buffer:
>>>
>>> executing Shell source code block
>>> ~/babel 
>>> save-current-buffer: Wrong type argument: char-or-string-p, nil
>>>
>>> but the relevent part runs ok. My shell buffer depict to the new folder
>>> after execution:
>>>
>>> torsten@gaijin ~ % 
>>> cd ~/babel
>>> echo 'org_babel_sh_eoe'
>>> torsten@gaijin ~ % cd ~/babel
>>> torsten@gaijin ~/babel (git)-[master] %
>
>> It stops working only when I add `:session "whatever"' after the `sh'
>> specification.
>>
>> That's the only difference between when it works and when it doesn't.
>
> You discovered a tricky bug in the session-based evaluation of shell blocks.

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've just pushed up a fix which fixes this bug and generally cleans up the
> code executing sh blocks inside of interactive sessions. Please try the
> latest and see if the problem persists.

Just did: git pull && make clean && make.


> I'm also seeing problems with shell session evaluation but having
> trouble debugging. My current suspicion is that the prompt characters
> are the problem here (something which differs between you and Torsten)
> Could you try using a prompt that ends in '% '? E.g. on ubuntu at least
> I can set the prompt in emacs shell sessions with a line like
>
> PS1='\w % '
>
> in ~/.emacs_bash.

I did this in my .bashrc:

--8<---------------cut here---------------start------------->8---
# my format of the prompt
function my_prompt_command ()
{
    # colorful prompt, based on whether the previous command succeeded or not
    if [[ $? -eq 0 ]]; then
        HILIT=${GREEN}
    else
        HILIT=${RED}
    fi

    # replace the $HOME prefix by ~ in the current directory
    if [[ $HOME == ${PWD:0:${#HOME}} ]]; then
        NEWPWD="~${PWD:${#HOME}}"
    else
        NEWPWD=$PWD
    fi

    # how many characters of the $PWD should be kept
    local pwd_max_length=15

    if [[ ${#NEWPWD} -gt $pwd_max_length ]]; then
        local pwd_offset=$(( ${#NEWPWD} - $pwd_max_length ))
        NEWPWD="...${NEWPWD:$pwd_offset:$pwd_max_length}"
    fi

    # prompt character
    if [[ $(whoami) = "root" ]]; then
        local PROMPTCHAR="#"
    else
        local PROMPTCHAR=">"
    fi

    case $TERM in
        # TODO use `date' instead of escape characters...
        dumb)
            # Emacs shell mode and Tramp among others
            setenv PS1 "[\u@\h] ${NEWPWD}${PROMPTCHAR}"
            ;;
        emacs | *)
            # Emacs is handled in the same way as other terminals, if it's
            # configured to use `ansi-color' to translate ANSI escape
            # sequences into colored faces
            setenv PS1 "\w % "  ;; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            ;;
    esac
}
--8<---------------cut here---------------end--------------->8---


> Also, please pull latest git as we have just fixed an unrelated bug in
> shell session-based evaluation.

Now, with the new version and the prompt change, what's the result?

Let's assume the following Org file:

--8<---------------cut here---------------start------------->8---
#+begin_src sh :session "ecm"
cd ~/Personal
#+end_src

#+begin_src sh :session "ecm"
ls *.org
#+end_src
--8<---------------cut here---------------end--------------->8---

I C-c C-c the first snippet. Nothing special, except it doesn't hang anymore.
So, it already looks much better.

Second snippet. C-c C-c. There, it still hangs ;-((

Though, C-x C-b shows me the contents of the "ecm" buffer:

--8<---------------cut here---------------start------------->8---
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  refile.org
~/Personal % org_babel_sh_eoe
~/Personal % 
--8<---------------cut here---------------end--------------->8---

Looks closer to what it should...

Still a little problem, though, as explained above.

BTW, what's the impact of specifying "sh" or "bash" for the snippet?

Best regards,
  Seb

-- 
Sébastien Vauban



_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2009-11-29 21:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25 14:22 [babel] Executing sh-code Sébastien Vauban
2009-11-27  9:15 ` Sébastien Vauban
2009-11-27 10:46   ` Eric S Fraga
2009-11-27 10:00 ` Torsten Wagner
2009-11-27 10:43   ` Sébastien Vauban
2009-11-27 19:32     ` Eric Schulte
2009-11-27 19:46     ` Dan Davison
2009-11-29 21:03       ` Sébastien Vauban [this message]
2009-11-30 15:44         ` Eric Schulte
2009-11-30 16:02           ` Nick Dokos
2009-11-30 16:16             ` Eric Schulte
2009-12-01  8:37               ` Sébastien Vauban
2009-12-01 10:01           ` Sébastien Vauban
2009-12-02 19:09             ` Eric Schulte
2009-12-04 13:25               ` Sébastien Vauban
2009-12-04 14:09                 ` Sébastien Vauban
2009-12-04 17:04                   ` Eric Schulte
2009-12-07  1:10                   ` Torsten Wagner
2009-12-07  9:59                     ` Sébastien Vauban
2009-12-04 17:03                 ` Eric Schulte
2009-12-02 14:55           ` Sébastien Vauban
2009-12-02 20:16             ` Eric Schulte
2009-12-03  9:27               ` Sébastien Vauban
2009-12-03 16:06                 ` Eric Schulte

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=87638tnivd.fsf@mundaneum.com \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    /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).