unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11883: 24.1.50; shell-mode doesn't colorize the prompt
@ 2012-07-09  5:29 Dima Kogan
  2012-11-06 19:12 ` bug#11883: Hints Dima Kogan
  0 siblings, 1 reply; 8+ messages in thread
From: Dima Kogan @ 2012-07-09  5:29 UTC (permalink / raw)
  To: 11883

When using shell mode (M-x shell), I'm seeing correct colors rendered
for output of commands like 'ls --color=auto'. However this doesn't
appear to apply to the prompt, all of which appears in one, wrong
color. This appears to be related to the prompt not emitting a trailing
newline (which is as it should be).

As a test, I can echo the ANSI codes myself. This produces a
correctly-colored red string:

dima@shorty:~$ echo -e "\033[31mtest\033[39m"
test <----- red

But this doesn't. Note it's the same command but without a trailing
newline:

dima@shorty:~$ echo -n -e "\033[31mtest\033[39m"
testdima@shorty:~$ <------ whole thing is blue

So the prompt emits the correct codes (verified with strace), but since
it has no trailing newline, it is rendered wrong, just like the "test"
string above. This is something that worked in emacs23.

Thanks.


In GNU Emacs 24.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2)
 of 2012-06-29 on zelenka, modified by Debian
 (emacs-snapshot package, version 2:20120629-1)
Windowing system distributor `The X.Org Foundation', version 11.0.11201902
Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--host' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.1.50/site-lisp:/usr/share/emacs/site-lisp'
 '--without-compress-info' '--with-crt-dir=/usr/lib/x86_64-linux-gnu/'
 '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes'
 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu'
 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g
 -Wl,--as-needed -znocombreloc' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_ALL: C
  value of $LANG: C
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Shell

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x s h e l l <return> <down-mouse-2> <mouse-2> C-x 
C-x C-w C-y <home> <return> <C-up> <home> <C-right> 
SPC - n <return> <return> M-x r e p o r t <tab> <r
eturn>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set [2 times]
History item: 1

