From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#74307: 30.0.92; emacs-lisp font-locking word regexp Date: Thu, 05 Dec 2024 09:47:05 +0200 Organization: LINKOV.NET Message-ID: <87zflainba.fsf@mail.linkov.net> References: <87jzdawagd.fsf@gnu.org> <868qtmkzeo.fsf@gnu.org> <87mshak5hz.fsf@mail.linkov.net> <86o71qy3xz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9849"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 74307@debbugs.gnu.org, winkler@gnu.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 05 08:49:14 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 1tJ6bp-0002OW-Rh for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Dec 2024 08:49:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJ6bh-0001QP-Oa; Thu, 05 Dec 2024 02:49:05 -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 1tJ6be-0001QA-Gu for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 02:49:02 -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 1tJ6be-0001IH-7p for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 02:49:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=eH3CsX6JsW5BTwXVDMcMUztgVZcXgDmm3TMvwH6+SRU=; b=renYSB8SHBW8bUybImKaSJuzhm7zY1G5JxqCRD0oZDt1P/17OAVBcGoYgF4i4nPmvd9MhiErDRBeA8KwD8584+M76ScEPxFAVkJFOKn2uaVE8UWbWNwk4e0+rjGADxIXYWUXSRJ7/IsHqxXMelY6cQUuB83/SNHw3n6+y+aza4/V+iq+2Yn2yNKtDiclp5H4CUBMd6i/7AM0MHjWzYRXEAtM7R302CCIX2Aq9MDdtbKhCE03gZwkEzqe83mYL60n1Bl91qtP3xDy2+X74suYN6MjEveQCyvysrurHOP62NyA8QsQ44lkKd99BwyOd8wusrnqax4ttaDJH/Eya7pNfQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tJ6bd-0005kE-Ps for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 02:49:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Dec 2024 07:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74307 X-GNU-PR-Package: emacs Original-Received: via spool by 74307-submit@debbugs.gnu.org id=B74307.173338490422024 (code B ref 74307); Thu, 05 Dec 2024 07:49:01 +0000 Original-Received: (at 74307) by debbugs.gnu.org; 5 Dec 2024 07:48:24 +0000 Original-Received: from localhost ([127.0.0.1]:38011 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJ6b1-0005j9-VO for submit@debbugs.gnu.org; Thu, 05 Dec 2024 02:48:24 -0500 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:56549) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJ6b0-0005iu-1J for 74307@debbugs.gnu.org; Thu, 05 Dec 2024 02:48:22 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 9197E6000E; Thu, 5 Dec 2024 07:48:14 +0000 (UTC) In-Reply-To: <86o71qy3xz.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 05 Dec 2024 09:38:48 +0200") X-GND-Sasl: juri@linkov.net 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:296452 Archived-At: >> The problem is that this removes highlighting from the last character >> because it doesn't get into the group: >> >> (rx (seq "[" (group-n 1 lisp-mode-symbol) (not "\\") "]")) >> => "\\[\\(?1:\\(?:\\w\\|\\s_\\|\\\\.\\)+\\)[^\\]]" >> >> A possible solution is to move (not "\\") inside the group: >> >> (rx (seq "[" (group-n 1 (seq lisp-mode-symbol (not "\\"))) "]")) >> => "\\[\\(?1:\\(?:\\w\\|\\s_\\|\\\\.\\)+[^\\]\\)]" >> >> But this removes highlighting completely from the reported case of >> (setq foo "\\"). However, I guess it should not have highlighting >> anyway because this is an incorrect syntax of `substitute-command-keys' >> that should match only \\[], \\<>, \\{} or \\`' without the second \\ > > Sorry, I don't understand: the change which was supposed to fix this > was already installed. Ah, so (setq foo "\\") should not be highlighted. Ok, then indeed (not "\\") should be inside the group. > If you are saying it caused regressions, could you please show > a recipe for reproducing those regressions? A recipe is to put the following two lines into a buffer with emacs-lisp-mode: (setq foo "\\") (setq foo "\\") The first foo should not be highlighted, the second currently is highlighted partially without the last character. Here is the fix: diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 99980a44ddf..95fbae48bb6 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -491,16 +491,16 @@ lisp-mode--search-key ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for ;; `substitute-command-keys'. (,(rx "\\\\" (or (seq "[" - (group-n 1 lisp-mode-symbol) (not "\\") "]") + (group-n 1 (seq lisp-mode-symbol (not "\\"))) "]") (seq "`" (group-n 1 ;; allow multiple words, e.g. "C-x a" lisp-mode-symbol (* " " lisp-mode-symbol)) "'"))) (1 font-lock-constant-face prepend)) (,(rx "\\\\" (or (seq "<" - (group-n 1 lisp-mode-symbol) (not "\\") ">") + (group-n 1 (seq lisp-mode-symbol (not "\\"))) ">") (seq "{" - (group-n 1 lisp-mode-symbol) (not "\\") "}"))) + (group-n 1 (seq lisp-mode-symbol) (not "\\")) "}"))) (1 font-lock-variable-name-face prepend)) ;; Ineffective backslashes (typically in need of doubling). ("\\(\\\\\\)\\([^\"\\]\\)"