help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q on using shell mode remotely


From: Kevin Rodgers
Subject: Re: Q on using shell mode remotely
Date: Mon, 31 Jul 2006 11:51:27 -0600
User-agent: Thunderbird 1.5.0.5 (Windows/20060719)

Drew Adams wrote:
When I use M-x telnet, I get a prompt that looks like this:

   > 8:34am

I have some Emacs-Lisp code that recognizes the shell prompt, in order to
let you complete and cycle among past shell inputs. I use
`comint-prompt-regexp' to recognize the prompt; I subtract the prompt from
an input line to get the actual command used.

In plain (local) shell mode on Windows, this works fine; there, the prompt I
see is this: "> ". In telnet mode, however, the time of day interferes. It
is not actually part of the prompt as understood by Emacs (comint mode) -
that is, it doesn't match the default value of `comint-prompt-regexp'. For
both shell and telnet modes, this is the value of `comint-prompt-regexp':

   "^[^#$%>\n]*[#$%>] *"

On the remote machine, I do have a right-side prompt variable ($rprompt) set
to add the time at the *right* side of the screen. I use csh as the
remote-machine shell, and this is my $prompt:

   "%B%.01%b %h:"

This is my $rprompt (it is this that prints the time of day at the right):

   "%@"

Through telnet, the time appears next to the left prompt (i.e. at the
left) - I guess there is no notion of right-side prompt, but it still picks
up $rprompt and concatenates it to $prompt. Naturally, it is not picked up
by `comint-prompt-regexp' (which can't know by itself that $rprompt is being
used and its value is a time-of-day pattern).

Any ideas on how to deal with this? Either 1) how to recognize the presence
of the added time (appearing at the left) and treat it as part of the
prompt, or 2) (not as good, because it won't help others who use my code)
how to tell telnet not to use the time part of the prompt? Is there some
variable similar to `comint-prompt-regexp' that will pick up $rprompt (or
the concatenation of $prompt and $rprompt)?

Why can't you just add a time pattern to telnet-prompt-pattern, which is
used to set the buffer-local value of comint-prompt-pattern:

(eval-after-load "telnet"
  '(setq telnet-prompt-pattern
      (concat telnet-prompt-pattern "\\([12]?[0-9]:[0-5][0-9][ap]m\\)?")))

--
Kevin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]