Load-path shadows:
/usr/share/emacs/24.1.50/site-lisp/cscope/xcscope hides /usr/share/emacs/site-lisp/xcscope
/usr/share/emacs/24.1.50/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs/24.1.50/site-lisp/easypg/epg hides /usr/share/emacs/24.1.50/lisp/epg
/usr/share/emacs/24.1.50/site-lisp/easypg/epa-dired hides /usr/share/emacs/24.1.50/lisp/epa-dired
/usr/share/emacs/24.1.50/site-lisp/easypg/epg-config hides /usr/share/emacs/24.1.50/lisp/epg-config
/usr/share/emacs/24.1.50/site-lisp/easypg/epa hides /usr/share/emacs/24.1.50/lisp/epa
/usr/share/emacs/24.1.50/site-lisp/easypg/epa-file hides /usr/share/emacs/24.1.50/lisp/epa-file
/usr/share/emacs/24.1.50/site-lisp/easypg/epa-mail hides /usr/share/emacs/24.1.50/lisp/epa-mail
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-list hides /usr/share/emacs/24.1.50/lisp/org/org-list
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-screen hides /usr/share/emacs/24.1.50/lisp/org/ob-screen
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-protocol hides /usr/share/emacs/24.1.50/lisp/org/org-protocol
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-footnote hides /usr/share/emacs/24.1.50/lisp/org/org-footnote
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-docview hides /usr/share/emacs/24.1.50/lisp/org/org-docview
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-pcomplete hides /usr/share/emacs/24.1.50/lisp/org/org-pcomplete
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-sh hides /usr/share/emacs/24.1.50/lisp/org/ob-sh
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-irc hides /usr/share/emacs/24.1.50/lisp/org/org-irc
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-maxima hides /usr/share/emacs/24.1.50/lisp/org/ob-maxima
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-mac-message hides /usr/share/emacs/24.1.50/lisp/org/org-mac-message
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-bibtex hides /usr/share/emacs/24.1.50/lisp/org/org-bibtex
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-asymptote hides /usr/share/emacs/24.1.50/lisp/org/ob-asymptote
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-bbdb hides /usr/share/emacs/24.1.50/lisp/org/org-bbdb
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob hides /usr/share/emacs/24.1.50/lisp/org/ob
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-lilypond hides /usr/share/emacs/24.1.50/lisp/org/ob-lilypond
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-exp-blocks hides /usr/share/emacs/24.1.50/lisp/org/org-exp-blocks
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-icalendar hides /usr/share/emacs/24.1.50/lisp/org/org-icalendar
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-gnuplot hides /usr/share/emacs/24.1.50/lisp/org/ob-gnuplot
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-src hides /usr/share/emacs/24.1.50/lisp/org/org-src
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-w3m hides /usr/share/emacs/24.1.50/lisp/org/org-w3m
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-css hides /usr/share/emacs/24.1.50/lisp/org/ob-css
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-ledger hides /usr/share/emacs/24.1.50/lisp/org/ob-ledger
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-wl hides /usr/share/emacs/24.1.50/lisp/org/org-wl
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-mew hides /usr/share/emacs/24.1.50/lisp/org/org-mew
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-mks hides /usr/share/emacs/24.1.50/lisp/org/org-mks
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-python hides /usr/share/emacs/24.1.50/lisp/org/ob-python
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-shen hides /usr/share/emacs/24.1.50/lisp/org/ob-shen
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-tangle hides /usr/share/emacs/24.1.50/lisp/org/ob-tangle
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-haskell hides /usr/share/emacs/24.1.50/lisp/org/ob-haskell
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-eval hides /usr/share/emacs/24.1.50/lisp/org/ob-eval
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-rmail hides /usr/share/emacs/24.1.50/lisp/org/org-rmail
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-habit hides /usr/share/emacs/24.1.50/lisp/org/org-habit
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-exp hides /usr/share/emacs/24.1.50/lisp/org/org-exp
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-mscgen hides /usr/share/emacs/24.1.50/lisp/org/ob-mscgen
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-gnus hides /usr/share/emacs/24.1.50/lisp/org/org-gnus
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-plantuml hides /usr/share/emacs/24.1.50/lisp/org/ob-plantuml
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-ascii hides /usr/share/emacs/24.1.50/lisp/org/org-ascii
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-octave hides /usr/share/emacs/24.1.50/lisp/org/ob-octave
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-entities hides /usr/share/emacs/24.1.50/lisp/org/org-entities
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-dot hides /usr/share/emacs/24.1.50/lisp/org/ob-dot
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-latex hides /usr/share/emacs/24.1.50/lisp/org/ob-latex
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-java hides /usr/share/emacs/24.1.50/lisp/org/ob-java
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-indent hides /usr/share/emacs/24.1.50/lisp/org/org-indent
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-table hides /usr/share/emacs/24.1.50/lisp/org/org-table
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-eshell hides /usr/share/emacs/24.1.50/lisp/org/org-eshell
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-org hides /usr/share/emacs/24.1.50/lisp/org/ob-org
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-exp hides /usr/share/emacs/24.1.50/lisp/org/ob-exp
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-keys hides /usr/share/emacs/24.1.50/lisp/org/ob-keys
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-install hides /usr/share/emacs/24.1.50/lisp/org/org-install
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-ref hides /usr/share/emacs/24.1.50/lisp/org/ob-ref
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-id hides /usr/share/emacs/24.1.50/lisp/org/org-id
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-sass hides /usr/share/emacs/24.1.50/lisp/org/ob-sass
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-picolisp hides /usr/share/emacs/24.1.50/lisp/org/ob-picolisp
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-sqlite hides /usr/share/emacs/24.1.50/lisp/org/ob-sqlite
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-xoxo hides /usr/share/emacs/24.1.50/lisp/org/org-xoxo
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-calc hides /usr/share/emacs/24.1.50/lisp/org/ob-calc
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-mhe hides /usr/share/emacs/24.1.50/lisp/org/org-mhe
/usr/share/emacs/24.1.50/site-lisp/org-mode/org hides /usr/share/emacs/24.1.50/lisp/org/org
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-docbook hides /usr/share/emacs/24.1.50/lisp/org/org-docbook
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-mouse hides /usr/share/emacs/24.1.50/lisp/org/org-mouse
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-html hides /usr/share/emacs/24.1.50/lisp/org/org-html
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-ditaa hides /usr/share/emacs/24.1.50/lisp/org/ob-ditaa
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-ocaml hides /usr/share/emacs/24.1.50/lisp/org/ob-ocaml
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-lisp hides /usr/share/emacs/24.1.50/lisp/org/ob-lisp
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-jsinfo hides /usr/share/emacs/24.1.50/lisp/org/org-jsinfo
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-odt hides /usr/share/emacs/24.1.50/lisp/org/org-odt
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-macs hides /usr/share/emacs/24.1.50/lisp/org/org-macs
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-freemind hides /usr/share/emacs/24.1.50/lisp/org/org-freemind
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-archive hides /usr/share/emacs/24.1.50/lisp/org/org-archive
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-latex hides /usr/share/emacs/24.1.50/lisp/org/org-latex
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-crypt hides /usr/share/emacs/24.1.50/lisp/org/org-crypt
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-emacs-lisp hides /usr/share/emacs/24.1.50/lisp/org/ob-emacs-lisp
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-clojure hides /usr/share/emacs/24.1.50/lisp/org/ob-clojure
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-lparse hides /usr/share/emacs/24.1.50/lisp/org/org-lparse
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-colview hides /usr/share/emacs/24.1.50/lisp/org/org-colview
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-taskjuggler hides /usr/share/emacs/24.1.50/lisp/org/org-taskjuggler
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-matlab hides /usr/share/emacs/24.1.50/lisp/org/ob-matlab
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-faces hides /usr/share/emacs/24.1.50/lisp/org/org-faces
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-table hides /usr/share/emacs/24.1.50/lisp/org/ob-table
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-capture hides /usr/share/emacs/24.1.50/lisp/org/org-capture
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-js hides /usr/share/emacs/24.1.50/lisp/org/ob-js
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-mobile hides /usr/share/emacs/24.1.50/lisp/org/org-mobile
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-agenda hides /usr/share/emacs/24.1.50/lisp/org/org-agenda
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-sql hides /usr/share/emacs/24.1.50/lisp/org/ob-sql
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-special-blocks hides /usr/share/emacs/24.1.50/lisp/org/org-special-blocks
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-beamer hides /usr/share/emacs/24.1.50/lisp/org/org-beamer
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-fortran hides /usr/share/emacs/24.1.50/lisp/org/ob-fortran
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-timer hides /usr/share/emacs/24.1.50/lisp/org/org-timer
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-perl hides /usr/share/emacs/24.1.50/lisp/org/ob-perl
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-R hides /usr/share/emacs/24.1.50/lisp/org/ob-R
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-ctags hides /usr/share/emacs/24.1.50/lisp/org/org-ctags
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-ruby hides /usr/share/emacs/24.1.50/lisp/org/ob-ruby
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-compat hides /usr/share/emacs/24.1.50/lisp/org/org-compat
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-feed hides /usr/share/emacs/24.1.50/lisp/org/org-feed
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-publish hides /usr/share/emacs/24.1.50/lisp/org/org-publish
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-remember hides /usr/share/emacs/24.1.50/lisp/org/org-remember
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-C hides /usr/share/emacs/24.1.50/lisp/org/ob-C
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-vm hides /usr/share/emacs/24.1.50/lisp/org/org-vm
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-datetree hides /usr/share/emacs/24.1.50/lisp/org/org-datetree
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-awk hides /usr/share/emacs/24.1.50/lisp/org/ob-awk
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-plot hides /usr/share/emacs/24.1.50/lisp/org/org-plot
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-scheme hides /usr/share/emacs/24.1.50/lisp/org/ob-scheme
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-attach hides /usr/share/emacs/24.1.50/lisp/org/org-attach
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-lob hides /usr/share/emacs/24.1.50/lisp/org/ob-lob
/usr/share/emacs/24.1.50/site-lisp/org-mode/ob-comint hides /usr/share/emacs/24.1.50/lisp/org/ob-comint
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-inlinetask hides /usr/share/emacs/24.1.50/lisp/org/org-inlinetask
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-clock hides /usr/share/emacs/24.1.50/lisp/org/org-clock
/usr/share/emacs/24.1.50/site-lisp/org-mode/org-info hides /usr/share/emacs/24.1.50/lisp/org/org-info

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils shell pcomplete comint ansi-color ring
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)





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

