From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs 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 Message-ID: <20121104004557.00fb50a5@shorty.local> References: <871ugbxdyr.fsf@secretsauce.net> <85r4oazoh4.fsf@iznogoud.viz> <83y5ii4pfw.fsf@gnu.org> <85d2zuzhxe.fsf@iznogoud.viz> <85hap6yre0.fsf@iznogoud.viz> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1352015230 26409 80.91.229.3 (4 Nov 2012 07:47:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 4 Nov 2012 07:47:10 +0000 (UTC) Cc: 12792@debbugs.gnu.org To: Wolfgang Jenkner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 04 08:47:19 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 1TUuvN-0007Hj-NU for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Nov 2012 08:47:17 +0100 Original-Received: from localhost ([::1]:39949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUuvE-0004nW-Us for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Nov 2012 02:47:08 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:50693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUuvC-0004nP-Gj for bug-gnu-emacs@gnu.org; Sun, 04 Nov 2012 02:47:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUuvB-0005Hp-A5 for bug-gnu-emacs@gnu.org; Sun, 04 Nov 2012 02:47:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUuvB-0005Hl-63 for bug-gnu-emacs@gnu.org; Sun, 04 Nov 2012 02:47:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TUuy2-0004hk-SQ for bug-gnu-emacs@gnu.org; Sun, 04 Nov 2012 02:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Nov 2012 07:50: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.135201534418010 (code B ref 12792); Sun, 04 Nov 2012 07:50:02 +0000 Original-Received: (at 12792) by debbugs.gnu.org; 4 Nov 2012 07:49:04 +0000 Original-Received: from localhost ([127.0.0.1]:48027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TUux6-0004gR-7l for submit@debbugs.gnu.org; Sun, 04 Nov 2012 02:49:04 -0500 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:40737) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TUux4-0004g7-KN for 12792@debbugs.gnu.org; Sun, 04 Nov 2012 02:49:03 -0500 Original-Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 80CCD20385; Sun, 4 Nov 2012 02:46:03 -0500 (EST) Original-Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160]) by compute3.internal (MEProxy); Sun, 04 Nov 2012 02:46:03 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=quOwurRThyq5wocGXCq9sIcVrZI=; b=DkEJwInKcUisVraCH4aAaSPbYfF3 LJSbH1xn9yjEx150QVC30PIWXpAMiBuUdppoD6rQjuq56RFe7jiISRO7fo0D9p4e vzA8VflJitKUM0hprey2Z7HTL+Fxyp5sWDUR+FOE0ADUh0OTSNwbL80IbPbR556H AalxikOM/Rvotpg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; s=smtpout; bh=quOwurRThyq5wocGXCq9sI cVrZI=; b=OAqgtgQGx2MTU/O7060NeqJhpWT3hk4kComZEnxqIIBo6yS7QpKcft pfq5Yq5fijHnmhZFdsXAiIxTUFdWILotK7FbMWxCimn1xFf/Rtn2yqFFrEM0DbwZ etLXQa1oe9KXm7lW7pli7IIWn0dGAPnXl7yvqLlwOS1dHrcmm2cZg= X-Sasl-enc: IEFKByX85uut/nJaJICZag328+7orK8LmwRRjXfEIBo8 1352015163 Original-Received: from shorty.local (unknown [76.169.242.46]) by mail.messagingengine.com (Postfix) with ESMTPA id D1E678E04CD; Sun, 4 Nov 2012 02:46:02 -0500 (EST) In-Reply-To: <85hap6yre0.fsf@iznogoud.viz> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) 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:66427 Archived-At: > On Sun, 04 Nov 2012 04:27:35 +0100 > Wolfgang Jenkner 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.