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:20:16 +0200 Organization: LINKOV.NET Message-ID: <87mshak5hz.fsf@mail.linkov.net> References: <87jzdawagd.fsf@gnu.org> <868qtmkzeo.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="31861"; 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, Roland Winkler , Stefan Monnier To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 05 08:23:24 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 1tJ6Cp-00088B-39 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Dec 2024 08:23:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJ6CX-0003Nh-4M; Thu, 05 Dec 2024 02:23: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 1tJ6CU-0003NE-RM for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 02:23: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 1tJ6CU-0007yX-6F for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 02:23: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=IIi7IE+e2OCFoaAwX7f0kmS5vvCVGEkPwbZ8WBM+5lc=; b=Gw7Taqe71Cs2kAES20RT/t4zsA6ACzNLBP+gl5AcXEQDDfBm7tqVpUi3vIsvW82N8T/dEbfR0821X2d8AnaaJ2szOylsR0Z38KFe0D8i1WDOzDbqAEbsfu5QPnEC2KjcnIMhl0NaRnkezcigsKC/grbP91HmIOiQNd0JgA8AkA2xlTNsVf8XwMEpN55gRWUQY4SazDd5kmM4XEVFkOtna8a81nsyWbkYgGlXn+nAzB1XzA8R21Xn5KL6Crn+XS4IPgDQLIYi/r33FBXrupySkD8K0Vjw3R1h2AF2DvD4l++ymej/fQiMY7dDieIhm2rIVjVgFEs+LGrcP31QQnyZWQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tJ6CU-0004VO-1B for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 02:23:02 -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:23: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.173338332717227 (code B ref 74307); Thu, 05 Dec 2024 07:23:01 +0000 Original-Received: (at 74307) by debbugs.gnu.org; 5 Dec 2024 07:22:07 +0000 Original-Received: from localhost ([127.0.0.1]:37940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJ6Ba-0004Tn-Vi for submit@debbugs.gnu.org; Thu, 05 Dec 2024 02:22:07 -0500 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:36825) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJ6BZ-0004TG-GZ for 74307@debbugs.gnu.org; Thu, 05 Dec 2024 02:22:05 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id BC6451BF207; Thu, 5 Dec 2024 07:21:55 +0000 (UTC) In-Reply-To: <868qtmkzeo.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Nov 2024 10:11:43 +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:296445 Archived-At: >> (setq foo "\\") >> >> The part "foo\\" of the string "\\" will get >> font-lock-variable-name-face, which looks odd. >> >> I believe, this is due to a clause in lisp-mode.el that says >> >> ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for >> ;; `substitute-command-keys'. >> >> But this assumption is not always correct, in particular if ">" is >> preceded by "\\", which happens when constructing regexps. > > I believe you are saying that in > > (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) ">") > (seq "{" (group-n 1 lisp-mode-symbol) "}"))) > (1 font-lock-variable-name-face prepend)) > > we should use something like the below instead? > > (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) (not "\\\\") ">") > (seq "{" (group-n 1 lisp-mode-symbol) (not "\\\\") "}")) 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 \\