* bug#11883: Hints
  2012-07-09  5:29 bug#11883: 24.1.50; shell-mode doesn't colorize the prompt Dima Kogan
@ 2012-11-06 19:12 ` Dima Kogan
  2012-11-09 19:05   ` bug#11883: shell-mode doesn't colorize the prompt Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Dima Kogan @ 2012-11-06 19:12 UTC (permalink / raw)
  To: 11883

Looking around, I discovered that this regression was introduced in

http://git.savannah.gnu.org/cgit/emacs.git/commit/lisp/ansi-color.el?id=cd49cea06bb1c492d4d024889f3f320bf4c9b507

Furthermore, starting from the recent sources, this regression can be fixed by
making the following changes to comint.el:

1. Not inheriting the comint-highlight-prompt face from minibuffer-prompt
2. In comint-output-filter, changing

		    ;; Just move an existing overlay
                    (move-overlay comint-last-prompt-overlay
				  prompt-start (point))

to

		    (move-overlay (copy-overlay comint-last-prompt-overlay)
				  prompt-start (point))


Note that I don't understand this code sufficiently well to claim this as a fix,
but hopefully this will be helpful for the maintainer to make the final fix.

dima





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

* bug#11883: shell-mode doesn't colorize the prompt
  2012-11-06 19:12 ` bug#11883: Hints Dima Kogan
@ 2012-11-09 19:05   ` Stefan Monnier
  2021-07-15 23:06     ` bug#11883: 24.1.50; " Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2012-11-09 19:05 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 11883

severity 11883 wishlist
thanks

The behavior you see is due to the following:
- the prompt is highlighted with an overlay that uses
  a comint-highlight-prompt face.
- "the prompt" is determined dynamically as "the last
  non-line-terminated output of the process".
- the ansi-color escapes used to be applied using overlays but are now
  applied using text-properties.

When you use ansi escapes to color the prompt, you clearly have
a conflict with the comint-highlight-prompt face that is to be used for
the prompt.

If you do C-u C-x = on the "t" of "test" in your test case, you'll see
that it does have a `font-lock-face' text-property that stipulates the
use of a red foreground, but the overlay takes precedence.

