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: Fri, 09 Nov 2012 02:50:32 +0100 Message-ID: <858vaaq27e.fsf@iznogoud.viz> References: <871ugbxdyr.fsf@secretsauce.net> <85r4oazoh4.fsf@iznogoud.viz> <83y5ii4pfw.fsf@gnu.org> <85d2zuzhxe.fsf@iznogoud.viz> <85hap6yre0.fsf@iznogoud.viz> <20121104004557.00fb50a5@shorty.local> <85txt5eav5.fsf@iznogoud.viz> <20121104122456.3f2c6448@shorty.local> <85sj8prl8d.fsf@iznogoud.viz> <20121104192343.1f243455@shorty.local> <854nl4krvr.fsf@iznogoud.viz> <20121105155711.267e869b@fatty> <85mwyvplpu.fsf@iznogoud.viz> <20121105173150.19d3290c@fatty> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1352471414 32455 80.91.229.3 (9 Nov 2012 14:30:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2012 14:30:14 +0000 (UTC) Cc: 12792@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 09 15:30:24 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 1TWpbA-0006Cb-FG for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Nov 2012 15:30:21 +0100 Original-Received: from localhost ([::1]:55302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWpb1-00025F-4b for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Nov 2012 09:30:11 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWpat-00020W-2V for bug-gnu-emacs@gnu.org; Fri, 09 Nov 2012 09:30:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TWpam-0005B7-1V for bug-gnu-emacs@gnu.org; Fri, 09 Nov 2012 09:30:02 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47100) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWpal-0005B1-Tf for bug-gnu-emacs@gnu.org; Fri, 09 Nov 2012 09:29:55 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TWpas-0001kg-Pf for bug-gnu-emacs@gnu.org; Fri, 09 Nov 2012 09:30:02 -0500 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: Fri, 09 Nov 2012 14:30:02 +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.13524713966694 (code B ref 12792); Fri, 09 Nov 2012 14:30:02 +0000 Original-Received: (at 12792) by debbugs.gnu.org; 9 Nov 2012 14:29:56 +0000 Original-Received: from localhost ([127.0.0.1]:57351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TWpal-0001jv-DD for submit@debbugs.gnu.org; Fri, 09 Nov 2012 09:29:56 -0500 Original-Received: from mx19.lb01.inode.at ([62.99.145.21]:31224 helo=mx.inode.at) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TWpah-0001jl-Bn for 12792@debbugs.gnu.org; Fri, 09 Nov 2012 09:29:53 -0500 Original-Received: from [91.119.128.247] (port=2061 helo=iznogoud.viz) by smartmx-19.inode.at with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1TWpaY-0008CE-Si; Fri, 09 Nov 2012 15:29:42 +0100 Original-Received: from wolfgang by iznogoud.viz with local (Exim 4.80 (FreeBSD)) (envelope-from ) id 1TWpaX-0000qD-ET; Fri, 09 Nov 2012 15:29:41 +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:66689 Archived-At: On Tue, Nov 06 2012, Dima Kogan wrote: >> So, I'd say that the issue at hand is solved. I'll just try to >> rewrite the new ansi-color-apply-sequence in a less ugly way. > > Sounds good. Thanks a lot. I hope the patch below is less ugly and also correct. Perhaps you could try it. Note to the maintainers: This fixes a regression for a feature not actually present in previous versions of emacs ;-) 2012-11-08 Wolfgang Jenkner * ansi-color.el (ansi-color-apply-sequence): Implement SGR codes 39 and 49 (bug#12792). Also, restore the behavior of revisions prior to 109621, where unimplemented codes are treated like code 0. === modified file 'lisp/ansi-color.el' --- lisp/ansi-color.el 2012-09-25 04:13:02 +0000 +++ lisp/ansi-color.el 2012-11-09 00:19:00 +0000 @@ -534,34 +534,39 @@ ESCAPE-SEQ is an escape sequence parsed by `ansi-color-parse-sequence'. -If the new codes resulting from ESCAPE-SEQ start with 0, then the -old codes are discarded and the remaining new codes are -processed. Otherwise, for each new code: if it is 21-25 or 27-29 -delete appropriate parameters from the list of codes; any other -code that makes sense is added to the list of codes. Finally, -the so changed list of codes is returned." +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))) (while new-codes - (setq codes - (let ((new (pop new-codes))) - (cond ((zerop new) - nil) - ((or (<= new 20) - (>= new 30)) - (if (memq new codes) - codes - (cons new codes))) - ;; The standard says `21 doubly underlined' while - ;; http://en.wikipedia.org/wiki/ANSI_escape_code claims - ;; `21 Bright/Bold: off or Underline: Double'. - ((/= new 26) - (remq (- new 20) - (cond ((= new 22) - (remq 1 codes)) - ((= new 25) - (remq 6 codes)) - (t codes)))) - (t codes))))) + (let* ((new (pop new-codes)) + (q (/ new 10))) + (setq codes + (pcase q + (0 (unless (memq new '(0 8 9)) + (cons new (remq new codes)))) + (2 (unless (memq new '(20 26 28 29)) + ;; The standard says `21 doubly underlined' while + ;; http://en.wikipedia.org/wiki/ANSI_escape_code claims + ;; `21 Bright/Bold: off or Underline: Double'. + (remq (- new 20) (pcase new + (22 (remq 1 codes)) + (25 (remq 6 codes)) + (_ codes))))) + ((or 3 4) (let ((r (mod new 10))) + (unless (= r 8) + (let (beg) + (while (and codes (/= q (/ (car codes) 10))) + (push (pop codes) beg)) + (setq codes (nconc (nreverse beg) (cdr codes))) + (if (= r 9) + codes + (cons new codes)))))) + (_ nil))))) codes)) (defun ansi-color-make-color-map ()