From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#50207: 28.0.50; ansi-color-compilation-filter and rgrep Date: Thu, 26 Aug 2021 10:07:52 -0700 Message-ID: <9c24f4b0-e7aa-62d3-5737-0edffb8b2501@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30949"; mail-complaints-to="usenet@ciao.gmane.io" To: Manuel Uberti , 50207@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 26 19:22:51 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJJ5W-0007ve-VP for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Aug 2021 19:22:50 +0200 Original-Received: from localhost ([::1]:45998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJJ5V-0005d8-UB for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Aug 2021 13:22:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJIrC-0007Io-Q0 for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 13:08:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJIrC-0003FZ-Hp for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 13:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mJIrC-0000Qi-DK for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 13:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Aug 2021 17:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50207 X-GNU-PR-Package: emacs Original-Received: via spool by 50207-submit@debbugs.gnu.org id=B50207.16299976811646 (code B ref 50207); Thu, 26 Aug 2021 17:08:02 +0000 Original-Received: (at 50207) by debbugs.gnu.org; 26 Aug 2021 17:08:01 +0000 Original-Received: from localhost ([127.0.0.1]:50313 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJIrB-0000QS-Gb for submit@debbugs.gnu.org; Thu, 26 Aug 2021 13:08:01 -0400 Original-Received: from mail-pg1-f169.google.com ([209.85.215.169]:35658) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJIr8-0000QA-Jw for 50207@debbugs.gnu.org; Thu, 26 Aug 2021 13:08:00 -0400 Original-Received: by mail-pg1-f169.google.com with SMTP id e7so3645830pgk.2 for <50207@debbugs.gnu.org>; Thu, 26 Aug 2021 10:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=+49yq0dLQrQ5rRlcfIyXPS67S/w417D+lMg4Kw22ih4=; b=iaqNtjLs9uTze1lU2Id5ytAnn7vIF3MaGaIK5m+IyuAXIZ8Xuux8ULtg3f3c4NCign bsboEW6WtasK6M7BgJ1M0WfL5URx00f8gWkYOBf4ZbEwlOFd5dAOQYVg+3mFu8/hkTU5 g+Ydo6/WvhfiBgmcsL+4ImHCnRTaQE228LKAE1Om3GuCChnWcCtIkAEVcwtY8aFWflCR +dvyVvAXP0BoiMAb9elLKPXwlGtY6tSohf6Xox9WLCmqzN997ag78PwXK1g1O7yjxaEv 1SHHGyQ0QYMbHiSq+436BqQEE7MMqeye/TvXIir3qMyssCbJ2Lp/mxql1yNY8dsk0FYi hXHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=+49yq0dLQrQ5rRlcfIyXPS67S/w417D+lMg4Kw22ih4=; b=dweKVRDwxePg81KP+9k6zqy2Gdf4f1c4GVWmxGTjmJWjCTyv0br4PjiglrKor+m6uM C7BpVvthTHMqPlrIpAdFtg1ls1xcGOaxhe2R+hfeVNJTbzCU6C/O1fvccHoLsBTIMeSE XejNe/osa//U+dYMJXI8Ef202U2xUw2jl6wQT+/5Y1htuBH9lnabCnNM2tbvTxFqAJem ojWG62qKmN1H+3/jNzW0zvDjLqOcLW6svN6ZSjRmSPqqwvLlsdF/ZzaA594WSEGhho+M zXWbXDGG/v6uloyBWPvAGdnXXmAJ5IAOiOjU4qIpySZ7Kgio2zLpWE5sH2zctaXJNyFX owuQ== X-Gm-Message-State: AOAM532sTgbCyTnI9Dq69IfWwhqr/ozctFgDmH6Ipsna1k4hOJ3S35i8 Cq2Q9bq73gRNUTjzra3qMI05UzbxTxs= X-Google-Smtp-Source: ABdhPJzqITiQzzKOmU02YJB/Q8+nXm29oHCnZUbRseZhn/WoTU6F6FfgNvx0fysxDGg9ax8XGfm8Og== X-Received: by 2002:aa7:8d46:0:b029:3cd:c2fd:fea5 with SMTP id s6-20020aa78d460000b02903cdc2fdfea5mr4672687pfe.31.1629997672570; Thu, 26 Aug 2021 10:07:52 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id t15sm4078122pgk.13.2021.08.26.10.07.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 10:07:51 -0700 (PDT) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:212739 Archived-At: On 8/25/2021 10:57 PM, Manuel Uberti wrote: > From 'emacs -Q', this is what I did: > > - (add-hook 'compilation-filter-hook #'ansi-color-compilation-filter) > - M-x rgrep RET > - setq RET > - RET > - ~/emacs RET (this is where I keep the entire Emacs source code) > > As you can see from the attached image, some of the results are red and > some are not. This is not happening without ansi-color-compilation-filter.y I encountered this a bit ago, and did a bit of diagnosis, but it ended up on my back-burner. I think the issue is due to how the compilation-filter-hooks for grep and ansi-color interact. `grep-filter' is fairly simple and wants to see both the start and end of an ANSI-colorized region, so it "rewinds" to the beginning of a line every time it's called. `ansi-color-compilation-filter', on the other hand, is smart enough to handle the case where it only sees the start of a colorized region in one call, and the end in the next call (see `ansi-color-context' for details). These interact poorly, since normally `grep-filter' reads all the ANSI escapes, handles the ones it recognizes, and strips the rest, leaving `ansi-color-compilation-filter' with nothing to do. However, when grep's output currently shows the start of a colorized region but not the end, `grep-filter' doesn't touch that, assuming it can come back to it in the next call. By then `ansi-color-compilation-filter' has "stolen" that ANSI escape, confusing `grep-filter'. To solve this, I just turn off `ansi-color-compilation-filter' for grep. When things are working right, it should be a no-op, and when things are working wrong, you see the behavior described in this bug. It might be nice to turn this off automatically though. Right now it's just a sharp corner people can cut themselves on.