GNU bug report logs -
#33092
26.1; Re-running shell wipes font-lock from xterm-color
Previous Next
To reply to this bug, email your comments to 33092 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33092
; Package
emacs
.
(Fri, 19 Oct 2018 07:18:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Allen Li <darkfeline <at> felesatra.moe>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 19 Oct 2018 07:18:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Where to begin?
The problem I am having is that when there is already a *shell* buffer
without a running process, re-running the `shell' command will reuse the
buffer and wipe the font-lock color added by xterm-color.el, a
third-party package.
I'm reporting this here because it seems like Emacs could be improved in
some way to avoid this class of problem.
What causes this is as follows:
The `shell' command will call `make-comint-in-buffer' and `shell-mode'.
`shell-mode' will then call `comint-mode' as a derived mode.
`comint-mode' will call `kill-all-local-variables'.
`comint-mode' also adds `font-lock-defontify' to
`change-major-mode-hook'. Since we're already in `shell-mode' derived
from `comint-mode', switching "back" to `shell-mode' wipes font-lock.
I can work around this pretty easily in my personal config, by removing
`font-lock-defontify' from `change-major-mode-hook' with a well-placed
advice, but the current behavior doesn't seem comfortable to me.
First, if we're reusing the buffer, do we have to switch to `shell-mode'
again? The advantage is that it clears out some buffer state, so it's
kind of like running a "fresh" `shell'.
But the existing output in the buffer isn't cleared (although it is
defontified as I found out to my dismay). The `default-directory' isn't
reset either; normally running `shell' starts the shell with the
`default-directory' of the buffer of your current window, but not if it
reuses a *shell* buffer.
So the current behavior of `shell', if it reuses the *shell* buffer, is
to do a half-hearted reset of the buffer state. As a user this is very
hard to understand and I certainly would not have understood it had I
not taken Edebug to the problem.
`shell' should either fully reset the buffer or touch as little as
possible. The reset option is indistinguishable from killing the existing
*shell* buffer and creating a new one. Therefore, if we are going to
reuse the buffer, I think the desired intent would be to touch as little
as possible, in which case we want to avoid the `shell-mode'
reset if we are reusing the *shell* buffer.
In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
of 2018-07-05 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.12001000
Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
-fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 MODULES THREADS LIBSYSTEMD LCMS2
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33092
; Package
emacs
.
(Wed, 30 Oct 2019 19:19:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 33092 <at> debbugs.gnu.org (full text, mbox):
Allen Li <darkfeline <at> felesatra.moe> writes:
> The `shell' command will call `make-comint-in-buffer' and `shell-mode'.
>
> `shell-mode' will then call `comint-mode' as a derived mode.
>
> `comint-mode' will call `kill-all-local-variables'.
>
> `comint-mode' also adds `font-lock-defontify' to
> `change-major-mode-hook'. Since we're already in `shell-mode' derived
> from `comint-mode', switching "back" to `shell-mode' wipes font-lock.
>
> I can work around this pretty easily in my personal config, by removing
> `font-lock-defontify' from `change-major-mode-hook' with a well-placed
> advice, but the current behavior doesn't seem comfortable to me.
Yes, that seems odd. Unfortunately the commit log for this just says:
commit 3dd4c1c5af3cdf77ba98b7255ec4034051107c6f
Author: Richard M. Stallman <rms <at> gnu.org>
Date: Tue Sep 10 16:44:58 2002 +0000
(comint-mode): Add font-lock-defontify to change-major-mode-hook.
So I have no idea what this was supposed to fix. Richard, do you
remember, by any chance?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
This bug report was last modified 5 years and 229 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.