Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: problem with GNU Emacs shell mode

In message "Re: problem with GNU Emacs shell mode",
'schaefer@xxxxxxx' writes:

>On Feb 26,  2:00pm, Jerry Jackson wrote:
>> Subject: problem with GNU Emacs shell mode
>> I've been using zsh for a long time but when GNU Emacs changed
>> comint mode around version 19.2x - 19.3x I started getting a lot
>> of spurious ^M's in my buffer.  I couldn't figure out how to fix
>> it and I reverted to Emacs version 19.21 for years.
>Ouch!  Why didn't you ask sooner?
>> Has anyone figured out how to fix this problem?
>Emacs 19.29 or thereabouts stopped using a terminal type of "emacs"
>in shell buffers, and instead sets it to "dumb".  Zsh only kicks in
>its special I'm-inside-emacs initialization when the terminal type
>is "emacs".

Emacs sets the EMACS environment variable to "t" in shell buffers.

Maybe ZSH should also kick its "I'm-inside-emacs" initialization when
the EMACS variable is set to "t".

>Placing a
>(setenv "TERM" "emacs")
>in your ~/.emacs file seems to fix this.  If that confuses other programs
>that are run from within emacs, you can instead use
>(setenv "ESHELL" "~/bin/eshell")
>and then put "TERM=emacs exec zsh" in the file ~/bin/eshell.

Another solution, is to put sthe following in your .zshrc

if [[ "$TERM" == "xterm"]]; then

   # initialization for an xterm

elif [[ "$EMACS" == "t" ]]; then

  # initialization for an emacs shell-buffer

  unsetopt zle

elsif [[ "${TERM%%-em[0-9]#}" == "emacs" ]]; then
   # running zsh under the emacs terminal-emulator...
   # default initialization: probably a vt100 emulator when dialing
   # from home.

I prefer this solution to the ones you proposed but this probably is a
matter of taste.

Alain Caron
Nortel Technology, Montréal, Québec, Canada
email: alainc@xxxxxxxxx
phone: 514-765-7718

Messages sorted by: Reverse Date, Date, Thread, Author