emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Babel] Marker does not point anywhere (when session buffer needs to be created)
@ 2010-10-15 15:41 Sébastien Vauban
  2010-11-04 13:47 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Sébastien Vauban @ 2010-10-15 15:41 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

* Marker does not point anywhere

Executing the following:

#+begin_src sh :session NoSuchSessionYet
cd ~
ls *.txt
#+end_src

outputs this in *Messages*:

: executing Sh code block...
: think it is Cygwin...
: ~ 
: ansi-color-process-output: Marker does not point anywhere

when executed for the *first* time. All subsequent executions don't exhibit
this error (currently, they hang, but that's another story).

My prompt is colored -- I need it, really!  *None* of the =ls= results are
colored, though (in this above case: =ls ~/*.txt=).

Can we fix this somehow?

Test the following, and you'll see you need a colored prompt as well, if not
yet convinced:

#+begin_src sh :tangle .sva-bashrc
#*** Controlling the Prompt

# define some colors
RED='\e[1;31m'
GREEN='\e[1;32m'
NO_COLOR='\e[0m'

# 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
        dumb)  # for Tramp?
            setenv PS1 "[\u@\h] ${NEWPWD}${PROMPTCHAR}"
            ;;
        *)
            setenv PS1 "\n\[${HILIT}\][\u@\h] ${NEWPWD}${PROMPTCHAR}\[${NO_COLOR}\]"
            ;;
    esac
}

# shell prompt
setenv PROMPT_COMMAND my_prompt_command
echo ""
#+end_src

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Babel] Marker does not point anywhere (when session buffer needs to be created)
  2010-10-15 15:41 [Babel] Marker does not point anywhere (when session buffer needs to be created) Sébastien Vauban
@ 2010-11-04 13:47 ` Eric Schulte
  2010-11-04 15:51   ` Sébastien Vauban
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2010-11-04 13:47 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode

Hi Seb,

This "mark doesn't point anywhere" error is common across a bunch of
sessions (ruby and python as well as shell).  It's simply a matter of
Babel trying to use the session before it is ready.  I haven't found
these errors to be an issue as all subsequent use of the session works
as expected.  I suppose that we should try to be more careful on session
creation explicitly waiting until the buffer is ready, however this
would add some degree of complication to the code...

Thanks -- Eric

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:

> * Marker does not point anywhere
>
> Executing the following:
>
> #+begin_src sh :session NoSuchSessionYet
> cd ~
> ls *.txt
> #+end_src
>
> outputs this in *Messages*:
>
> : executing Sh code block...
> : think it is Cygwin...
> : ~ 
> : ansi-color-process-output: Marker does not point anywhere
>
> when executed for the *first* time. All subsequent executions don't exhibit
> this error (currently, they hang, but that's another story).
>
> My prompt is colored -- I need it, really!  *None* of the =ls= results are
> colored, though (in this above case: =ls ~/*.txt=).
>
> Can we fix this somehow?
>
> Test the following, and you'll see you need a colored prompt as well, if not
> yet convinced:
>
> #+begin_src sh :tangle .sva-bashrc
> #*** Controlling the Prompt
>
> # define some colors
> RED='\e[1;31m'
> GREEN='\e[1;32m'
> NO_COLOR='\e[0m'
>
> # 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
>         dumb)  # for Tramp?
>             setenv PS1 "[\u@\h] ${NEWPWD}${PROMPTCHAR}"
>             ;;
>         *)
>             setenv PS1 "\n\[${HILIT}\][\u@\h] ${NEWPWD}${PROMPTCHAR}\[${NO_COLOR}\]"
>             ;;
>     esac
> }
>
> # shell prompt
> setenv PROMPT_COMMAND my_prompt_command
> echo ""
> #+end_src
>
> Best regards,
>   Seb

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Babel] Marker does not point anywhere (when session buffer needs to be created)
  2010-11-04 13:47 ` Eric Schulte
@ 2010-11-04 15:51   ` Sébastien Vauban
  0 siblings, 0 replies; 3+ messages in thread
From: Sébastien Vauban @ 2010-11-04 15:51 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

HI Eric,

"Eric Schulte" wrote:
> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>> * Marker does not point anywhere
>>
>> Executing the following:
>>
>> #+begin_src sh :session NoSuchSessionYet
>> cd ~
>> ls *.txt
>> #+end_src
>>
>> outputs this in *Messages*:
>>
>> : executing Sh code block...
>> : think it is Cygwin...
>> : ~ 
>> : ansi-color-process-output: Marker does not point anywhere
>>
>> when executed for the *first* time.
>
> This "mark doesn't point anywhere" error is common across a bunch of
> sessions (ruby and python as well as shell). It's simply a matter of Babel
> trying to use the session before it is ready. I haven't found these errors
> to be an issue as all subsequent use of the session works as expected.

OK.


> I suppose that we should try to be more careful on session creation
> explicitly waiting until the buffer is ready, however this would add some
> degree of complication to the code...

Just a stupid idea: adding a sleep for 5 seconds or so, the first time the
session is created?  I wouldn't mind having to wait a bit on the first session
invocation, if I'm sure everything works better that way.


>> All subsequent executions don't exhibit this error (currently, they hang,
>> but that's another story).

The new posting of today refers to this issue.


>> My prompt is colored -- I need it, really!  *None* of the =ls= results are
>> colored, though (in this above case: =ls ~/*.txt=).
>>
>> Can we fix this somehow?

For now, I've given up using a colored shell, just to be sure I try to get sh
sessions working before adding complexity into the game.

So, now, my prompt is without any ANSI color spec, and completely mono-lined
(no extra \n), as you can see in the other post. Don't look at this for now --
except if you find it great to use! ;-)


>> Test the following, and you'll see you need a colored prompt as well, if not
>> yet convinced:
>>
>> #+begin_src sh :tangle .sva-bashrc
>> #*** Controlling the Prompt
>>
>> # define some colors
>> RED='\e[1;31m'
>> GREEN='\e[1;32m'
>> NO_COLOR='\e[0m'
>>
>> # 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
>>         dumb)  # for Tramp?
>>             setenv PS1 "[\u@\h] ${NEWPWD}${PROMPTCHAR}"
>>             ;;
>>         *)
>>             setenv PS1 "\n\[${HILIT}\][\u@\h] ${NEWPWD}${PROMPTCHAR}\[${NO_COLOR}\]"
>>             ;;
>>     esac
>> }
>>
>> # shell prompt
>> setenv PROMPT_COMMAND my_prompt_command
>> echo ""
>> #+end_src

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-04 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-15 15:41 [Babel] Marker does not point anywhere (when session buffer needs to be created) Sébastien Vauban
2010-11-04 13:47 ` Eric Schulte
2010-11-04 15:51   ` Sébastien Vauban

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).