From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 12 17:26:02 2025 Received: (at submit) by debbugs.gnu.org; 12 Mar 2025 21:26:02 +0000 Received: from localhost ([127.0.0.1]:51994 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tsTaU-00006u-E9 for submit@debbugs.gnu.org; Wed, 12 Mar 2025 17:26:02 -0400 Received: from lists.gnu.org ([2001:470:142::17]:34240) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tsTaR-00006W-SN for submit@debbugs.gnu.org; Wed, 12 Mar 2025 17:26:00 -0400 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 1tsTaK-0003Fa-H7 for bug-gnu-emacs@gnu.org; Wed, 12 Mar 2025 17:25:52 -0400 Received: from mail.hostpark.net ([212.243.197.30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tsTaI-0002g5-Eg for bug-gnu-emacs@gnu.org; Wed, 12 Mar 2025 17:25:52 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 17769167AE; Wed, 12 Mar 2025 22:25:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-type:content-type:mime-version:message-id:date:date :subject:subject:from:from; s=sel2011a; t=1741814746; bh=C+sfPmR 9csP113PFXHDAa48mYNDilRiHsKrL9CoruLw=; b=3ehTqUOu4tSaSBTSNjai6uK HP4DSYNgqWfXnKnLKtXtAdDrvkvrVM20c+ruZCOXeiNRbtwencWKOPhSL/rB1IOq 0uNqJ9Y0orGCw0lq3CQUJzktyuD0teFfLGH5/bQPNLiXs3OpPGUEgJt5ewz1ItOy O2PBon4ZvKVRD2fpgoTk= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id 95_pNrvtpBNT; Wed, 12 Mar 2025 22:25:46 +0100 (CET) Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 7F7C91657F; Wed, 12 Mar 2025 22:25:46 +0100 (CET) From: Jonas Bernoulli To: bug-gnu-emacs@gnu.org Subject: Invert when symbol syntax class is used for ## Date: Wed, 12 Mar 2025 22:25:46 +0100 Message-ID: <87seniszz9.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=212.243.197.30; envelope-from=jonas@bernoul.li; helo=mail.hostpark.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) The `llama' package uses the `##' symbol and encourages not putting any space in between that and the following symbol. Since it was added three years ago, `elisp-mode-syntax-propertize' explicitly assigns the symbol syntax class to "##", which means that code that relies on the syntax alone (such as complete-symbol), thinks that ##foo is one symbol, when that are actually two symbols ## and foo. For some reason [1: 6ccc4b6bc8a] limited assigning symbol syntax for ## to when that appears in code. I propose we do the opposite: do NOT use symbol syntax in code, but DO use symbol syntax in strings and comments. Do the latter so that `##' is highlighted like other symbols would, when quoted like that. 1: 2022-05-06 6ccc4b6bc8a14daca6b3e3250574752c90c1eb9b Handle elisp #-syntax better in Emacs Lisp mode I am opening this bug-report because Stefan Monnier commented on llama.el's advice for `elisp-mode-syntax-propertize', to ask whether such a bug-report exists: >> + (syntax-propertize-rules >> + ;; Empty symbol. >> + ;; {{ Comment out to prevent the `##' from becoming part of >> + ;; the following symbol when there is no space in between. >> + ;; ("##" (0 (unless (nth 8 (syntax-ppss)) >> + ;; (string-to-syntax "_")))) >> + ;; }} >> + ;; {{ As for other symbols, use `font-lock-constant-face' in >> + ;; docstrings and comments. >> + ("##" (0 (when (nth 8 (syntax-ppss)) >> + (string-to-syntax "_")))) >> + ;; }} > > BTW, is there a bug-report about this? It seems this issue is not > really dependent on what ## is used for (except maybe for the fact that > `llama.el` encourages the use a `##` immediately followed by another > symbol without any intervening space). > > Stefan Coming from an override advice, the above code includes "original vs. advice" commentary. As a patch to Emacs, this change look like this: diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el @@ -269,9 +269,12 @@ elisp-mode-syntax-propertize (let ((case-fold-search nil)) (funcall (syntax-propertize-rules - ;; Empty symbol. - ("##" (0 (unless (nth 8 (syntax-ppss)) - (string-to-syntax "_")))) + ;; Prevent ## (the empty symbol) from becoming part of a + ;; preceeding or following symbol by *not* explicitly assigning + ;; symbol syntax class here; except in comments and strings, so + ;; that `##' gets highlighted like other `symbols'. + ("##" (0 (and (nth 8 (syntax-ppss)) + (string-to-syntax "_")))) ;; Prevent the @ from becoming part of a following symbol. (",@" (0 (unless (nth 8 (syntax-ppss)) (string-to-syntax "'")))) Jonas From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 12 18:15:34 2025 Received: (at submit) by debbugs.gnu.org; 12 Mar 2025 22:15:34 +0000 Received: from localhost ([127.0.0.1]:52102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tsUMP-0002Xi-Fr for submit@debbugs.gnu.org; Wed, 12 Mar 2025 18:15:33 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33266) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tsUMM-0002XK-J5 for submit@debbugs.gnu.org; Wed, 12 Mar 2025 18:15:31 -0400 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 1tsUMH-0003VK-1Q for bug-gnu-emacs@gnu.org; Wed, 12 Mar 2025 18:15:25 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tsUMB-0008S6-3r for bug-gnu-emacs@gnu.org; Wed, 12 Mar 2025 18:15:21 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id EF4A01001EE; Wed, 12 Mar 2025 18:15:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1741817715; bh=31ueXbHcYy4kBpAz8ESkw08gy9pLVkSRlC3xjBy5jVw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=m0rFhwkziegM7/BKUWZ+E0oBuiKZKQT8utAAADJNDhzCCfYhSgqopAT3XJlhrlb1B YXFt+paAwgypDDiS7u1udyuEa1tyBpwC6Dpy6rlmlJnXEOLzesRvX0MgxJutIFu6MK 0LhXImDOWCLGQRbqxrikIxyAa+Q0qHVEKwMgF55Ey52ZutiLRh2+DWrIVruSittCQx sgqz6VrNnnjA1KW5Ueoxiv6afAtSRwOrlS3M05+QGeYu7M8avuLJ4/MlvbuPP0o0Dn 35kHIQhmr2XLKSkJMH+gaOsu9vaALDSGTRrmo8KhmljAyJqndoej6jhG1uMpzcmdF1 1g9lt9ZFJeJxw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1299F100035; Wed, 12 Mar 2025 18:15:15 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 01CAE120206; Wed, 12 Mar 2025 18:15:15 -0400 (EDT) From: Stefan Monnier To: Jonas Bernoulli Subject: Re: Invert when symbol syntax class is used for ## In-Reply-To: <87seniszz9.fsf@bernoul.li> (Jonas Bernoulli's message of "Wed, 12 Mar 2025 22:25:46 +0100") Message-ID: References: <87seniszz9.fsf@bernoul.li> Date: Wed, 12 Mar 2025 18:15:14 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.105 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > The `llama' package uses the `##' symbol and encourages not putting any > space in between that and the following symbol. > > Since it was added three years ago, `elisp-mode-syntax-propertize' > explicitly assigns the symbol syntax class to "##", which means that > code that relies on the syntax alone (such as complete-symbol), thinks > that ##foo is one symbol, when that are actually two symbols ## and foo. Do you have specific behaviors w.r.t highlighting, navigation, or indentation, that matter specifically? To be "technically" more correct, I suspect `##` in code should be treated in the syntax tables as some kind of "pair of an open-paren-like thingy and close-paren-like thingy", so that navigation with M-C-f over `##foo` skips it in two steps. I suspect this will lead to indentation that's different from the one you'd prefer, e.g. (list (##foo bar) (##foo bar baz)) instead of (list (##foo bar) (##foo bar baz)) But I think this is specific to llama's use of ## so ideally, we'd fix that on the `llama.el` side with some `list-indent-function` magic. > For some reason [1: 6ccc4b6bc8a] limited assigning symbol syntax for ## > to when that appears in code. I propose we do the opposite: do NOT use > symbol syntax in code, but DO use symbol syntax in strings and comments. > Do the latter so that `##' is highlighted like other symbols would, when > quoted like that. Sounds good to me. I think we left ## untouched in text/comments because we assumed that ## in comments would usually not represent ELisp code but something else. With the use of ## for llama, this presumption does not seem valid any more. Stefan