From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#27407: 25.2; SGR reset is ignored if it terminates Eshell's output Date: Sat, 17 Jun 2017 14:19:54 -0400 Message-ID: <87a856schh.fsf@users.sourceforge.net> References: <20170617113103.GB7315@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1497723552 17249 195.159.176.226 (17 Jun 2017 18:19:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 17 Jun 2017 18:19:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 27407@debbugs.gnu.org To: Pierre Neidhardt Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 17 20:19:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMIJQ-0004DX-1t for geb-bug-gnu-emacs@m.gmane.org; Sat, 17 Jun 2017 20:19:08 +0200 Original-Received: from localhost ([::1]:35913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMIJV-00021O-Ac for geb-bug-gnu-emacs@m.gmane.org; Sat, 17 Jun 2017 14:19:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMIJN-0001zu-PR for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 14:19:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMIJK-0001R9-LC for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 14:19:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMIJK-0001R4-Dk for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 14:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dMIJK-0002v1-4J for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 14:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2017 18:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27407 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27407-submit@debbugs.gnu.org id=B27407.149772350511177 (code B ref 27407); Sat, 17 Jun 2017 18:19:02 +0000 Original-Received: (at 27407) by debbugs.gnu.org; 17 Jun 2017 18:18:25 +0000 Original-Received: from localhost ([127.0.0.1]:53636 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMIIj-0002u8-CU for submit@debbugs.gnu.org; Sat, 17 Jun 2017 14:18:25 -0400 Original-Received: from mail-io0-f179.google.com ([209.85.223.179]:33422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMIIh-0002tk-K4; Sat, 17 Jun 2017 14:18:23 -0400 Original-Received: by mail-io0-f179.google.com with SMTP id t87so45602455ioe.0; Sat, 17 Jun 2017 11:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=YlIFJcaHDHaN5qk+ipALRrOl//QNqDShveB/+4Wn2zs=; b=DTQOW935x8CK1DlHyMs5K4ARQqgp2Fl8jBwNiCG1cbCYncAJ26q4AC+Gp3t1K+2Bxi 45fDZnIeO4d70xmWihUJMdjFR7MFTglGFAPhv+siwEiZPuH6ooUMwrU9wduOtnPwC7eS WlacdQ6AKo/g68TBXux77o27C7/MfTr7oE5PqSAydn4IS5E4J8H6RCXJ4TcI+FO9eghe lObySZNpfXcglud6TUYYWVwt6rAbvdoxiHuZkylPtsowqzglX6q5PIAMhrP8vnGNCkDn zQzMcXcdAnKtP4xhc8yrGsScm8TDNqAs8NeaduF/v+3v/KQrm3HoeZVGgrzA0WYyXl+T V7DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=YlIFJcaHDHaN5qk+ipALRrOl//QNqDShveB/+4Wn2zs=; b=OAQu6aH+1VBTo8H7V3AfUQR2GU2ejSp8Li0Ol0ma/qaLkwVv203grrhVC+72K74xiM JGFhBwHysM1CSrLckr3H/Vrii3fuAqnvDE2nroLIY0PPh/qD/4cEh5BpyiE/NV8GFHY+ Ep5zrOJxKgFu7sYdbESzS1VTH75Rg9iRu84b5jmJbpbejP0rSnwG5ua2AY+piVg53pV1 lnDniw03eO2LbZ1CPOf4a3PzHIce3pKMEBSbfpBbAzlOOVopGsIuG2vNCyJ9rlI/aPNC jkdPFKI0m9vDnPd2XjOdtiJ6hn85qpO7acrAmSk5U9HuIN98ZnaL0wK2EVLNAQ5HNK5H imRg== X-Gm-Message-State: AKS2vOxZorkTftzDWDuA9Z53YFHQLR9ioW4mt/x1aah0TrbYzcVlTN5D puESTvIyYyCevkNw X-Received: by 10.107.12.142 with SMTP id 14mr15887244iom.214.1497723497709; Sat, 17 Jun 2017 11:18:17 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id b62sm4032916itd.2.2017.06.17.11.18.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Jun 2017 11:18:16 -0700 (PDT) In-Reply-To: <20170617113103.GB7315@gmail.com> (Pierre Neidhardt's message of "Sat, 17 Jun 2017 12:31:03 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:133708 Archived-At: --=-=-= Content-Type: text/plain tags 27407 + patch severity 27407 minor quit Pierre Neidhardt writes: > Steps to reproduce: > > - M-x eshell > - Enter "hello" > > The new prompt becomes yellow. You meant enter the text produced with (insert "echo \"\e[33mhello\e[0m\""). > It does not happen if the SGR reset sequence is not last. > This is fine for instance: > > - echo "hello"X > - echo -n "hello" > > Maybe an off-by-one error in the `ansi-*' function? The escape code is implemented by applying an overlay to the text following it (see `ansi-color-apply-on-region'). The problem seems to be that the reset sequence is translated to no face, so nothing is applied (see `ansi-color-apply-overlay-face'), and the yellow overlay gets extended despite the `ansi-color-freeze-overlay' modification-hook because `eshell-output-filter' (and `eshell-send-input') let-bind `inhibit-modification-hooks'. I'm not sure why `inhibit-modification-hooks' needs to be let-bound at all, but just binding it to nil around string insertion seems to be enough: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Let-ansi-color-overlay-hooks-work-in-eshell-Bug-2.patch Content-Description: patch >From 6e3892b8044fc918a5231a79963d0560adea2403 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 17 Jun 2017 12:06:37 -0400 Subject: [PATCH v1] Let ansi-color overlay hooks work in eshell (Bug#27407) * lisp/ansi-color.el (ansi-color-make-extent): Add `ansi-color-freeze-overlay' to `insert-behind-hooks' as well. * lisp/eshell/esh-mode.el (eshell-output-filter): Let-bind `inhibit-modification-hooks' to nil while inserting the string. --- lisp/ansi-color.el | 1 + lisp/eshell/esh-mode.el | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el index a1b4933175..72d70c2102 100644 --- a/lisp/ansi-color.el +++ b/lisp/ansi-color.el @@ -481,6 +481,7 @@ (defun ansi-color-make-extent (from to &optional object) ;; property to make sure it works. (let ((overlay (make-overlay from to object))) (overlay-put overlay 'modification-hooks '(ansi-color-freeze-overlay)) + (overlay-put overlay 'insert-behind-hooks '(ansi-color-freeze-overlay)) overlay))) (defun ansi-color-freeze-overlay (overlay is-after begin end &optional len) diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 0fd0c18301..0999f9c4a8 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -726,7 +726,9 @@ (defun eshell-output-filter (process string) (setq obeg (+ obeg nchars))) (if (<= (point) oend) (setq oend (+ oend nchars))) - (insert-before-markers string) + ;; Let the ansi-color overlay hooks run. + (let ((inhibit-modification-hooks nil)) + (insert-before-markers string)) (if (= (window-start) (point)) (set-window-start (selected-window) (- (point) nchars))) -- 2.11.1 --=-=-=--