From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#7485: 23.2; Fix removing unrecognized ANSI sequences in ansi-color-apply Date: Fri, 26 Nov 2010 13:55:16 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1290800234 14505 80.91.229.12 (26 Nov 2010 19:37:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 26 Nov 2010 19:37:14 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: Leo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 26 20:37:10 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PM46T-00017R-Sv for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Nov 2010 20:37:09 +0100 Original-Received: from localhost ([127.0.0.1]:44456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PM46T-0003qQ-4K for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Nov 2010 14:37:05 -0500 Original-Received: from [140.186.70.92] (port=53139 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PM3kw-0002Ll-3E for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2010 14:14:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PM3ku-0000Hx-Jo for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2010 14:14:50 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PM3ku-0000Ht-I7 for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2010 14:14:48 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PM3Mx-0004hz-Gh; Fri, 26 Nov 2010 13:50:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Nov 2010 18:50:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7485 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.129079739818084 (code B ref -1); Fri, 26 Nov 2010 18:50:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Nov 2010 18:49:58 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PM3Mr-0004hd-Bx for submit@debbugs.gnu.org; Fri, 26 Nov 2010 13:49:57 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PM3Mo-0004hS-U1 for submit@debbugs.gnu.org; Fri, 26 Nov 2010 13:49:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PM3S4-00048E-H1 for submit@debbugs.gnu.org; Fri, 26 Nov 2010 13:55:21 -0500 Original-Received: from lists.gnu.org ([199.232.76.165]:39008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PM3S4-00048A-Eq for submit@debbugs.gnu.org; Fri, 26 Nov 2010 13:55:20 -0500 Original-Received: from [140.186.70.92] (port=50908 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PM3S3-00061m-Jt for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2010 13:55:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PM3S2-00047u-At for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2010 13:55:19 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:50847 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PM3S2-00047o-8L for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2010 13:55:18 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgwJAI6R70xFxKB0/2dsb2JhbACiEn1ywCGFRwSEXI1t X-IronPort-AV: E=Sophos;i="4.59,262,1288584000"; d="scan'208";a="83792995" Original-Received: from 69-196-160-116.dsl.teksavvy.com (HELO ceviche.home) ([69.196.160.116]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 26 Nov 2010 13:55:16 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 9A6B5660DC; Fri, 26 Nov 2010 13:55:16 -0500 (EST) In-Reply-To: (Leo's message of "Fri, 26 Nov 2010 14:48:20 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 26 Nov 2010 13:50:03 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:41898 Archived-At: > In ansi-color-apply, (string-match "\033" string start) finds the wrong > portion of context if unrecognized ANSI sequences is not removed before > the match. You mean, because \033 can appear in that unrecognized ANSI sequence? > This can cause, for example, eshell's prompt to disappear if > ansi-color-apply is used in eshell-preoutput-filter-functions. > The attached patch tries to fix this. I don't quite understand your patch. And your saying "tries to fix" doesn't make me more confident. > diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el > index 00162c9..40c0066 100644 > *** a/lisp/ansi-color.el > --- b/lisp/ansi-color.el > *************** > *** 341,352 **** > (put-text-property start (length string) 'ansi-color t string) > (put-text-property start (length string) 'face face string)) > ;; save context, add the remainder of the string to the result > ! (let (fragment) > ! (if (string-match "\033" string start) > (let ((pos (match-beginning 0))) > ! (setq fragment (substring string pos)) > ! (push (substring string start pos) result)) > ! (push (substring string start) result)) > (if (or face fragment) > (setq ansi-color-context (list face fragment)) > (setq ansi-color-context nil))) > --- 341,355 ---- > (put-text-property start (length string) 'ansi-color t string) > (put-text-property start (length string) 'face face string)) > ;; save context, add the remainder of the string to the result > ! (let ((remaining (substring string start)) > ! fragment) > ! (while (string-match ansi-color-drop-regexp remaining) > ! (setq remaining (replace-match "" nil nil remaining))) > ! (if (string-match "\033" remaining) > (let ((pos (match-beginning 0))) > ! (setq fragment (substring remaining pos)) > ! (push (substring remaining 0 pos) result)) > ! (push remaining result)) > (if (or face fragment) > (setq ansi-color-context (list face fragment)) > (setq ansi-color-context nil))) This appears to "drop control sequences" even tho they weren't dropped before, so it does more than "ignore false-positive \033 from unrecognized control sequences". IIUC those unrecognized control sequences are dropped elsewhere, right? So are maybe suggesting that they are currently not dropped at the right time (i.e. dropped too late), or that the \033 handling takes place too early, or that we currently forget to drop those control sequences or ... ? Stefan