From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Guillaume Brunerie Newsgroups: gmane.emacs.bugs Subject: bug#74415: 29.4; mouse-start-end does not respect syntax-table text properties Date: Mon, 9 Dec 2024 20:21:49 +0100 Message-ID: References: <86cyilj6ks.fsf@gnu.org> <86mshjcpod.fsf@gnu.org> <86seqzisg2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3739"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, 74415@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 10 06:11:22 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 1tKsWo-0000nr-Am for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Dec 2024 06:11:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKsWZ-0005h7-Ro; Tue, 10 Dec 2024 00:11:08 -0500 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 1tKsWW-0005gj-5c for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 00:11:04 -0500 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 1tKsWV-00054C-B1 for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 00:11:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:In-Reply-To:References:MIME-Version:To:Subject; bh=ijo97RbjUEYCrgQw+V6KLzlFIzoUsj6M5sdttHSHmAg=; b=v4v829bcyB+uNzZNXf8WyX5e84JVonCfY1scXrUUSx2fBXEpukPtQrLS1T36ChsPvLM0iJhzy/yzHAZIuJGOW+0+3wSLhlB2R/DFNXxgIhgI7jBdMtxBtd+0xee/3s3vKB7yaCR+mnooMykXqLMvsi7ShwVaa2fD/uN5I1uac2CjZRg1MxpIDp3FAritc+LJGGI4+UuPv9yJingKBmfAK0vW+7CKbU1uGPsI3ENO1/Uq43tWHJJEQHQnLa3uZNAaArqhWc+/Q1AlZrqPFIfIbL0a3Eur7cEkHx0mWIOiISLPgq4fM3mXDItazli6hUKi4FFS/EYvUxGsgISczGFV8A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tKsWV-0003jd-5C for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 00:11:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Guillaume Brunerie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Dec 2024 05:11:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74415 X-GNU-PR-Package: emacs Original-Received: via spool by 74415-submit@debbugs.gnu.org id=B74415.173380743814172 (code B ref 74415); Tue, 10 Dec 2024 05:11:03 +0000 Original-Received: (at 74415) by debbugs.gnu.org; 10 Dec 2024 05:10:38 +0000 Original-Received: from localhost ([127.0.0.1]:56547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKsW3-0003gC-Rv for submit@debbugs.gnu.org; Tue, 10 Dec 2024 00:10:38 -0500 Original-Received: from mail-qt1-f172.google.com ([209.85.160.172]:59552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKjLW-0008FN-2Y for 74415@debbugs.gnu.org; Mon, 09 Dec 2024 14:23:07 -0500 Original-Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-467745731fdso2093251cf.2 for <74415@debbugs.gnu.org>; Mon, 09 Dec 2024 11:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733772120; x=1734376920; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ijo97RbjUEYCrgQw+V6KLzlFIzoUsj6M5sdttHSHmAg=; b=WlfrcH/Y8UIFU7DUtPBf7U/J8k8N0BtMyrq6ilKBLOdQ8zBqHQy/bPLDX8MEngJtyU oobRmz05CCdjZX9XREKCp4Cf/FXvohEX8e+cyt83jb7e56m97HzVNjOjRy2SxlZ8ofTQ 24LezerXpRhc2yHRbq0xau1+KYAUIfybBpWn1X2uPut9rU2IFZltRzHPjWQuf8Km/fu9 Aft7ZndQuu3NL67F+BCuZARw9UFsTEEhJ/rcPr6NbPoltmTl+IgeQQTl25SGsyunF4fh dD1wYuEGsNmqBgMCgpnXpuT8phdZXVHjhLvuF+hwq4GdD2yFsg0Y6zPowaSRR+EOi2CR 9eIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733772120; x=1734376920; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ijo97RbjUEYCrgQw+V6KLzlFIzoUsj6M5sdttHSHmAg=; b=f8/PyNTjkbrRQ/1No1ScxVnadtqMm1gVBYz7YL58kIEmskOgcoAwKjDjRqOHfoHsIl TlrR6SfxirO/i2BODyjGs452+2xKxnRCRRpx8KUD3JlM/Ntb/pI3OUU0oYrxBZiL186X pW0PI35LOy0Hh3tKg7wVrTGCq+w9P47P7ZaYIc/tPNXiAq1gIdwO22FcNx1Iszz3UVyW ZNHqygvNMiXrJT0Rq/qcjlFzfMiBT0u/3b8GtRGeEA+tIWrMqxFQeHT9E+3S0bMBWcXc t3CcvwTD6ASUyAuuBLyYu5G4oS5JuAz7JHiitmBAAI9o8RSNPTzuTtWlyaD1Ga2x+exn i3rw== X-Forwarded-Encrypted: i=1; AJvYcCWRSg54fNThBMpyl4XurDzqvM8b0J8cBRGzgDP9JXWN6J98RqHqrQpWayttaxJaXH8BgPAMIw==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyW8iW5ZbOM4NiCWliB1McmjRu0XZSJSQ8Wmq4SxvqfdwC+QBkt kveu/kWfye+Ph1hOw6t3FNzca8W2UuHnYsF/961bPZl873ob/zha0xeqfQ3BYnA/Q7/Winwo3AC WB+DwglqbC8MBjKGnDpP1yNYoKg== X-Gm-Gg: ASbGncufYniIjbZ7Ku3eUDDrfZtzmA6eP876FPvWbyOPj4zb3DPzbF+cUngN8HUaGjn upNOycHPgkV7D+LMSd96EUtodi66sMw== X-Google-Smtp-Source: AGHT+IFovCZb44wwlfTFdJb1oGby7WeZZ/bO1HALp6GbFmZ2yFHza5WBGT3TTR2WhI0nsaOHTa2wHhVLSo5xSFq600E= X-Received: by 2002:ac8:5846:0:b0:466:ac4d:22a5 with SMTP id d75a77b69052e-46734c8a7dcmr187213911cf.11.1733772120333; Mon, 09 Dec 2024 11:22:00 -0800 (PST) In-Reply-To: <86seqzisg2.fsf@gnu.org> X-Mailman-Approved-At: Tue, 10 Dec 2024 00:10:28 -0500 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:296732 Archived-At: Den l=C3=B6r 7 dec. 2024 kl 13:33 skrev Eli Zaretskii : > > > From: Guillaume Brunerie > > Date: Thu, 5 Dec 2024 07:13:20 +0100 > > Cc: Stefan Monnier , 74415@debbugs.gnu.org > > > > Den tors 28 nov. 2024 kl 17:02 skrev Eli Zaretskii : > > > Thanks. Guillaume, does the patch below give good results? > > > > Thank you, I haven=E2=80=99t managed to apply the patch locally yet but= I > > think that would work (I=E2=80=99m on Emacs 29.4, but I guess I might n= eed to > > get the development version of Emacs? The patch seems to fail on my > > mouse.el). > > But one thing I want to point out is that the two `(signal 'scan-error > > [...])` seem to be dead code now, as they test the exact opposite of > > what the previous test now does. > > Sorry, I don't understand. The changes I proposed didn't touch the > lines that signals errors. Are you saying that those errors were dead > code before these changes as well? If not, could you please elaborate > on the issues you see with the changes I proposed? No, it was not dead code before, but changing the outer condition makes it impossible for both the outer condition and the inner condition to be true at the same time. The current code is the following (inside a cond) ((and (=3D mode 1) (=3D start end) (char-after start) (=3D (char-syntax (char-after start)) ?\()) (if (/=3D (syntax-class (syntax-after start)) 4) ; raw syntax code for ?\( ;; This happens in CC Mode when unbalanced parens in CPP ;; constructs are given punctuation syntax with ;; syntax-table text properties. (2016-02-21). (signal 'scan-error (list "Containing expression ends prematurely" start start)) (list start (save-excursion (goto-char start) (forward-sexp 1) (point))))) So the 'scan-error happens when the character is a parenthesis character according to the syntax table (that's what is tested by (=3D (char-syntax (char-after start)) ?\()) but has a text property telling Emacs to treat it as something else than a parenthesis instead. Changing the "char-syntax" test to (=3D (syntax-class-to-char (syntax-class (syntax-after start))) ?\()) makes it so that the 'scan-error happens if the character is both a parenthesis and not a parenthesis according to text properties, which is not possible. In other words, it is not possible for both (=3D (syntax-class-to-char (syntax-class (syntax-after start))) ?\()) and (/=3D (syntax-class (syntax-after start)) 4) to be simultaneously true, as they are the exact opposite of each other, so when they are nested conditions, the inner one becomes dead code. That said, it only seems to happen in rare edge cases (as in https://lists.gnu.org/archive/html/bug-gnu-emacs/2016-02/msg00988.html), as regular unmatched parentheses do seem to still trigger a different "Unbalanced parentheses" scan error. Apart from that, I have now managed to test the patch, and I can confirm that it fixes my original issue