From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.bugs Subject: bug#71698: 29.3; comint--intersect-regions fontifies some output using input function Date: Fri, 21 Jun 2024 13:11:58 -0400 Message-ID: <277CDEDD-3D35-4ACC-A94A-D733AF1B6A10@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7219"; mail-complaints-to="usenet@ciao.gmane.io" Cc: miha@kamnitnik.top To: 71698@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 21 20:13:23 2024 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 1sKilH-0001ld-Ge for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Jun 2024 20:13:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKilA-0003x3-Sf; Fri, 21 Jun 2024 14:13:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sKikx-0003vM-R3 for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 14:13:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKikx-0006Xf-JB for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 14:13:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sKikw-0003MN-QL for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 14:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: JD Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jun 2024 18:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71698 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.171899357512847 (code B ref -1); Fri, 21 Jun 2024 18:13:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Jun 2024 18:12:55 +0000 Original-Received: from localhost ([127.0.0.1]:43249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKiko-0003L7-J2 for submit@debbugs.gnu.org; Fri, 21 Jun 2024 14:12:54 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:57290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKikm-0003KE-Cv for submit@debbugs.gnu.org; Fri, 21 Jun 2024 14:12:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sKho6-0005sc-Ka for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 13:12:15 -0400 Original-Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKho4-0004UG-Po for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 13:12:14 -0400 Original-Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-6b06e63d288so9981606d6.0 for ; Fri, 21 Jun 2024 10:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718989930; x=1719594730; darn=gnu.org; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=tpK0wy+mJi54NpKXk9CYDxrHcxRufU77wUeJyKE1v7o=; b=BgK6uDfxnmupfhMF6Uo3SQGwslQBtQ9RKOCTvpgOO2PiDPjGPs0s0HuWDVPytEBkoF mLq0v4x/jOscgi4gzij39ljHHN0T1SGMy1LwHs7Np01884jzb2KDKCipcQEUVRoxTbII izlOzu/zBkId8GynuT58Znv1+KW6PhpHIbIukUm9AJrDaO95wOsvEKRv68GQDlPPGH2l 8Iz/hdEXtQXteGrCw6U+Ey+W93sbo3PDN2eUyXvmrYzhHArzVGLQaLC/958ko0ZSNTV7 +h837XxfyWWfqoTIhM9xlUoVzjRVnfusMJr7Lnb67Pm424eGa07hjxcRWt9cZUqdxw96 0pEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718989930; x=1719594730; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tpK0wy+mJi54NpKXk9CYDxrHcxRufU77wUeJyKE1v7o=; b=Jeysa7mKhp/77mEXu+SorDcmNQtpfpd6Q4LlhA0/ylf+/5lk+vPaSieCWqpIw2K4n+ kvgfWdkZPD5tD6x78t1X5DXElT+loPm7ib1n/B9JV3gD97OnMSssfwMf8E18GmWa5YuF +Pp5ISk9O91ES8G2EMsTPuSUA0+51iIARHOamp6vRwel1WG9yr7y6VJTD4GjOHV+2tjX mmR5zq9+D6D4Pv5igz3yjI9f2PfoT7Tb3aAkZNLg4Wq72ZR+9eSV9DM6cWgQQBBVFaqP u72/Pob/cj0pndM37dG+i2OXH3OV2kdQdF0XhpC5dnuagYQ6Zc0t4beOo69EWW+pluEc JqfQ== X-Gm-Message-State: AOJu0YyfpI7u5UR+4nm3TQ2N2fRMak6rDbWgIKNSW1y9x3ygcZ2bckmb +mFeA3J8xjlQHlF9b2n+qoWQVQvTzKHiOf/8camN/LGVAs9TV4fjJGyFZg== X-Google-Smtp-Source: AGHT+IHAuKamEt77WCr0h3kaABE3+ZuEFcS6hvCRSO2t8Mt/HuHCZGCYAZQVzK/0HsD2ZDmwYoVtrQ== X-Received: by 2002:a0c:e610:0:b0:6b5:6a1:f894 with SMTP id 6a1803df08f44-6b506a1fce4mr80282336d6.3.1718989929961; Fri, 21 Jun 2024 10:12:09 -0700 (PDT) Original-Received: from smtpclient.apple ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b51ef30d30sm10579066d6.93.2024.06.21.10.12.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jun 2024 10:12:09 -0700 (PDT) X-Mailer: Apple Mail (2.3774.600.62) Received-SPF: pass client-ip=2607:f8b0:4864:20::f29; envelope-from=jdtsmith@gmail.com; helo=mail-qv1-xf29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287626 Archived-At: This relates to bug#51940: 29.0.50; [PATCH] Fontification and = indentation in M-x shell. I found a tiny bug in the introduced command = `comint--intersect-regions'. It pertains to the "field-expansion" in = the following section, which is responsible for narrowing to alternating = regions of input and output: (let ((beg2 beg1) (end2 end1)) (when (=3D beg2 beg) (setq beg2 (field-beginning beg2))) ; <--- bug here (when (=3D end2 end) (setq end2 (field-end end2))) ;; Narrow to the whole field surrounding the region (narrow-to-region beg2 end2)) The nature of the bug is that `field-beginning' is left-associative, = whereas `(get-text-property (point) 'field)` is right associative. You = can demonstrate this to yourself as follows: (progn (insert (concat "\n" (propertize "AAA" 'field 'a) (propertize "B" = 'field 'b) (propertize "CCC" 'field 'c))) (goto-char (- (point) 4)) ; cursor on 'B' (list (get-text-property (point) 'field) (field-beginning) (field-end) (buffer-substring-no-properties (field-beginning) (field-end)))) ;; gives: (b 356 359 "AAA") So on the line: (setq beg2 (field-beginning beg2))) ; <--- bug here if beg is at the first character of its field, `field-beginning` will = actually return the start of the prior field. This leads to = `comint--intersect-regions' unwittingly including `output' field text in = its input fontification narrowing. I noticed this in a new python = interactive mode I'm working on: the prompt itself (i.e. output) was = being partially fontified by python-mode. I believe the correct fix is: (setq beg2 (field-beginning (1+ beg2)))) This takes care of the problem here, even for single-character fields = (like `boundary'). We know (< beg1 end) from the loop condition, so = it's safe to increment beg2. --- /var/folders/by/19mt78cj63v5_tslqh826g7w0000gn/T/jka-comrWKsIJ = 2024-06-21 13:08:59 +++ = /var/folders/by/19mt78cj63v5_tslqh826g7w0000gn/T/buffer-content-Q8dmID = 2024-06-21 13:08:59 @@ -4122,7 +4122,7 @@ (let ((beg2 beg1) (end2 end1)) (when (=3D beg2 beg) - (setq beg2 (field-beginning beg2))) + (setq beg2 (field-beginning (1+ beg2)))) (when (=3D end2 end) (setq end2 (field-end end2))) ;; Narrow to the whole field surrounding the region