Emacs-23's use of overlays for ansi colors worked better in this
respect, because those overlays took precedence by virtue of
being smaller.

You can by revert to the Emacs-23 behavior with the following hack:

   (add-hook 'shell-mode-hook
             (lambda ()
               (kill-local-variable 'ansi-color-apply-face-function)))

But the reason Emacs-24 stopped using overlays is because they can slow
things down significantly if you have many such colored chunks and your
shell buffer grows large.


        Stefan


PS: Yes, that's an implementation defect in Emacs which should use more
efficient algorithms for its overlays.  I have a pretty good idea how to
fix this, so if someone's interested, I'd be happy to help them write
a patch for it.





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

* bug#11883: 24.1.50; shell-mode doesn't colorize the prompt
  2012-11-09 19:05   ` bug#11883: shell-mode doesn't colorize the prompt Stefan Monnier
@ 2021-07-15 23:06     ` Lars Ingebrigtsen
  2021-07-30 12:04       ` Lars Ingebrigtsen
  2021-12-19  9:48       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-15 23:06 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 11883, Dima Kogan

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

> The behavior you see is due to the following:
> - the prompt is highlighted with an overlay that uses
>   a comint-highlight-prompt face.
> - "the prompt" is determined dynamically as "the last
>   non-line-terminated output of the process".
> - the ansi-color escapes used to be applied using overlays but are now
>   applied using text-properties.
>
> When you use ansi escapes to color the prompt, you clearly have
> a conflict with the comint-highlight-prompt face that is to be used for
> the prompt.

The following simple tweak seems to fix the reported issue:

diff --git a/lisp/comint.el b/lisp/comint.el
index 9e406614b9..3dfb269de4 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2157,9 +2157,9 @@ comint-output-filter
 		 'comint-highlight-prompt))
 	      (setq comint-last-prompt
 		    (cons (copy-marker prompt-start) (point-marker)))
-	      (font-lock-prepend-text-property prompt-start (point)
-					       'font-lock-face
-					       'comint-highlight-prompt)
+	      (font-lock-append-text-property prompt-start (point)
+					      'font-lock-face
+					      'comint-highlight-prompt)
 	      (add-text-properties prompt-start (point)
 	                           `(rear-nonsticky
 	                             ,comint--prompt-rear-nonsticky)))

That is, we don't overwrite the ANSI face properties.

I guess this might also avoid overwriting properties in prompts that use
ANSI codes?  Which might also be nice.

Would this regress anything?  Anybody got an opinion?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#11883: 24.1.50; shell-mode doesn't colorize the prompt
  2021-07-15 23:06     ` bug#11883: 24.1.50; " Lars Ingebrigtsen
@ 2021-07-30 12:04       ` Lars Ingebrigtsen
  2021-07-30 18:38         ` Dima Kogan
  2021-12-19  9:48       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-30 12:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 11883, Dima Kogan

Lars Ingebrigtsen <larsi@gnus.org> writes:

> The following simple tweak seems to fix the reported issue:

[...]

> Would this regress anything?  Anybody got an opinion?

Nobody had in two weeks, so I've now pushed the change.  If it leads to
problems, we'll have to reconsider.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#11883: 24.1.50; shell-mode doesn't colorize the prompt
  2021-07-30 12:04       ` Lars Ingebrigtsen
@ 2021-07-30 18:38         ` Dima Kogan
  0 siblings, 0 replies; 8+ messages in thread
From: Dima Kogan @ 2021-07-30 18:38 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 11883, Stefan Monnier

Thanks much. I can now remove that 9-year-old workaround from my .emacs :)





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

* bug#11883: 24.1.50; shell-mode doesn't colorize the prompt
  2021-07-15 23:06     ` bug#11883: 24.1.50; " Lars Ingebrigtsen
  2021-07-30 12:04       ` Lars Ingebrigtsen
@ 2021-12-19  9:48       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-12-19 11:02         ` Lars Ingebrigtsen
  1 sibling, 1 reply; 8+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-12-19  9:48 UTC (permalink / raw)
  To: 11883

[-- Attachment #1: Type: text/plain, Size: 2430 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>
>> The behavior you see is due to the following:
>> - the prompt is highlighted with an overlay that uses
>>   a comint-highlight-prompt face.
>> - "the prompt" is determined dynamically as "the last
>>   non-line-terminated output of the process".
>> - the ansi-color escapes used to be applied using overlays but are now
>>   applied using text-properties.
>>
>> When you use ansi escapes to color the prompt, you clearly have
>> a conflict with the comint-highlight-prompt face that is to be used for
>> the prompt.
>
> The following simple tweak seems to fix the reported issue:
>
> diff --git a/lisp/comint.el b/lisp/comint.el
> index 9e406614b9..3dfb269de4 100644
> --- a/lisp/comint.el
> +++ b/lisp/comint.el
> @@ -2157,9 +2157,9 @@ comint-output-filter
>  		 'comint-highlight-prompt))
>  	      (setq comint-last-prompt
>  		    (cons (copy-marker prompt-start) (point-marker)))
> -	      (font-lock-prepend-text-property prompt-start (point)
> -					       'font-lock-face
> -					       'comint-highlight-prompt)
> +	      (font-lock-append-text-property prompt-start (point)
> +					      'font-lock-face
> +					      'comint-highlight-prompt)
>  	      (add-text-properties prompt-start (point)
>  	                           `(rear-nonsticky
>  	                             ,comint--prompt-rear-nonsticky)))
>

Sorry for late reply. I believe an analogous change should be made in
the function comint-snapshot-last-prompt:

diff --git a/lisp/comint.el b/lisp/comint.el
index 5f99f560cf..3decb80ff0 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2036,7 +2036,7 @@ comint-snapshot-last-prompt
 Freezes the `font-lock-face' text property in place."
   (when comint-last-prompt
     (with-silent-modifications
-      (font-lock-prepend-text-property
+      (font-lock-append-text-property
        (car comint-last-prompt)
        (cdr comint-last-prompt)
        'font-lock-face 'comint-highlight-prompt))

> That is, we don't overwrite the ANSI face properties.
>
> I guess this might also avoid overwriting properties in prompts that use
> ANSI codes?  Which might also be nice.
>
> Would this regress anything?  Anybody got an opinion?
>
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

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

* bug#11883: 24.1.50; shell-mode doesn't colorize the prompt
  2021-12-19  9:48       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-12-19 11:02         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-19 11:02 UTC (permalink / raw)
  To: miha; +Cc: 11883

miha@kamnitnik.top writes:

> Sorry for late reply. I believe an analogous change should be made in
> the function comint-snapshot-last-prompt:

Thanks; applied to master.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-12-19 11:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-09  5:29 bug#11883: 24.1.50; shell-mode doesn't colorize the prompt Dima Kogan
2012-11-06 19:12 ` bug#11883: Hints Dima Kogan
2012-11-09 19:05   ` bug#11883: shell-mode doesn't colorize the prompt Stefan Monnier
2021-07-15 23:06     ` bug#11883: 24.1.50; " Lars Ingebrigtsen
2021-07-30 12:04       ` Lars Ingebrigtsen
2021-07-30 18:38         ` Dima Kogan
2021-12-19  9:48       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-19 11:02         ` Lars Ingebrigtsen

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

	https://git.savannah.gnu.org/cgit/emacs.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).