From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wolfgang Jenkner Newsgroups: gmane.emacs.bugs Subject: bug#12792: 24.2.50; shell-mode renders all its output in a yellow face Date: Sun, 04 Nov 2012 04:27:35 +0100 Message-ID: <85hap6yre0.fsf@iznogoud.viz> References: <871ugbxdyr.fsf@secretsauce.net> <85r4oazoh4.fsf@iznogoud.viz> <83y5ii4pfw.fsf@gnu.org> <85d2zuzhxe.fsf@iznogoud.viz> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1351999988 1647 80.91.229.3 (4 Nov 2012 03:33:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 4 Nov 2012 03:33:08 +0000 (UTC) Cc: 12792@debbugs.gnu.org, dima@secretsauce.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 04 04:33:16 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TUqxY-0004qC-KJ for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Nov 2012 04:33:16 +0100 Original-Received: from localhost ([::1]:57499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUqxP-0007Pq-Up for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Nov 2012 23:33:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUqxN-0007Pk-VA for bug-gnu-emacs@gnu.org; Sat, 03 Nov 2012 23:33:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUqxM-0007bG-SI for bug-gnu-emacs@gnu.org; Sat, 03 Nov 2012 23:33:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37635) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUqxM-0007bC-Ou for bug-gnu-emacs@gnu.org; Sat, 03 Nov 2012 23:33:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TUr0D-0006Xh-Sr for bug-gnu-emacs@gnu.org; Sat, 03 Nov 2012 23:36:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <871ugbxdyr.fsf@secretsauce.net> Resent-From: Wolfgang Jenkner Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Nov 2012 03:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12792 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12792-submit@debbugs.gnu.org id=B12792.135200014325122 (code B ref 12792); Sun, 04 Nov 2012 03:36:01 +0000 Original-Received: (at 12792) by debbugs.gnu.org; 4 Nov 2012 03:35:43 +0000 Original-Received: from localhost ([127.0.0.1]:47886 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TUqzu-0006X9-VZ for submit@debbugs.gnu.org; Sat, 03 Nov 2012 23:35:43 -0400 Original-Received: from mx04.lb01.inode.at ([62.99.145.4]:43916 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TUqzs-0006X1-Es for 12792@debbugs.gnu.org; Sat, 03 Nov 2012 23:35:41 -0400 Original-Received: from [91.119.128.247] (port=3424 helo=iznogoud.viz) by smartmx-04.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TUqx0-0003Az-EK; Sun, 04 Nov 2012 04:32:42 +0100 Original-Received: from wolfgang by iznogoud.viz with local (Exim 4.80 (FreeBSD)) (envelope-from ) id 1TUqwy-0000W3-17; Sun, 04 Nov 2012 04:32:40 +0100 User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (berkeley-unix) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:66419 Archived-At: 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))