zsh-users
 help / color / mirror / code / Atom feed
* problem with GNU Emacs shell mode
@ 1997-02-26 21:00 Jerry Jackson
  1997-02-27  1:22 ` Bart Schaefer
  0 siblings, 1 reply; 10+ messages in thread
From: Jerry Jackson @ 1997-02-26 21:00 UTC (permalink / raw)
  To: zsh-users

Hello,

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.  I've since
moved on to a new job and I'd like to upgrade to the current Emacs.

Has anyone figured out how to fix this problem?  (I tried to look in
the mail archives but I couldn't get on to the FTP server.)

Surely someone else must be a shell mode user???

Thanks in advance,

Jerry Jackson


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

* Re: problem with GNU Emacs shell mode
  1997-02-26 21:00 problem with GNU Emacs shell mode Jerry Jackson
@ 1997-02-27  1:22 ` Bart Schaefer
  1997-02-27 14:38   ` James B. Crigler
  0 siblings, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 1997-02-27  1:22 UTC (permalink / raw)
  To: Jerry Jackson, zsh-users

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

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.


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

* Re: problem with GNU Emacs shell mode
  1997-02-27  1:22 ` Bart Schaefer
@ 1997-02-27 14:38   ` James B. Crigler
  1997-02-27 14:58     ` Peter Stephenson
  1997-02-27 17:43     ` Bart Schaefer
  0 siblings, 2 replies; 10+ messages in thread
From: James B. Crigler @ 1997-02-27 14:38 UTC (permalink / raw)
  To: zsh-users; +Cc: schaefer

>>>>> "Bart" == Bart Schaefer <schaefer@candle.brasslantern.com> writes:
>>>>> "Jerry" == Jerry Jackson <jrj@chsft.com> writes:

 Jerry> I've been using zsh for a long time but when GNU Emacs changed
 Jerry> comint mode around version 19.2x - 19.3x I started getting a
 Jerry> lot of spurious ^M's in my buffer.
[...]
 Jerry> Has anyone figured out how to fix this problem?
[...]
 Bart> Placing a
 Bart>     (setenv "TERM" "emacs")
 Bart> in your ~/.emacs file seems to fix this.  If that confuses
 Bart> other programs that are run from within emacs, you can instead
 Bart> use
 Bart>    (setenv "ESHELL" "~/bin/eshell")
 Bart> and then put "TERM=emacs exec zsh" in the file ~/bin/eshell.

Neither of these works for me.  I start a shell and get ^M's and "echo
$TERM" still returns "dumb".  Next idea?

-- 
Jim Crigler <crigler@seo.com>
Schwartz Electro-Optics, Inc.   Voice:  (407)298-1802 x200
3404 N. Orange Blossom Tr.        Fax:  (407)290-9666
Orlando FL 32804-3498 USA


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

* Re: problem with GNU Emacs shell mode
  1997-02-27 14:38   ` James B. Crigler
@ 1997-02-27 14:58     ` Peter Stephenson
  1997-02-27 15:18       ` James B. Crigler
  1997-02-27 17:43     ` Bart Schaefer
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 1997-02-27 14:58 UTC (permalink / raw)
  To: James B. Crigler, Zsh users list

"James B. Crigler" wrote:
> 
> Neither of these works for me.  I start a shell and get ^M's and "echo
> $TERM" still returns "dumb".  Next idea?

Assuming you're never going to be doing command line editing with zsh
in a terminal that's `dumb', you can put

[[ $TERM = dumb ]] && unsetopt zle

in your .zshrc.  This certainly works for me.

(If you *did* need to do edit in a dumb terminal, probably the right thing
to do would be to find out what the terminal actually is anyway.)

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

* Re: problem with GNU Emacs shell mode
  1997-02-27 14:58     ` Peter Stephenson
@ 1997-02-27 15:18       ` James B. Crigler
  0 siblings, 0 replies; 10+ messages in thread
From: James B. Crigler @ 1997-02-27 15:18 UTC (permalink / raw)
  To: pws; +Cc: zsh-users

>>>>> "Peter" == Peter Stephenson <pws@ifh.de> writes:
>>>>> "Me" == James B. Crigler <crigler@seo.com> writes:

 Peter> "James B. Crigler" wrote:
 Me>  Neither of these works for me.  I start a shell and get ^M's and
 Me> "echo $TERM" still returns "dumb".  Next idea?

 Peter> Assuming you're never going to be doing command line editing
 Peter> with zsh in a terminal that's `dumb', you can put

 Peter> [[ $TERM = dumb ]] && unsetopt zle

 Peter> in your .zshrc.  This certainly works for me.

As it did for me.  Many thanks.

 Peter> (If you *did* need to do edit in a dumb terminal, probably the
 Peter> right thing to do would be to find out what the terminal
 Peter> actually is anyway.)

True, but since the subject is GNU Emacs shell mode, I have plenty of
editing capability.

