unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dima Kogan <dima@secretsauce.net>
To: Wolfgang Jenkner <wjenkner@inode.at>
Cc: 12792@debbugs.gnu.org
Subject: bug#12792: 24.2.50; shell-mode renders all its output in a yellow face
Date: Sun, 4 Nov 2012 00:45:57 -0700	[thread overview]
Message-ID: <20121104004557.00fb50a5@shorty.local> (raw)
In-Reply-To: <85hap6yre0.fsf@iznogoud.viz>

> On Sun, 04 Nov 2012 04:27:35 +0100
> Wolfgang Jenkner <wjenkner@inode.at> wrote:
>
> On Sat, Nov 03 2012, Wolfgang Jenkner wrote:
> 
> > On Sat, Nov 03 2012, Eli Zaretskii wrote:
> 
> >> SGR parameter 39 means go back to the default foreground color.  How
> >> can ansi-color not support it and still be useful?
> 
> > I'll fix this omission if nobody beats me to it.
> 
> Here's a rewrite of `ansi-color-apply-sequence' which implements SGR
> codes 39 and 49.  It's straightforward but, sadly, uses side-effects all
> over the place.  At this point, however, I'd just like to know if its
> behaviour meets everybody's expectations, so please test it a bit.
> 
> Wolfgang
> 
> (defun ansi-color-apply-sequence (escape-sequence codes)
>   "Apply ESCAPE-SEQ to CODES and return the new list of codes.
> 
> ESCAPE-SEQ is an escape sequence parsed by `ansi-color-parse-sequence'.
> 
> For each new code, the following happens: if it is 1-7, add it to
> the list of codes; if it is 21-25 or 27, delete appropriate
> parameters from the list of codes; if it is 30-37 resp. 39, the
> foreground color code is replaced or added resp. deleted; if it
> is 40-47 resp. 49, the background color code is replaced or added
> resp. deleted; any other code is discarded together with the old
> codes.  Finally, the so changed list of codes is returned."
>   (let ((new-codes (ansi-color-parse-sequence escape-sequence))
> 	(fg (and codes (>= (car codes) 30) (<= (car codes) 37)
> 		 (pop codes)))
> 	(bg (and codes (>= (car codes) 40) (<= (car codes) 47)
> 		 (pop codes))))
>     (while new-codes
>       (let ((new (pop new-codes)))
> 	(cond ((and (>= new 1) (<= new 7))
> 	       (unless (memq new codes)
> 		 (push new codes)))
> 	      ((and (= new 22)
> 		    (setq codes (remq 1 codes))
> 		    nil))
> 	      ((and (= new 25)
> 		    (setq codes (remq 6 codes))
> 		    nil))
> 	      ;; The standard says `21 doubly underlined' while
> 	      ;; http://en.wikipedia.org/wiki/ANSI_escape_code claims
> 	      ;; `21 Bright/Bold: off or Underline: Double'.
> 	      ((and (>= new 21) (<= new 27) (/= new 26))
> 	       (setq codes (remq (- new 20) codes)))
> 	      ((and (>= new 30) (<= new 37))
> 	       (setq fg new))
> 	      ((= new 39)
> 	       (setq fg nil))
> 	      ((and (>= new 40) (<= new 47))
> 	       (setq bg new))
> 	      ((= new 49)
> 	       (setq bg nil))
> 	      (t
> 	       (setq codes nil fg nil bg nil)))))
>     (when bg
>       (push bg codes))
>     (when fg
>       (push fg codes))
>     codes))

I ran a test:

1. I start an 'emacs -Q' with the latest ansi-colors.el
2. I evaluate the defun you pasted
3. M-x shell
4. I run some commands in the shell


Results:

1. The prompt is still not colored at all even though it should be.

2. Everything is still yellow with a 'nil' face UNTIL something with ansi color
   codes is encountered. At that point correct coloring resumes, except for the
   prompt. The prompt also doesn't count as encountering ansi colors.

Are you not able to reproduce this? My setup isn't particularly special.





  reply	other threads:[~2012-11-04  7:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-03  8:55 bug#12792: 24.2.50; shell-mode renders all its output in a yellow face Dima Kogan
2012-11-03 11:16 ` Chong Yidong
2012-11-03 18:08   ` Dima Kogan
2012-11-03 15:37 ` Wolfgang Jenkner
2012-11-03 16:32   ` Eli Zaretskii
2012-11-03 17:59     ` Wolfgang Jenkner
2012-11-04  3:27       ` Wolfgang Jenkner
2012-11-04  7:45         ` Dima Kogan [this message]
2012-11-04 13:49           ` Wolfgang Jenkner
2012-11-04 20:24             ` Dima Kogan
2012-11-04 23:39               ` Wolfgang Jenkner
2012-11-05  3:23                 ` Dima Kogan
2012-11-05 15:00                   ` Wolfgang Jenkner
2012-11-05 15:25                     ` Wolfgang Jenkner
2012-11-05 23:57                     ` Dima Kogan
2012-11-06  1:24                       ` Wolfgang Jenkner
2012-11-06  1:31                         ` Dima Kogan
2012-11-09  1:50                           ` Wolfgang Jenkner
2012-11-09 17:30                             ` Stefan Monnier
2012-11-09 18:20                               ` Wolfgang Jenkner
2012-11-09 20:37                                 ` Stefan Monnier
2012-11-17 15:21 ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121104004557.00fb50a5@shorty.local \
    --to=dima@secretsauce.net \
    --cc=12792@debbugs.gnu.org \
    --cc=wjenkner@inode.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).