-- 
Jim Crigler <crigler@seo.com>
Schwartz Electro-Optics, Inc.   Voice:  (407)298-1802 x200
3404 N. Orange Blossom Tr.        Fax:  (407)290-9666
Orlando FL 32804-3498 USA


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

* Re: problem with GNU Emacs shell mode
  1997-02-27 14:38   ` James B. Crigler
  1997-02-27 14:58     ` Peter Stephenson
@ 1997-02-27 17:43     ` Bart Schaefer
  1997-02-27 19:15       ` James B. Crigler
  1 sibling, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 1997-02-27 17:43 UTC (permalink / raw)
  To: James B. Crigler, zsh-users

On Feb 27,  9:38am, James B. Crigler wrote:
} Subject: Re: problem with GNU Emacs shell mode
}
} >>>>> "Bart" == Bart Schaefer <schaefer@candle.brasslantern.com> writes:
}  Bart> Placing a
}  Bart>     (setenv "TERM" "emacs")
}  Bart> in your ~/.emacs file seems to fix this.
} 
} Neither of these works for me.  I start a shell and get ^M's and "echo
} $TERM" still returns "dumb".  Next idea?

If you C-h v process-environment RET in emacs, what is TERM set to?  Maybe
you're stomping on the (setenv ...) with a (setq process-environment ...)
or some such, elsewhere?

Try this:

;; Don't set TERM=dumb, it bugs zsh.

(require 'comint)
(defun comint-exec-1 (name buffer command switches)
  (let ((process-environment
	 (nconc
	  (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
	      (list "EMACS=t" "TERM=emacs"
		    (format "COLUMNS=%d" (frame-width)))
	    (list "EMACS=t" "TERM=emacs"
		  (format "TERMCAP=emacs:co#%d:tc=unknown" (frame-width))))
	  process-environment)))
    (apply 'start-process name buffer command switches)))

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

* Re: problem with GNU Emacs shell mode
  1997-02-27 17:43     ` Bart Schaefer
@ 1997-02-27 19:15       ` James B. Crigler
  1997-02-27 20:48         ` Bart Schaefer
  0 siblings, 1 reply; 10+ messages in thread
From: James B. Crigler @ 1997-02-27 19:15 UTC (permalink / raw)
  To: zsh-users; +Cc: schaefer

-----BEGIN PGP SIGNED MESSAGE-----

>>>>> "Bart" == Bart Schaefer <schaefer@candle.brasslantern.com> writes:
>>>>> "Me" = James B. Crigler <crigler@seo.com> writes:

 Bart> Placing a
 Bart>     (setenv "TERM" "emacs")
 Bart> in your ~/.emacs file seems to fix this.

 Me> Neither of these works for me.  I start a shell and get ^M's and
 Me> "echo $TERM" still returns "dumb".  Next idea?

 Bart> If you C-h v process-environment RET in emacs, what is TERM set
 Bart> to?  Maybe you're stomping on the (setenv ...) with a (setq
 Bart> process-environment ...)  or some such, elsewhere?

Nothing, i.e., there is no TERM in process-environment.  (I start
emacs from my .xinitrc so it will be available immediately---well, as
fast as emacs comes up, anyway.)

 Bart> Try this:

 Bart> ;; Don't set TERM=dumb, it bugs zsh.
 Bart> 
 Bart> (require 'comint)
 Bart> (defun comint-exec-1 (name buffer command switches)
 Bart>   (let ((process-environment
 Bart> 	 (nconc
 Bart> 	  (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
 Bart> 	      (list "EMACS=t" "TERM=emacs"
 Bart> 		    (format "COLUMNS=%d" (frame-width)))
 Bart> 	    (list "EMACS=t" "TERM=emacs"
 Bart> 		  (format "TERMCAP=emacs:co#%d:tc=unknown" (frame-width))))
 Bart> 	  process-environment)))
 Bart>     (apply 'start-process name buffer command switches)))

This also works.  (The previous solution was to add this:

   [[ $TERM = dumb ]] && unsetopt zle

to .zshrc.  Since you (Bart) are a lot more fluent in zsh stuff than I
am, could you comment on the relative merits of the two approaches?

- -- 
Jim Crigler <crigler@seo.com>
Schwartz Electro-Optics, Inc.   Voice:  (407)298-1802 x200
3404 N. Orange Blossom Tr.        Fax:  (407)290-9666
Orlando FL 32804-3498 USA

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBMxXdn7UOmtduhAKtAQHdQwQAnvv2N6HDYA4g84INhmzA2O9U4pDHJFN4
jqimfiQv8GrQ/GrSQCQwv68UNSqCaVAds9Rcv0Vx+ax7X2YL4ziCbNeg0T9xmTrE
7tVhW7MAaZ2MDuR9VaLdibUovlSzxTgqc/o/mp+RI6RPcNA2lO1m+zdBZHRdeu7o
/taaOd6zSy8=
=W9YN
-----END PGP SIGNATURE-----


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

* Re: problem with GNU Emacs shell mode
  1997-02-27 19:15       ` James B. Crigler
@ 1997-02-27 20:48         ` Bart Schaefer
  0 siblings, 0 replies; 10+ messages in thread
From: Bart Schaefer @ 1997-02-27 20:48 UTC (permalink / raw)
  To: James B. Crigler, zsh-users; +Cc: schaefer

On Feb 27,  2:15pm, James B. Crigler wrote:
> Subject: Re: problem with GNU Emacs shell mode
> 
>  Bart> ;; Don't set TERM=dumb, it bugs zsh.
>  Bart> 
>  Bart> (require 'comint)
>  Bart> (defun comint-exec-1 (name buffer command switches)
	   [...]
>  Bart>   )
> 
> This also works.

I suspect this means that you normally use comint for emacs shell-mode,
and that's why the (setenv "TERM" ...) didn't work.  Here's an excerpt
from what I sent to zsh-workers, which will probably appear in the FAQ
in some form or other:

On Feb 27, 10:16am, Bart Schaefer wrote:
> On Feb 27, 10:32am, Peter Stephenson wrote:
> } 
> } 3.6: Why does zsh not work in an Emacs shell mode any more?
> } 
> }   Placing a
> } 
> }     (setenv "TERM" "emacs")
> } 
> }   in your ~/.emacs file seems to fix this.
> 
> This may not be universal, based on the discussion on zsh-users.  It
> appears to work for the default shell-mode (shell.el) but not for the
> enhanced shell-mode supplied by comint (comint.el).
> 
> Looking at the lisp code in comint.el, it appears emacs forces TERM=dumb
> for systems where emacs is compiled with terminfo, and TERM=emacs for
> those where it's compiled with termcap.  There's no hook to override
> this; you can only redefine comint-exec-1 as in the sample I sent, which
> is bad if comint gets upgraded.
> 
> [...] I'd add (via Alain Caron <alainc@nortel.ca>):
> 
>    If none of the above works, place
> 
>       [[ -n "$EMACS" ]] && unsetopt zle
> 
>    in your $ZDOTDIR/.zshrc file.
> 
> If you want to say something about terminal mode:
> 
>    [[ -n "$EMACS" ]] && {
>      [[ "$TERM" = eterm ]] && TERM=vt100 || unsetopt zle
>    }


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

* Re: problem with GNU Emacs shell mode
  1997-02-27 14:37 Alain Caron
@ 1997-02-27 17:35 ` Bart Schaefer
  0 siblings, 0 replies; 10+ messages in thread
From: Bart Schaefer @ 1997-02-27 17:35 UTC (permalink / raw)
  To: Alain Caron, zsh-users; +Cc: jrj

On Feb 27,  9:37am, Alain Caron wrote:
} Subject: Re: problem with GNU Emacs shell mode
}
} 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".

This might be good, but how do we decide whether to do it when EMACS
is set to something other than `t'?

Terminal mode sets the EMACS variable to the emacs version number plus
the term-mode version number, and sets the terminal type to "eterm".
The eterm type works better when zle is off, too (but a better fix is
to reset TERM=vt100 and leave zle on).

} Another solution, is to put sthe following in your .zshrc
} 
} if [[ "$EMACS" == "t" ]]; then
} 
}   # initialization for an emacs shell-buffer
} 
}   unsetopt zle
}   ...
} 
} fi
} 
} I prefer this solution to the ones you proposed but this probably is a
} matter of taste.

I prefer the pre-startup reset of TERM only because zsh might change to
do or require something in addition to unset zle when running inside emacs
(e.g., it would be nice if zsh knew not to print ^G characters in its
correction prompts, and not to expect cbreak mode to work -- but those
restrictions don't apply to term-mode).

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

* Re: problem with GNU Emacs shell mode
@ 1997-02-27 14:37 Alain Caron
  1997-02-27 17:35 ` Bart Schaefer
  0 siblings, 1 reply; 10+ messages in thread
From: Alain Caron @ 1997-02-27 14:37 UTC (permalink / raw)
  To: schaefer; +Cc: jrj, zsh-users

In message "Re: problem with GNU Emacs shell mode",
'schaefer@nbn.com' 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...
   ...
else
   # default initialization: probably a vt100 emulator when dialing
   # from home.
   ...
fi

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@nortel.ca
phone: 514-765-7718


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

end of thread, other threads:[~1997-02-27 20:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-26 21:00 problem with GNU Emacs shell mode Jerry Jackson
1997-02-27  1:22 ` Bart Schaefer
1997-02-27 14:38   ` James B. Crigler
1997-02-27 14:58     ` Peter Stephenson
1997-02-27 15:18       ` James B. Crigler
1997-02-27 17:43     ` Bart Schaefer
1997-02-27 19:15       ` James B. Crigler
1997-02-27 20:48         ` Bart Schaefer
1997-02-27 14:37 Alain Caron
1997-02-27 17:35 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).