From unknown Sun Jun 15 08:45:12 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#67390 <67390@debbugs.gnu.org> To: bug#67390 <67390@debbugs.gnu.org> Subject: Status: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Reply-To: bug#67390 <67390@debbugs.gnu.org> Date: Sun, 15 Jun 2025 15:45:12 +0000 retitle 67390 28; shorthands-font-lock-shorthands assumes shorthand uses sa= me separator reassign 67390 emacs submitter 67390 Jonas Bernoulli severity 67390 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 22 17:18:41 2023 Received: (at submit) by debbugs.gnu.org; 22 Nov 2023 22:18:41 +0000 Received: from localhost ([127.0.0.1]:60009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5vYO-0000ZN-U7 for submit@debbugs.gnu.org; Wed, 22 Nov 2023 17:18:41 -0500 Received: from lists.gnu.org ([2001:470:142::17]:45240) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5vYN-0000Z5-50 for submit@debbugs.gnu.org; Wed, 22 Nov 2023 17:18:39 -0500 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 1r5vYD-0003Jf-Uj for bug-gnu-emacs@gnu.org; Wed, 22 Nov 2023 17:18:30 -0500 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 1r5vYC-0007KE-23 for bug-gnu-emacs@gnu.org; Wed, 22 Nov 2023 17:18:29 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id B8BC71622A; Wed, 22 Nov 2023 23:18:21 +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=1700691501; bh=Slz+AOm DONt0AsjcBVEXdB/O+Nm81qMPRQko44/UNzY=; b=u9gvS8OqMOt5tCmxof+Swgu h89K33xox7FR//uNmCCD8TPp75ue/5yH03ZVNOo82a66c0IFDZK1V58j9nPRiyEE uRvMuwutCPbp5SjcHB9Sg89xXG60uueSTYY/HQl+rvDYHiwDWg5/XJAn3CT4DFGg e7YFzW9jPzXLPb0tYN0I= 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 G29anzRuvacJ; Wed, 22 Nov 2023 23:18:21 +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 (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 39E7F161DD; Wed, 22 Nov 2023 23:18:21 +0100 (CET) From: Jonas Bernoulli To: bug-gnu-emacs@gnu.org Subject: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Wed, 22 Nov 2023 23:18:18 +0100 Message-ID: <87a5r5ph3p.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: Joseph Turner , Adam Porter , =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= 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 (/) Hello, `shorthands-font-lock-shorthands' assumes that the shorthand uses the same separator as the real symbol name, e.g., "s-" instead of "long-". This causes an additional character to be highlighted when an alternative separator is used, e.g., when using "s/" instead of "long-". `shorthands--mismatch-from-end' returns the length of the common suffix, of the shorthand and the long name. (shorthands--mismatch-from-end "s-tail" "long-tail") => 5 "s-" is highlighted in this case. Since `shorthands-font-lock-shorthands' also wants to highlight the separator, "-" in this case, it corrects this off-by-one, but when different separators are in use, this causes an additional character to be highlighted (shorthands--mismatch-from-end "s/tail" "long-tail") => 4 "s/t" is highlighted in this case. Could we add support for using an alternative separator in shorthands? IMO it is okay to use another separator for *shorthand* prefixes. They won't show up in M-x completion candidates, for example. Shorthands are confined to the file where they are being used, and I think authors should be free to use whatever prefix they fancy. Cheers, Jonas From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 23 07:54:52 2023 Received: (at submit) by debbugs.gnu.org; 23 Nov 2023 12:54:52 +0000 Received: from localhost ([127.0.0.1]:32877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r69EK-00015G-Gd for submit@debbugs.gnu.org; Thu, 23 Nov 2023 07:54:52 -0500 Received: from lists.gnu.org ([2001:470:142::17]:43056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r69EI-000150-HZ for submit@debbugs.gnu.org; Thu, 23 Nov 2023 07:54:51 -0500 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 1r69E7-0000n5-IJ for bug-gnu-emacs@gnu.org; Thu, 23 Nov 2023 07:54:40 -0500 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r69E4-0000jg-SG for bug-gnu-emacs@gnu.org; Thu, 23 Nov 2023 07:54:38 -0500 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-507bd644a96so1094999e87.3 for ; Thu, 23 Nov 2023 04:54:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700744072; x=1701348872; darn=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=EsRi/cYGPtCl2brwBEQA94ALsNYwl15GAcMJ36BhDgI=; b=JcC9X/kXsz7CLVX6gSxVlNBzIvKrMgQaWttQT6/vE88Vc0wiTOdSHcX6A3g+3iRRzZ UJ7Ax4W2tVlXGcGhZy7nl+vhmuB2nBe5nmOWB5Mz9RyjOFITAqbTovHR80/mA6KVRejr 8kum9u1dCJ/7C6cd1vXP7FzJCH4tzj4oqyVkP/1tu6lDJSF7MffY8uZcb5xWoyHuLqoq CQiI9VIyXsnbBYEdwY6XkodZR91zL5DxkRgHERe8amqBt75cm8ZlRMY4gtZNJi77ncXD c0Z4bcXz3Ba32bXj9YIUoSPyVtg0775hXkB+EYuj430T27OFHue6FCHc8IClRpNvrUe8 bU+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700744072; x=1701348872; 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=EsRi/cYGPtCl2brwBEQA94ALsNYwl15GAcMJ36BhDgI=; b=jMaotWTS5KhI9rFH+e66gDbtM2Pl1CA9kjScnK21zg7RQUz1kRy4QKyB03HfsXbYkm Vc76EUjvRtOprFNJM4Rr9/czacw1yiaksaaJEJAZ5nIXPWkGMcFlhjcGIn2oG1XtXppB yCEaMf5YEMlHJu+YBJ+PCGPAPlnjXb2DXtVdCn2jKDS6cP0KgMWcmCDcHAwhLH86oOMu W1/OjNSCpOn0IsLNU7Dt7vRa6JVdUSSAkNk9v8umVksUlQc/mCzDKjnAd7oKPj+jcdOM jTVPg4MiIHk8aJjE/+i9XlCGnt/8fNdkZsrYwYDiJZo45RmkEQORWlnLUu17Rt4abvRT aoUw== X-Gm-Message-State: AOJu0YxKiCnd0qvDzTn2/N61sfcjqQixsY7XiOQmHN/PkRQ29/HG/r+K 51xh+BJGgmIYAJaHeVt4XnhGd/uMGOvcrQNG49E= X-Google-Smtp-Source: AGHT+IFTfK3mR3qqOiKr9uk5YhpFrogq6CZ259/DoNNdOxcJolBoSfc9TRfU/YcKdCg4PT4jmUZppSrUqCSejp75GCA= X-Received: by 2002:a19:7607:0:b0:503:3781:ac32 with SMTP id c7-20020a197607000000b005033781ac32mr3487314lff.41.1700744072263; Thu, 23 Nov 2023 04:54:32 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> In-Reply-To: <87a5r5ph3p.fsf@bernoul.li> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Thu, 23 Nov 2023 12:57:31 +0000 Message-ID: Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Jonas Bernoulli Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=joaotavora@gmail.com; helo=mail-lf1-x12e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Joseph Turner , Adam Porter , 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: -0.0 (/) On Wed, Nov 22, 2023 at 10:18=E2=80=AFPM Jonas Bernoulli = wrote: > Could we add support for using an alternative separator in shorthands? I think so, if you can find a patch for it. This only affects the font-loc= king bits of shorthands right? IOW all other shorthand-aware functionality like eldoc, M-., etc, already works with different separators, right? > IMO it is okay to use another separator for *shorthand* prefixes. They > won't show up in M-x completion candidates, for example. Shorthands are > confined to the file where they are being used, and I think authors > should be free to use whatever prefix they fancy. I agree in principle, and exactly for that reason (that shorthands are conf= ined to a file). Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 24 16:52:06 2023 Received: (at submit) by debbugs.gnu.org; 24 Nov 2023 21:52:06 +0000 Received: from localhost ([127.0.0.1]:37399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6e5j-00073C-PK for submit@debbugs.gnu.org; Fri, 24 Nov 2023 16:52:06 -0500 Received: from lists.gnu.org ([2001:470:142::17]:33690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6e5d-00072X-PP for submit@debbugs.gnu.org; Fri, 24 Nov 2023 16:52:01 -0500 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 1r6e5T-0002zt-BH for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 16:51:47 -0500 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 1r6e5P-0007eB-AW for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 16:51:45 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 1DA15168BC; Fri, 24 Nov 2023 22:51:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-transfer-encoding:content-type:content-type:mime-version :message-id:date:date:references:in-reply-to:subject:subject :from:from; s=sel2011a; t=1700862695; bh=XHS24lRQDfZmkhuUcknpBZk vWlsSThav1tM7C3rIRJc=; b=HNY/ij8V3c27ziuKJ6HwwFZ7hIfFu4J/qWKUK+N COMfwWS3/pv/Wzt3YWXTaJadkP8LZ9o/9yx429SH4ViPlDaA8xPoE8eOmaqxA7LS NhCteEU9fYJw8YMc3VlyL+zpuOh4xr9hY1WkQlebmtVlize1EEWAVkhzpgtsvdAT 9K50= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id pWOdGj5LG_Qz; Fri, 24 Nov 2023 22:51:35 +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 (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 7A04D1653B; Fri, 24 Nov 2023 22:51:35 +0100 (CET) From: Jonas Bernoulli To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator In-Reply-To: References: <87a5r5ph3p.fsf@bernoul.li> Date: Fri, 24 Nov 2023 22:51:32 +0100 Message-ID: <87msv2vmzf.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: Joseph Turner , Adam Porter , 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: -0.1 (/) Jo=C3=A3o T=C3=A1vora writes: > On Wed, Nov 22, 2023 at 10:18=E2=80=AFPM Jonas Bernoulli wrote: > >> Could we add support for using an alternative separator in shorthands? > > I think so, if you can find a patch for it. This only affects the font-l= ocking > bits of shorthands right? IOW all other shorthand-aware functionality li= ke > eldoc, M-., etc, already works with different separators, right? I haven't found any issues beside this off-by-one font-lock issue. So far I have used this beauty: diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el @@ -57,7 +57,7 @@ shorthands--mismatch-from-end for i from 1 for i1 =3D (- l1 i) for i2 =3D (- l2 i) while (and (>=3D i1 0) (>=3D i2 0) (eq (aref str1 i1) (aref str= 2 i2))) - finally (return (1- i)))) + finally (return (if (eq (aref str2 (1+ i2)) ?-) (1- i) i)))) Is that good enough? Depending on how you look at it, this changes what is being returned, but IMO this function is a bit murky to begin with. The function name is `shorthands--mismatch-from-end', but it returns the length of the common suffix, minus one, to account for the separator. This change ensures that the separator is accounted for, even if it differs between the shorthand and real symbol. Since this function returns the length of the *matching* suffix after the prefixes (including separator), I find it weird that its name contains *MISmatch*. It might make more sense to return the length of the shorthand prefix. Also, have you considered throwing in a (not (string-equal (match-string 1) sname)) to avoid having to call `shorthands--mismatch-from-end' at all? Maybe you have, but concluded it is cheaper to do a bit too much work for non-shorthands, than to effectively repeat some work for shorthands. Jonas From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 24 19:03:42 2023 Received: (at submit) by debbugs.gnu.org; 25 Nov 2023 00:03:42 +0000 Received: from localhost ([127.0.0.1]:37501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6g98-0002Ua-9H for submit@debbugs.gnu.org; Fri, 24 Nov 2023 19:03:42 -0500 Received: from lists.gnu.org ([2001:470:142::17]:35436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6g94-0002UL-0k for submit@debbugs.gnu.org; Fri, 24 Nov 2023 19:03:40 -0500 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 1r6g8t-00081M-QM for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 19:03:27 -0500 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6g8r-0002oc-Te for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 19:03:27 -0500 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5079f6efd64so3196518e87.2 for ; Fri, 24 Nov 2023 16:03:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700870603; x=1701475403; darn=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=Ol+AjJlLPdeK8Wk9mRyBSoMDt8M7c64Ya7RZ95ZZWa8=; b=Uh7zWHp3T7vNrCMEa9W1zntC/nic4uEku0WDOUH7wGqZxMldT+baZdPeKsuPHb7D1b 8PeCd6i6CwccVDge0MkPxOLnF8HdAehYiFO7/vlOlSdi841iD3yhjZDRf0XLr+ZSWlO8 xcHbMu8Jtmv8DaucUa8nZJqtVsoMaTsBed2qGv+/04IY27Kz2SPMDdvQl+bQ/1icatBk KvNVmKnQtgaVmVpJaS4e+vOHPcmBzG6411+AIbYfXVWxBT8oX1D6CHkWubD673mWjC9B R/FNLprKhwYTfgVR7ycLWnHxZiy17N7Ng1/NyJM7gZKY4VK81BZMoGpvL2bMvR5h2k4m 6J2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700870603; x=1701475403; 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=Ol+AjJlLPdeK8Wk9mRyBSoMDt8M7c64Ya7RZ95ZZWa8=; b=eqvmVTT9yjnCRS9ieutFsQ5u7OV8CxITqAgYh8Y7nX+joLs4A2n2tY47nELhZdZ9OS cvTEDeudEXjsZXm7rizm7idD47zoioAY1ZeJ0vIAe3SCDqYKIPNMtS88WVYU7a0r62gp OLG6AfhYYOgAXTtPxJHZwrhuI9dYYIi4u1InYQPvGbI8wJHYyqwRzWkltmM2idgxgLcp 0EtOnVHJVz3erAvXRHSo9nI7RGOMRy7PsTcBeA2pSp0NWCTIk3+xytTRDN0WS91nkixI yYhQCroKY5U9QXGwp8RKKaatXOnkKOfXXF6c7u911ufy+Ku2yxpKIHloZ+2iGIEeKjL+ gIeA== X-Gm-Message-State: AOJu0YzlB6h1wbaeJPhAULM2QEXrtFS8zIAWVPIhpDlSCcWxnJv0wUQW UEsbQUUjq/BH0U4uQ6ho74MK0WamXKeYmLiswv5p2M6E1Lk= X-Google-Smtp-Source: AGHT+IFJxK14DZtOHQEBIztyrxM5G8nuvPReVCkJaRky9ObII92i+3xglJiMFj1qrYoivzuFKau9/oHMotv3SYaKljM= X-Received: by 2002:ac2:5e66:0:b0:509:115c:51de with SMTP id a6-20020ac25e66000000b00509115c51demr2464144lfr.25.1700870603019; Fri, 24 Nov 2023 16:03:23 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> In-Reply-To: <87msv2vmzf.fsf@bernoul.li> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sat, 25 Nov 2023 00:03:10 +0000 Message-ID: Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Jonas Bernoulli Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=joaotavora@gmail.com; helo=mail-lf1-x12b.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Joseph Turner , Adam Porter , 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: -0.0 (/) On Fri, Nov 24, 2023 at 9:51=E2=80=AFPM Jonas Bernoulli = wrote: > I haven't found any issues beside this off-by-one font-lock issue. Good. > So far I have used this beauty: > > diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.e= l > @@ -57,7 +57,7 @@ shorthands--mismatch-from-end > for i from 1 > for i1 =3D (- l1 i) for i2 =3D (- l2 i) > while (and (>=3D i1 0) (>=3D i2 0) (eq (aref str1 i1) (aref s= tr2 i2))) > - finally (return (1- i)))) > + finally (return (if (eq (aref str2 (1+ i2)) ?-) (1- i) i)))) > > Is that good enough? Depending on how you look at it, this changes what > is being returned, but IMO this function is a bit murky to begin with. A bit dodgy, no :-) Maybe a docstring would shed some light on what this function is supposed to do, so I'll propose one below. > The function name is `shorthands--mismatch-from-end', but it returns the > length of the common suffix, minus one, to account for the separator. > This change ensures that the separator is accounted for, even if it > differs between the shorthand and real symbol. > > Since this function returns the length of the *matching* suffix after > the prefixes (including separator), I find it weird that its name > contains *MISmatch*. Probably I wanted to emulate what CL's MISMATCH does to some degree. cl-mismatch exists in Emacs, but it's not available in shorthands.el, and it seems to be buggy anyway. You can rename the function shorthands--common-suffix-length if you want. I probably meant it to be separator-agnostic function, and be replaceable by a cl-mismatch some time around 2084, Now to your problem: I think what you want is to customize element comparison (CL's MISMATCH allows that, btw). Here's one way. diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el index 82200ab88e9..36a862bc037 100644 --- a/lisp/emacs-lisp/shorthands.el +++ b/lisp/emacs-lisp/shorthands.el @@ -52,11 +52,18 @@ elisp-shorthand-font-lock-face :version "28.1" :group 'font-lock-faces) -(defun shorthands--mismatch-from-end (str1 str2) - (cl-loop with l1 =3D (length str1) with l2 =3D (length str2) +(defun shorthands--mismatch-from-end (str1 str2 &optional test) + "Compute position of first mismatching element of STR1 and STR2, from en= d. +The return value is the reverse index of that element. If 0, the +last characters of STR1 and STR2 differ, if 1, the penultimate +characters differ, and so on. If optional TEST is passed, +compare elements using that function, else compare with `eq'." + (cl-loop with test =3D (or test #'eq) + with l1 =3D (length str1) with l2 =3D (length str2) for i from 1 for i1 =3D (- l1 i) for i2 =3D (- l2 i) - while (and (>=3D i1 0) (>=3D i2 0) (eq (aref str1 i1) (aref str= 2 i2))) + while (and (>=3D i1 0) (>=3D i2 0) + (funcall test (aref str1 i1) (aref str2 i2))) finally (return (1- i)))) (defun shorthands-font-lock-shorthands (limit) And now using the following lambda for TEST yields what you want: (shorthands--mismatch-from-end "s-tail" "long-tail") ;; =3D> 5 (shorthands--mismatch-from-end "s/tail" "long-tail" (lambda (c1 c2) (or (and (eq c1 ?/) (eq c2 ?-)) (eq c1 c2)))) ;; =3D> also 5 Of course, you can hardcode this test inside the function, no need for a parameter, and rename the function to whatever you find more appropriate. This allows us to keep control over what things are considered acceptable separators from a font-locking perspective > It might make more sense to return the length of the shorthand prefix. I've been away from this code for a couple of years, so feel free to propose more extensive changes. As long as they don't increase the complexity and are suitably tested, I have nothing against. > Also, have you considered throwing in a > (not (string-equal (match-string 1) sname)) > > to avoid having to call `shorthands--mismatch-from-end' at all? Where and how this be thrown in? How would you know what to highlight in the shorthand printed form? There can be many shorthand prefixes in a given file. But do show some code. > Maybe you have, but concluded it is cheaper to do a bit too much work > for non-shorthands, than to effectively repeat some work for shorthands. Maybe. Not sure this is more work (string-equal must still compare every character right?), but, in summary, I'm not married to this implementation. I somewhat appreciate that I could still read it after not having looked at it for a couple years, but feel free to change it. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 24 22:30:50 2023 Received: (at 67390) by debbugs.gnu.org; 25 Nov 2023 03:30:50 +0000 Received: from localhost ([127.0.0.1]:37562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6jNZ-00086j-MB for submit@debbugs.gnu.org; Fri, 24 Nov 2023 22:30:50 -0500 Received: from out-172.mta1.migadu.com ([2001:41d0:203:375::ac]:34047) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6jNV-00086U-Jz for 67390@debbugs.gnu.org; Fri, 24 Nov 2023 22:30:48 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1700883039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=k5AensBvfw1yi2Gi5b4zMJje9rdtvv1hqk+rzhqdwq4=; b=R/iMRz46HFFSEDWyTBB5qyvjlic8CJLIuW2ZzSd+9OftOImZrdlp3LU8mQo4AEJdSpy0HY ZmdfAr7Lf9C53eZolfEst5d8jZ6lBVmkudXQpRsXBfE7TZqD8ra+ExRT6cJVAPQqvDEH3s TAe4t6kwY22pVYaIevqzt4iSPvWvfmBsE2Ix8KBBSCAvcEYtXLipTgEH8xASfoTecKMAvt MFHMdh8ll4LDUCM3lU3qK6uYSaMr2CLBWDmMHm7VNSmL+ff3ojJfIM+wpmXW3CwdbJxxjZ nsR2c5+CKj6jbkhjiQiyWyKyoJhuvYiClrKpMlfrGUkEuz6WAoL5mtboJD7uyw== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Fri, 24 Nov 2023 19:26:54 -0800 In-reply-to: Message-ID: <878r6mzezo.fsf@ushin.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Jonas Bernoulli 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 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jo=C3=A3o T=C3=A1vora writes: > On Fri, Nov 24, 2023 at 9:51=E2=80=AFPM Jonas Bernoulli wrote: > >> Also, have you considered throwing in a >> (not (string-equal (match-string 1) sname)) >> >> to avoid having to call `shorthands--mismatch-from-end' at all? > > Where and how this be thrown in? How would you know what to highlight > in the shorthand printed form? There can be many shorthand prefixes > in a given file. But do show some code. Please see the attached patch, inspired by Jonas's comment. >> Maybe you have, but concluded it is cheaper to do a bit too much work >> for non-shorthands, than to effectively repeat some work for shorthands. > > Maybe. Not sure this is more work (string-equal must still compare > every character right?), but, in summary, I'm not married to this > implementation. I somewhat appreciate that I could still read it > after not having looked at it for a couple years, but feel free to > change it. I haven't done any benchmarking - I'm curious to learn how to benchmark font lock though! Thanks!! Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Support-shorthand-prefixes-besides.patch >From e469c9d621116857bd1d84720eb2eb43d4560074 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Fri, 24 Nov 2023 19:17:13 -0800 Subject: [PATCH] Support shorthand prefixes besides "-" Previously, shorthands-font-lock-shorthands added font locking to the shorthand prefix by checking for a mismatch between the shorthand and longhand symbols. This broke font-locking when the shorthand prefix separator was not "-" (bug#67390). Now, shorthands-font-lock-shorthands adds font locking to the shorthand prefix by checking if any of the shorthand prefixes in read-symbol-shorthands are a prefix for the current symbol name. Thanks to Jonas Bernoulli for the idea to use (not (string-equal (match-string 1) sname)) --- lisp/emacs-lisp/shorthands.el | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el index 82200ab88e9..141b6115a3d 100644 --- a/lisp/emacs-lisp/shorthands.el +++ b/lisp/emacs-lisp/shorthands.el @@ -52,12 +52,14 @@ :version "28.1" :group 'font-lock-faces) -(defun shorthands--mismatch-from-end (str1 str2) - (cl-loop with l1 = (length str1) with l2 = (length str2) - for i from 1 - for i1 = (- l1 i) for i2 = (- l2 i) - while (and (>= i1 0) (>= i2 0) (eq (aref str1 i1) (aref str2 i2))) - finally (return (1- i)))) +(defun shorthands--find-if (predicate seq &optional key) + "Find the first item satisfying PREDICATE in SEQ. +Return the matching item, or nil if not found. Optional argument +KEY is used to filter SEQ, as in `cl-find-if'." + (catch 'found + (dolist (el seq) + (when (funcall predicate (funcall (or key #'identity) el)) + (throw 'found el))))) (defun shorthands-font-lock-shorthands (limit) (when read-symbol-shorthands @@ -69,10 +71,15 @@ font-lock-string-face))) (intern-soft (match-string 1)))) (sname (and probe (symbol-name probe))) - (mm (and sname (shorthands--mismatch-from-end - (match-string 1) sname)))) - (unless (or (null mm) (= mm (length sname))) - (add-face-text-property (match-beginning 1) (1+ (- (match-end 1) mm)) + (prefix (and sname + (not (string-equal (match-string 1) sname)) + (car (shorthands--find-if + (lambda (short) + (string-prefix-p short (match-string 1))) + read-symbol-shorthands #'car))))) + (when prefix + (add-face-text-property (match-beginning 1) + (+ (match-beginning 1) (length prefix)) 'elisp-shorthand-font-lock-face)))))) (font-lock-add-keywords 'emacs-lisp-mode '((shorthands-font-lock-shorthands)) t) -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 25 11:02:08 2023 Received: (at 67390) by debbugs.gnu.org; 25 Nov 2023 16:02:08 +0000 Received: from localhost ([127.0.0.1]:40066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6v6e-0004FA-Iu for submit@debbugs.gnu.org; Sat, 25 Nov 2023 11:02:08 -0500 Received: from mail.hostpark.net ([212.243.197.30]:52658) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6v6c-0004Ea-0S for 67390@debbugs.gnu.org; Sat, 25 Nov 2023 11:02:07 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 48A311622A; Sat, 25 Nov 2023 17:01:54 +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 :references:in-reply-to:subject:subject:from:from; s=sel2011a; t=1700928113; bh=4vBthPdOg4jG/sKlUk6PUhlbaP+39lr1kJJNsSclX54=; b= ZESokQEQtOZCtHzL4xli462h4r1a2faM3de4CyVRvQfHgdxsTvBBUwMx7Yf55KhO 5RQl8FF+GxK5+oKbfAPYjByrsrmG7qJfzqq/9bd5oozZMZYfFXNoLq0u54dHXPvP EsJRMK984b6mOt+iEJF1XNOd1CrgcNL3oF2uTl+rSkU= 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 z4SWboFLLAXT; Sat, 25 Nov 2023 17:01:53 +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 (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id A399C161E7; Sat, 25 Nov 2023 17:01:53 +0100 (CET) From: Jonas Bernoulli To: Joseph Turner , =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator In-Reply-To: <878r6mzezo.fsf@ushin.org> References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> Date: Sat, 25 Nov 2023 17:01:51 +0100 Message-ID: <87sf4tg6ts.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter 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.7 (-) Joseph Turner writes: > + (car (shorthands--find-if > + (lambda (short) > + (string-prefix-p short (match-string 1))) > + read-symbol-shorthands #'car))))) Or simply: (car (assoc (match-string 1) read-symbol-shorthands #'string-prefix-p)) From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 25 17:43:27 2023 Received: (at 67390) by debbugs.gnu.org; 25 Nov 2023 22:43:27 +0000 Received: from localhost ([127.0.0.1]:40443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r71N1-0000hS-8j for submit@debbugs.gnu.org; Sat, 25 Nov 2023 17:43:27 -0500 Received: from out-179.mta0.migadu.com ([2001:41d0:1004:224b::b3]:37027) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r71My-0000hE-8H for 67390@debbugs.gnu.org; Sat, 25 Nov 2023 17:43:25 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1700952195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZVTUocfwnxBI2E4GenOqygA8Yl7Ms04uToyk/fkBujc=; b=RctsIcXhUrz+QzQSjb/3XTBo1nXNNtQRKACWPKkLyj/rf/tdq6xnFD55MlZb6lZ+jJGhjA y2/G9ku2mUG13r5EGjJuky8heq2ucQwS3nO8YSLInC7yeJL5ubiB0cESFXKhoPtnNKhZv9 EBnde/pHBr6zY/T9+oiKDW2yC/vEW2bTQDPJRTQDaois74yzozoXmwp132mSxSQbFkhQTm 9jiJ6CPFQ4E0nix5K7atEl2+VpcpbGxhn/zUhq/KZtBOByC0MJOkL/mqIZNstq7p3sunyh Pwu2UC6+Jdh5dQMn0aMWKHalxTLkzQ7Igen2E0OkreOwXYNC7Jc6G/SEMtU21A== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Jonas Bernoulli Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Sat, 25 Nov 2023 14:42:48 -0800 In-reply-to: <87sf4tg6ts.fsf@bernoul.li> Message-ID: <875y1po3nk.fsf@ushin.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= 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 (-) --=-=-= Content-Type: text/plain Jonas Bernoulli writes: > Joseph Turner writes: > >> + (car (shorthands--find-if >> + (lambda (short) >> + (string-prefix-p short (match-string 1))) >> + read-symbol-shorthands #'car))))) > > Or simply: > (car (assoc (match-string 1) > read-symbol-shorthands > #'string-prefix-p)) Much nicer - see patch. Thanks, Jonas! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Support-shorthand-prefixes-besides.patch >From 5033a0e14950ed1622db78df1828c40de4b5a23a Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Fri, 24 Nov 2023 19:17:13 -0800 Subject: [PATCH] Support shorthand prefixes besides "-" * lisp/emacs-lisp/shorthands.el (shorthands-font-lock-shorthands): Add font locking to the shorthand prefix by checking if any of the shorthand prefixes in read-symbol-shorthands are a prefix for the current symbol name (bug#67390). Co-authored-by: Jonas Bernoulli --- lisp/emacs-lisp/shorthands.el | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el index 82200ab88e9..6ce9984a353 100644 --- a/lisp/emacs-lisp/shorthands.el +++ b/lisp/emacs-lisp/shorthands.el @@ -52,13 +52,6 @@ :version "28.1" :group 'font-lock-faces) -(defun shorthands--mismatch-from-end (str1 str2) - (cl-loop with l1 = (length str1) with l2 = (length str2) - for i from 1 - for i1 = (- l1 i) for i2 = (- l2 i) - while (and (>= i1 0) (>= i2 0) (eq (aref str1 i1) (aref str2 i2))) - finally (return (1- i)))) - (defun shorthands-font-lock-shorthands (limit) (when read-symbol-shorthands (while (re-search-forward @@ -69,10 +62,14 @@ font-lock-string-face))) (intern-soft (match-string 1)))) (sname (and probe (symbol-name probe))) - (mm (and sname (shorthands--mismatch-from-end - (match-string 1) sname)))) - (unless (or (null mm) (= mm (length sname))) - (add-face-text-property (match-beginning 1) (1+ (- (match-end 1) mm)) + (prefix (and sname + (not (string-equal (match-string 1) sname)) + (car (assoc (match-string 1) + read-symbol-shorthands + #'string-prefix-p))))) + (when prefix + (add-face-text-property (match-beginning 1) + (+ (match-beginning 1) (length prefix)) 'elisp-shorthand-font-lock-face)))))) (font-lock-add-keywords 'emacs-lisp-mode '((shorthands-font-lock-shorthands)) t) -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 26 08:52:58 2023 Received: (at 67390) by debbugs.gnu.org; 26 Nov 2023 13:52:58 +0000 Received: from localhost ([127.0.0.1]:40937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7FZC-0007Lw-3x for submit@debbugs.gnu.org; Sun, 26 Nov 2023 08:52:58 -0500 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:42299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7FZA-0007Lh-3G for 67390@debbugs.gnu.org; Sun, 26 Nov 2023 08:52:57 -0500 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507a5f2193bso3439518e87.1 for <67390@debbugs.gnu.org>; Sun, 26 Nov 2023 05:52:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701006764; x=1701611564; 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=LzAPH7lmC9sgsd8vvJWAGbbmzRtbFFkh3EOfE2aEupM=; b=MAq2AVFAUqRg55dSNtq5+QNvk2dJGCdDDMXbIOxIDsfJojee+6yW6A6oh9s0astjuf Ih9A8659vaejvNUaYAQ5oY6QFdvL1ayBEKLwPCL581CdUzkqpHajlo1Bjlxwq0ISU6gY 8rTLe2XMv1oNpI6r9AVcbSwZagH0etPdYj1sSmWaFc9ifagMoTPPYXZu+MWiz+BugIPD P1BK0yZKVjdTKQm1l1Ro7A2KrKyc/LI1vuaddiT19m77CfDTVwJKQzI6QrS4ibPho6Ng ZR7cX7KpHdiq5+o1Nm0W5IA1Dvq3TmktovASCd2nljPcdWCvWeqie0qATX6ibh8O9c2T 15oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701006764; x=1701611564; 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=LzAPH7lmC9sgsd8vvJWAGbbmzRtbFFkh3EOfE2aEupM=; b=uIds5049UTUma/bZHpv2Wz3xokJjzpFeyQywmjh936Gg5FhepSbgfoLaftceXe8sFO iHeuPT8XkQQFLsZM0Ooy5S9kWBvXSvQtKnwNEv4wTMtDeGAOxrANy76Kxk1DtJh7s8If B2fznZIfY76Cq8OUFC3Y331+tReIL6NHIKEHwBbZH82PP4oRf/Ca5WCXaq5guZc4Vuzg 3uetCWf4TKOZDQD3OZZF6KQKNbkpjVDEr8EhfDyFiFNx4UFtNp4LrkHssSMOSz+6wmv9 4VxBNCHWXvwAyQdXvc5wGFZJNpwg0XQJkA+lkvs2iJQmuygPMrtT3riYB+e0dwF2eTTW 1tHQ== X-Gm-Message-State: AOJu0YyzVnYVV3/YUsz0RFgQ0UzvR4VOe5pMYwSn3W1bPysA9Iix0eu8 ObKsVVUQ2EUGrK14xGWcKwYSIznKtBa3/GWn97OOdnJSsl4= X-Google-Smtp-Source: AGHT+IHTXMPuf8zLKonxTPBeoy3w/QnYnVM+P6qeZmWvvtq/qpctIhyVTjrQ/HypI8dKQP+0H0X2gNTm0etNTN4F7Uc= X-Received: by 2002:ac2:532d:0:b0:509:366b:a01c with SMTP id f13-20020ac2532d000000b00509366ba01cmr2289204lfh.14.1701006763571; Sun, 26 Nov 2023 05:52:43 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> In-Reply-To: <875y1po3nk.fsf@ushin.org> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sun, 26 Nov 2023 13:52:30 +0000 Message-ID: Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Joseph Turner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Jonas Bernoulli 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 (-) On Sat, Nov 25, 2023 at 10:43=E2=80=AFPM Joseph Turner w= rote: > > Jonas Bernoulli writes: > > > Joseph Turner writes: > > > >> + (car (shorthands--find-if > >> + (lambda (short) > >> + (string-prefix-p short (match-strin= g 1))) > >> + read-symbol-shorthands #'car))))) > > > > Or simply: > > (car (assoc (match-string 1) > > read-symbol-shorthands > > #'string-prefix-p)) > > Much nicer - see patch. Thanks, Jonas! So, I had a look at this patch and I think we should compare it with the patch after my sig, which keeps 'shorthands--mismatch-from-end' and also fixes this bug. The main difference I see is that my patch keeps doing one string comparison, via the mismatch function (which btw is now perfectly analogous to CL mismatch and thus correctly named). In the worst case, Josheph's patch does 1 + N where N is the number of shorthands. So this is a fundamental complexity change. Normally, that would be the end of the story, but here, it isn't. For two reasons. My version keeps a behaviour that can be considered buggy. If a shorthand prefix has a common suffix with the longhand prefix then that suffix will not be highlighted. Like: ;; Local Variables: ;; read-symbol-shorthands: (("bcrumb-" . "breadcrumb-") ;; End: Here only "b" would be highlighted, effectively showing the user how much typing was saved. Is this wrong? Does it makes sense to use shorthands like this? The other reason why this isn't the end of the story is that even if we take that bug for granted, the string comparison functions in Joshep's patch delegate to built-in C comparison operators, which are often much, much faster than Elisp. At least before the advent of native compilation, it used to be like this. Of course for a large enough N number of shorthands, my version wins, but that is probably not very common either (or is it? Not very hard to imagine a file making use of many libraries and shorthanding each of them?) So, benchmarking it will have to be, I'm afraid, because AFAIK font-locking is a very performance sensitive area of Emacs. In the meantime I will push my patch, but keep the bug open to see if it is worth pushing Joseph's version. Jo=C3=A3o diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el index 82200ab88e9..b0665a55695 100644 --- a/lisp/emacs-lisp/shorthands.el +++ b/lisp/emacs-lisp/shorthands.el @@ -53,11 +53,16 @@ elisp-shorthand-font-lock-face :group 'font-lock-faces) (defun shorthands--mismatch-from-end (str1 str2) + "Tell index of first mismatch in STR1 and STR2, from end. +The index is a valid 0-based index on STR1. Returns nil if STR1 +equals STR2. Return 0 if STR1 is a suffix of STR2." (cl-loop with l1 =3D (length str1) with l2 =3D (length str2) for i from 1 for i1 =3D (- l1 i) for i2 =3D (- l2 i) - while (and (>=3D i1 0) (>=3D i2 0) (eq (aref str1 i1) (aref str= 2 i2))) - finally (return (1- i)))) + while (eq (aref str1 i1) (aref str2 i2)) + if (zerop i2) return (if (zerop i1) nil i1) + if (zerop i1) return 0 + finally (return i1))) (defun shorthands-font-lock-shorthands (limit) (when read-symbol-shorthands @@ -69,10 +74,16 @@ shorthands-font-lock-shorthands font-lock-string-face))) (intern-soft (match-string 1)))) (sname (and probe (symbol-name probe))) - (mm (and sname (shorthands--mismatch-from-end - (match-string 1) sname)))) - (unless (or (null mm) (=3D mm (length sname))) - (add-face-text-property (match-beginning 1) (1+ (- (match-end 1)= mm)) + (mismatch (and sname (shorthands--mismatch-from-end + (match-string 1) sname))) + (guess (and mismatch (1+ mismatch)))) + (when guess + (when (and (< guess (1- (length (match-string 1)))) + ;; In bug#67390 we allow other separators + (eq (char-syntax (aref (match-string 1) guess)) ?_)) + (setq guess (1+ guess))) + (add-face-text-property (match-beginning 1) + (+ (match-beginning 1) guess) 'elisp-shorthand-font-lock-face)))))) (font-lock-add-keywords 'emacs-lisp-mode '((shorthands-font-lock-shorthands)) t) From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 26 15:38:55 2023 Received: (at 67390) by debbugs.gnu.org; 26 Nov 2023 20:38:55 +0000 Received: from localhost ([127.0.0.1]:42754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7Lu2-0002Wh-Rs for submit@debbugs.gnu.org; Sun, 26 Nov 2023 15:38:55 -0500 Received: from out-179.mta1.migadu.com ([2001:41d0:203:375::b3]:55104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7Ltx-0002WS-Hw for 67390@debbugs.gnu.org; Sun, 26 Nov 2023 15:38:54 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1701031121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vNd9+0C1hfToGlnG6JD4RsbR1unGO+XuS41UHv3FzHY=; b=aJu7YAdyfV7FnPF6PTX69oH5UWExfu01n4HqLPT0HROzcvnuoVmC89Zxdlb96Qa57hiygr pCDb3NwKZXvQgvXry5lA7Vo9vHKEO82qnn0PFlKcp9e/50kh9Vm605wLLPvXVT49lz3AwT gyG7R3lkizYJ7L+9rJPDjdtUZzC0v4lbBpvU7mIWoRN5x0bDssVe2nKGKbnNNzPj28GM8M jREgZRZGZ1l2yOSYosCxcoyNJnYx4O+ePpxPONuvnI8EYUjAI5+jDQ2857SYy8IKtg8Dlv xywS0iNKOoYQgbsnGtKdEJJe6alRkTHAJVgc8mqRMQBvodq2Ee0wJkgLdaslog== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Sun, 26 Nov 2023 12:35:32 -0800 In-reply-to: Message-ID: <871qccqmgi.fsf@ushin.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Jonas Bernoulli 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 (-) Jo=C3=A3o T=C3=A1vora writes: > On Sat, Nov 25, 2023 at 10:43=E2=80=AFPM Joseph Turner = wrote: >> >> Jonas Bernoulli writes: >> >> > Joseph Turner writes: >> > >> >> + (car (shorthands--find-if >> >> + (lambda (short) >> >> + (string-prefix-p short (match-stri= ng 1))) >> >> + read-symbol-shorthands #'car))))) >> > >> > Or simply: >> > (car (assoc (match-string 1) >> > read-symbol-shorthands >> > #'string-prefix-p)) >> >> Much nicer - see patch. Thanks, Jonas! > > So, I had a look at this patch and I think we should compare it > with the patch after my sig, which keeps 'shorthands--mismatch-from-end' > and also fixes this bug. > > The main difference I see is that my patch keeps doing one string > comparison, via the mismatch function (which btw is now perfectly > analogous to CL mismatch and thus correctly named). In the worst case, > Josheph's patch does 1 + N where N is the number of shorthands. So > this is a fundamental complexity change. > > Normally, that would be the end of the story, but here, it isn't. > For two reasons. > > My version keeps a behaviour that can be considered buggy. > If a shorthand prefix has a common suffix with the longhand prefix > then that suffix will not be highlighted. Like: > > ;; Local Variables: > ;; read-symbol-shorthands: (("bcrumb-" . "breadcrumb-") > ;; End: > > Here only "b" would be highlighted, effectively showing the user > how much typing was saved. Is this wrong? Does it makes sense > to use shorthands like this? I would expect the entire the shorthand to be highlit, I don't feeling strongly about this. > The other reason why this isn't the end of the story is that even > if we take that bug for granted, the string comparison functions in > Joshep's patch delegate to built-in C comparison operators, which are > often much, much faster than Elisp. At least before the advent of native > compilation, it used to be like this. Of course for a large enough N > number of shorthands, my version wins, but that is probably not very > common either (or is it? Not very hard to imagine a file making use > of many libraries and shorthanding each of them?) > > So, benchmarking it will have to be, I'm afraid, because AFAIK > font-locking is a very performance sensitive area of Emacs. Yes. I would like to learn how to do this! > In the meantime I will push my patch, but keep the bug open to see > if it is worth pushing Joseph's version. Thank you!! I'm happy to discuss this further if others are interested. Joseph From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 26 17:02:30 2023 Received: (at 67390) by debbugs.gnu.org; 26 Nov 2023 22:02:30 +0000 Received: from localhost ([127.0.0.1]:42800 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7NCw-0004kM-Ch for submit@debbugs.gnu.org; Sun, 26 Nov 2023 17:02:30 -0500 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:57638) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7NCr-0004jz-0x for 67390@debbugs.gnu.org; Sun, 26 Nov 2023 17:02:28 -0500 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50aab3bf71fso4909457e87.3 for <67390@debbugs.gnu.org>; Sun, 26 Nov 2023 14:02:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701036133; x=1701640933; 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=gix8aCek+Hd5WJGHyo02ZzpVcn7p7nisACqQK6dUQVE=; b=nSOc64ntQdjJ2kXVPJEeacmVvtNXm+/d52Xxf/wbU9tx2Tt/koLHsAVja9/78c7JkK C3bgSjp2KGDHp6eIEL1ZblINkevM6BU/CRRUZvLOuA0Zf1+f67W6ZoL2jPKNdqrjlBOW cRE9qb9xb6WKFsQNtYYvseckDZkBFilqL1/7IVdf2iRB+rlvpjmfTMhz89z4RV8Wm4TT y2TS9mGzqNLQ/Pf+tPV4jH305npPTfj9TuLocAlNNBNCxg0W9QI8BZjZkP9dr4Qo0Dak 6tI9BkK4KC40iebmwmdz7T8E4pNw+FmVXwMg608UQZ27Q01zH7mluSuYLO/ZloI55VnM CdzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701036133; x=1701640933; 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=gix8aCek+Hd5WJGHyo02ZzpVcn7p7nisACqQK6dUQVE=; b=ujXNp+9hZGIXDyQQj29J6ggOEyoQVNzZrcHC2U+bgs4IhoYPHtqUz5quBmVUIjMMdU dS/AZqyd2Z08fyDe/2iaFNkzQ0Bnpv1c8GbD/jvRbkyxdu7FrMb6s6ZGCEBzTeCdWDAs 1fLmP0XdxVmdtPLQrSoV3HDkR0D5S0CnQgZh4WkVYZuJpXCc9Vi0Ki3xjk7EmlNrgtBt 57p7r9hIoYzJ941smDzbg/e8H/6U2kyJocabyYZ92ghtCYQn+76nQpuNTPRPske+SI17 IE/LMghw62YivBrkrRwUzX49+0Dwz9oj4nhO3nvq9H1L2+awWAYc7cBouUBDblgc5XL1 eFdQ== X-Gm-Message-State: AOJu0YzcXAM16nL5qZEQrTKmUydI3Sn/jrGcSJ8xK89Uk2aokQbyZBhj 1c8K52AsE1M7tcofnHr/jSr+tN9po+8Fnrnep9024Q4eU+I= X-Google-Smtp-Source: AGHT+IGC/3wA5/hVXxJcT+AtK8RL5ppFHjELJ+ZG4/cADhIybXSjaoExn4AdceFIIrjMVFSldhmRt80nvV4GDe1O1x8= X-Received: by 2002:a05:6512:3e02:b0:508:12f6:ff07 with SMTP id i2-20020a0565123e0200b0050812f6ff07mr8167121lfv.48.1701036132899; Sun, 26 Nov 2023 14:02:12 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> <871qccqmgi.fsf@ushin.org> In-Reply-To: <871qccqmgi.fsf@ushin.org> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sun, 26 Nov 2023 22:02:01 +0000 Message-ID: Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Joseph Turner , Eli Zaretskii Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Jonas Bernoulli 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 (-) On Sun, Nov 26, 2023 at 8:38=E2=80=AFPM Joseph Turner wr= ote: > > Jo=C3=A3o T=C3=A1vora writes: > > > On Sat, Nov 25, 2023 at 10:43=E2=80=AFPM Joseph Turner wrote: > > So, benchmarking it will have to be, I'm afraid, because AFAIK > > font-locking is a very performance sensitive area of Emacs. > > Yes. I would like to learn how to do this! I'm CCing Eli. In the past, ISTR, Eli suggested to benchmark such things by visiting a very large file in its beginning, then scrolling down by holding the down arrow or PgDn for some fixed time period, like 30 seconds. The Emacs that scrolls the farthest is the most performant. Not entirely fail-proof (other processes may interfere, etc), but not bad either. So here you could create very large fictitious Elisp file with 0, 1, 3 and 10 shorthands each and then run your version vs my version and record the final line numbers. Then show the files and the numbers. > > In the meantime I will push my patch, but keep the bug open to see > > if it is worth pushing Joseph's version. > > Thank you!! Now done in 36941e9e6a (master). > I'm happy to discuss this further if others are interested. I'm keeping this open. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 26 23:12:23 2023 Received: (at 67390) by debbugs.gnu.org; 27 Nov 2023 04:12:23 +0000 Received: from localhost ([127.0.0.1]:43062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7Syt-0006rx-0a for submit@debbugs.gnu.org; Sun, 26 Nov 2023 23:12:23 -0500 Received: from out-189.mta1.migadu.com ([2001:41d0:203:375::bd]:60580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7Syn-0006rj-TQ for 67390@debbugs.gnu.org; Sun, 26 Nov 2023 23:12:21 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> <871qccqmgi.fsf@ushin.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1701058330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y6moiMXCpl88/MzE4Ed60fIrWAj8z97Nb94tHiGcB5U=; b=n1kdtdxQxJje7GgIXkvO6alwin2Jmbdkce3j/nTWP92Y2jhcnJwB4cNGOWiaxFaIRJMSL0 rM48r9Uwx6kPkw7HGDshZVoOKYg+bNZYiqryXaTemCWPckluNPaXs2nyL3UgwTYbEWDuPC kW0MHB/YpbsKkAp2mEJ3nPe8tjySpEYiDQS6ubXXP//BrtizY143KcU2YaLAuU8Ov6zyzm CKY9HpLZ7xU8uqk+xq5aoENTMrb9+hWZXI41NZgdW6CdmnhnZOFhe1WgfNz4nqDgKIez9k sENKgXr1kNWZ8UHwWB/q9lcwacW4S3VzEYRSPlUSbFw4rgZ8HoaR3gE83EGi2A== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Sun, 26 Nov 2023 19:48:38 -0800 In-reply-to: Message-ID: <878r6jq1gp.fsf@ushin.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli 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 (-) Jo=C3=A3o T=C3=A1vora writes: > In the past, ISTR, Eli suggested to benchmark such things by visiting a > very large file in its beginning, then scrolling down by holding > the down arrow or PgDn for some fixed time period, like 30 seconds. > The Emacs that scrolls the farthest is the most performant. Not > entirely fail-proof (other processes may interfere, etc), but not > bad either. > > So here you could create very large fictitious Elisp file with 0, 1, 3 and > 10 shorthands each and then run your version vs my version and record > the final line numbers. Then show the files and the numbers. In a 2.5M Elisp file with 0 shorthand prefixes, after 30s of pressing C-v (scroll-up-command), point was on line 19238. I then tried the same file with 1 and 4 shorthands, and I got basically the same result: | With 1 shorthand prefix | | |-------------------------+-------| | No patch | 19447 | | mismatch | 19238 | | compare all prefixes | 19024 | | With 4 shorthand prefixes | | |---------------------------+-------| | No patch | 19211 | | mismatch | 19521 | | compare all prefixes | 19339 | There is a big margin of error (probably around 500-1000 lines) since my method wasn't at all exact. I stopped holding C-v when the stopwatch on another device hit 30s, and I might have held for =C2=B11s. If this approach to benchmarking is valid, I think it indicates that shorthands has no significant effect on performance in either case, though there may be a greater difference with more shorthand prefixes. > My version keeps a behaviour that can be considered buggy. > If a shorthand prefix has a common suffix with the longhand prefix > then that suffix will not be highlighted. Like: > ;; Local Variables: > ;; read-symbol-shorthands: (("bcrumb-" . "breadcrumb-") > ;; End: > Here only "b" would be highlighted, effectively showing the user > how much typing was saved. Is this wrong? Does it makes sense > to use shorthands like this? Another example case: ;; Local Variables: ;; read-symbol-shorthands: (("aw-" . "ace-window-") ;; End: Here only "a" would be highlighted. Thanks, Joseph From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 07:11:28 2023 Received: (at 67390) by debbugs.gnu.org; 27 Nov 2023 12:11:28 +0000 Received: from localhost ([127.0.0.1]:43408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7aSW-0003DO-2R for submit@debbugs.gnu.org; Mon, 27 Nov 2023 07:11:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7aSR-0003D9-3i for 67390@debbugs.gnu.org; Mon, 27 Nov 2023 07:11:26 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7aSD-0003oo-HQ; Mon, 27 Nov 2023 07:11:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=fLXy3cDTN7IaNAiZ5JQMlSXRiUtPJUFyaTJg/A7HKVU=; b=ba1QWSlpVzeALWkNwZkP DJwLFy8haS7wNz/N7oaldX/d4eokEHML5CwhP7fJ8FpFCKusSaosQkLh6BZExwKClIGwcVhpJhF8k yl/5lgOox+LagJlgwEOgeABRCD+ZJGReL1zhJzQazt4I9XMZVg6ee5C/m7uvr0bTeROOVunh6vvlI 9pUbAXwjYjIMFSkpOn/Sam4paZhIBJmbSeCzupfsKRpI2EtaQ39EGARxP2qq7hKkhOwfTxaAK5TGx /EkPea/QBz5D7/G+YzMojTaE+x14G1fWh3U26DQAOq6F+HU6npOOauCFORuxAuraBGsuopT1K4FsR 43woQccWrSetGg==; Date: Mon, 27 Nov 2023 14:10:53 +0200 Message-Id: <83bkbf9z1u.fsf@gnu.org> From: Eli Zaretskii To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= In-Reply-To: (message from =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= on Sun, 26 Nov 2023 22:02:01 +0000) Subject: Re: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> <871qccqmgi.fsf@ushin.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67390 Cc: joseph@ushin.org, 67390@debbugs.gnu.org, jonas@bernoul.li, adam@alphapapa.net 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: -3.3 (---) > From: João Távora > Date: Sun, 26 Nov 2023 22:02:01 +0000 > Cc: Jonas Bernoulli , 67390@debbugs.gnu.org, > Adam Porter > > On Sun, Nov 26, 2023 at 8:38 PM Joseph Turner wrote: > > > > João Távora writes: > > > > > On Sat, Nov 25, 2023 at 10:43 PM Joseph Turner wrote: > > > > So, benchmarking it will have to be, I'm afraid, because AFAIK > > > font-locking is a very performance sensitive area of Emacs. > > > > Yes. I would like to learn how to do this! > > I'm CCing Eli. > > In the past, ISTR, Eli suggested to benchmark such things by visiting a > very large file in its beginning, then scrolling down by holding > the down arrow or PgDn for some fixed time period, like 30 seconds. > The Emacs that scrolls the farthest is the most performant. Not > entirely fail-proof (other processes may interfere, etc), but not > bad either. I still recommend this method. Something like the below: (defun scroll-up-benchmark () (interactive) (let ((oldgc gcs-done) (oldtime (float-time))) (condition-case nil (while t (scroll-up) (redisplay)) (error (message "GCs: %d Elapsed time: %f seconds" (- gcs-done oldgc) (- (float-time) oldtime)))))) Evaluate the above, and the invoke it at the beginning of a large file. Then compare the timings with different font-lock arrangements. A variant is to scroll by N lines, not by pages. Just change the above to call scroll-up with the argument of N, for example 1 (or any other number, if you want). From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 29 03:22:28 2023 Received: (at 67390) by debbugs.gnu.org; 29 Nov 2023 08:22:28 +0000 Received: from localhost ([127.0.0.1]:48751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8Fq0-0006rn-0H for submit@debbugs.gnu.org; Wed, 29 Nov 2023 03:22:28 -0500 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:61817) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8Fpw-0006rY-Rl for 67390@debbugs.gnu.org; Wed, 29 Nov 2023 03:22:26 -0500 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50bc7706520so187939e87.3 for <67390@debbugs.gnu.org>; Wed, 29 Nov 2023 00:22:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701246131; x=1701850931; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9SVIHpDNeA1YGHX3lHRPLIBTC5gijmfmsP5W19XFQK4=; b=WUC055ZQWRCnSj07qJ5QBNvEB//WACA8gqFaLvcDOS5fRWdYqpJbrY4POn+FT7lkPX 9RL+8Qr7rgbLknzRWAorVGVtuGjm+OuV0CsbkpOx1QtFP+E8uGNbANWqJvpFNPNOddMZ bXn2ZTBuzRsqD6+Q3QbsOzcQfSFdqb1ud1UiCA1leiHJGovmI0IKVuvZXjokhBZss6yN mkIKljQhiaZ2Hm5KpriMlcMHNwnkT9ad4AZZBPe/2Hieu9xxLCQBRfOCOC//vsqwzWfy SFnPJ31ygTI4G9N4/75D8dcXMAHOIqiZOIRfGsv2IRWVG67QqoWJ0of+SOtQrJbwrgbW OxQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701246131; x=1701850931; h=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=9SVIHpDNeA1YGHX3lHRPLIBTC5gijmfmsP5W19XFQK4=; b=YUrfG6VetoHsPCc74etI1QcMlz0PIaXwA9AOlPDvKudAdeOWb5T7tGtzerLU+yAMbR cGVjvSVJDVacmObBFesFvmjsJArVOR1tP49LG2Dmq3/bY6GE2vKUU3MwYatvMhSWcQ1k o7hOQbxINkW4QVBzFmJNHzqZj2Qt22WahhBwURZ/xpg1KdnaZMtEyTF3uwUCr99Wrcsx Pb8AcqKA2OPTotzTGYGm/rUBnffx1a3O2SZx6SocTK5laqCF7CvvPO+XcbZIV56fLo6w OtTMGI+Ak2w+PgqotoBpOwE+FcAwsoXQdAN6FWa2w9U9nV51RMy67+dGrzxo6jqoP8fI JWtQ== X-Gm-Message-State: AOJu0YyU/tDWbVmc3QJsLBm9cU0fSfDPcQJZuW5A7P3zNHLwkllBKfxx LBHQc57OUXFu44g/G2bu7w8i8Fj//7BsGcPpGSx/Bz87 X-Google-Smtp-Source: AGHT+IFhM8g8JVeFko+vvUjPQvLOOaDpOYv+X3HTV2UJ5p/xbROQYzgSyUdB8tXDOnAC3oPk3GUz/o6gZ1Nk/cvF0ZI= X-Received: by 2002:a05:6512:5cc:b0:50b:c6c7:a777 with SMTP id o12-20020a05651205cc00b0050bc6c7a777mr375598lfo.41.1701246131339; Wed, 29 Nov 2023 00:22:11 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> <871qccqmgi.fsf@ushin.org> <83bkbf9z1u.fsf@gnu.org> In-Reply-To: <83bkbf9z1u.fsf@gnu.org> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Wed, 29 Nov 2023 08:21:59 +0000 Message-ID: Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Eli Zaretskii Content-Type: multipart/alternative; boundary="0000000000005587c3060b463bff" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: Joseph Turner , 67390@debbugs.gnu.org, Jonas Bernoulli , Adam Porter 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 (-) --0000000000005587c3060b463bff Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Nov 27, 2023, 12:12 Eli Zaretskii wrote: > > From: Jo=C3=A3o T=C3=A1vora > > Date: Sun, 26 Nov 2023 22:02:01 +0000 > > Cc: Jonas Bernoulli , 67390@debbugs.gnu.org, > > Adam Porter > > > > On Sun, Nov 26, 2023 at 8:38=E2=80=AFPM Joseph Turner wrote: > > > > > > Jo=C3=A3o T=C3=A1vora writes: > > > > > > > On Sat, Nov 25, 2023 at 10:43=E2=80=AFPM Joseph Turner > wrote: > > > > > > So, benchmarking it will have to be, I'm afraid, because AFAIK > > > > font-locking is a very performance sensitive area of Emacs. > > > > > > Yes. I would like to learn how to do this! > > > > I'm CCing Eli. > > > > In the past, ISTR, Eli suggested to benchmark such things by visiting a > > very large file in its beginning, then scrolling down by holding > > the down arrow or PgDn for some fixed time period, like 30 seconds. > > The Emacs that scrolls the farthest is the most performant. Not > > entirely fail-proof (other processes may interfere, etc), but not > > bad either. > > I still recommend this method. Something like the below: > > (defun scroll-up-benchmark () > (interactive) > (let ((oldgc gcs-done) > (oldtime (float-time))) > (condition-case nil (while t (scroll-up) (redisplay)) > (error (message "GCs: %d Elapsed time: %f seconds" > (- gcs-done oldgc) (- (float-time) oldtime)))))) > > Evaluate the above, and the invoke it at the beginning of a large > file. Then compare the timings with different font-lock arrangements. > > A variant is to scroll by N lines, not by pages. Just change the > above to call scroll-up with the argument of N, for example 1 (or any > other number, if you want). > Joseph can you try these variations? They're slightly more exact. Also show at least one of the large lisp files or tell me how to generate one. If you still don't find any significant slowdown, I think we can merge your patch. Jo=C3=A3o > --0000000000005587c3060b463bff Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Nov 27, 2023, 12:12 Eli Zaretskii <eliz@gnu.org> wrote:
> From: Jo=C3=A3o T=C3=A1vora <joaotavora@gmail.com>= ;
> Date: Sun, 26 Nov 2023 22:02:01 +0000
> Cc: Jonas Bernoulli <jonas@bernoul.li>, 67390@debbugs.gnu.o= rg,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Adam Porter <adam@alphapapa.net> >
> On Sun, Nov 26, 2023 at 8:38=E2=80=AFPM Joseph Turner <joseph@ushin.o= rg> wrote:
> >
> > Jo=C3=A3o T=C3=A1vora <joaotavora@gmail.com> writes:<= br> > >
> > > On Sat, Nov 25, 2023 at 10:43=E2=80=AFPM Joseph Turner <<= a href=3D"mailto:joseph@ushin.org" target=3D"_blank" rel=3D"noreferrer">jos= eph@ushin.org> wrote:
>
> > > So, benchmarking it will have to be, I'm afraid, because= AFAIK
> > > font-locking is a very performance sensitive area of Emacs.<= br> > >
> > Yes.=C2=A0 I would like to learn how to do this!
>
> I'm CCing Eli.
>
> In the past, ISTR, Eli suggested to benchmark such things by visiting = a
> very large file in its beginning, then scrolling down by holding
> the down arrow or PgDn for some fixed time period, like 30 seconds. > The=C2=A0 Emacs that scrolls the farthest is the most performant.=C2= =A0 Not
> entirely fail-proof (other processes may interfere, etc), but not
> bad either.

I still recommend this method.=C2=A0 Something like the below:

=C2=A0 (defun scroll-up-benchmark ()
=C2=A0 =C2=A0 (interactive)
=C2=A0 =C2=A0 (let ((oldgc gcs-done)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (oldtime (float-time)))
=C2=A0 =C2=A0 =C2=A0 (condition-case nil (while t (scroll-up) (redisplay))<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error (message "GCs: %d Elapsed time: %f = seconds"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (- gcs-done oldgc) (- (float-time) oldtime))))))

Evaluate the above, and the invoke it at the beginning of a large
file.=C2=A0 Then compare the timings with different font-lock arrangements.=

A variant is to scroll by N lines, not by pages.=C2=A0 Just change the
above to call scroll-up with the argument of N, for example 1 (or any
other number, if you want).
<= br>
Joseph can you try these variations? They're= slightly more exact. Also show at least one of the large lisp files or tel= l me how to generate one. If you still don't find any significant slowd= own, I think we can merge your patch.

Jo=C3=A3o
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">
--0000000000005587c3060b463bff-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 29 04:29:51 2023 Received: (at 67390) by debbugs.gnu.org; 29 Nov 2023 09:29:51 +0000 Received: from localhost ([127.0.0.1]:48903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8GtC-0000QO-3r for submit@debbugs.gnu.org; Wed, 29 Nov 2023 04:29:51 -0500 Received: from out-177.mta0.migadu.com ([91.218.175.177]:29001) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8Gt6-0000Pr-MQ for 67390@debbugs.gnu.org; Wed, 29 Nov 2023 04:29:48 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> <871qccqmgi.fsf@ushin.org> <83bkbf9z1u.fsf@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1701250175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hNARGsaGDsF5wu76jhZV3D/AviKgjkArLRzFC4vd27M=; b=ixW4wAcjA5IAsPLX7ez7Ys9184J5UVYgc9At4UzHuYjm6CqjdMJJiLiheYJppkuC1msx2w nv57sLBIc4rUIQufFmqs8c9pgebZHNM5nMORWpkS24suMXR+n/a87cIBQZ9ujuO6L8HkC/ ffQIRBJy+uGsZuk0R5wwSEivNsmtzI+0wLGTqeggzUBTM1JbE8w7mDdt38KVnkJ8+3W/Vl vzcY0wciG4cR4j6XDBOkhj0GujqcSbYBGJzFa1gx8EbzNZ0K6vS3HqRWv9UecJ1EafUdL3 mSlVZBoZMVnvzpntcCjoa2Cl/VcrktLg2dkrTSlxhY69hgO9tViDUuLJoiBgRA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Wed, 29 Nov 2023 01:12:52 -0800 In-reply-to: Message-ID: <87jzq0gb5x.fsf@ushin.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli 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 (-) Jo=C3=A3o T=C3=A1vora writes: > On Mon, Nov 27, 2023, 12:12 Eli Zaretskii wrote: > > > From: Jo=C3=A3o T=C3=A1vora > > Date: Sun, 26 Nov 2023 22:02:01 +0000 > > Cc: Jonas Bernoulli , 67390@debbugs.gnu.org, > > Adam Porter > > > > On Sun, Nov 26, 2023 at 8:38=E2=80=AFPM Joseph Turner wrote: > > > > > > Jo=C3=A3o T=C3=A1vora writes: > > > > > > > On Sat, Nov 25, 2023 at 10:43=E2=80=AFPM Joseph Turner wrote: > > > > > > So, benchmarking it will have to be, I'm afraid, because AFAIK > > > > font-locking is a very performance sensitive area of Emacs. > > > > > > Yes. I would like to learn how to do this! > > > > I'm CCing Eli. > > > > In the past, ISTR, Eli suggested to benchmark such things by visiting a > > very large file in its beginning, then scrolling down by holding > > the down arrow or PgDn for some fixed time period, like 30 seconds. > > The Emacs that scrolls the farthest is the most performant. Not > > entirely fail-proof (other processes may interfere, etc), but not > > bad either. > > I still recommend this method. Something like the below: > > (defun scroll-up-benchmark () > (interactive) > (let ((oldgc gcs-done) > (oldtime (float-time))) > (condition-case nil (while t (scroll-up) (redisplay)) > (error (message "GCs: %d Elapsed time: %f seconds" > (- gcs-done oldgc) (- (float-time) oldtime)))))) > > Evaluate the above, and the invoke it at the beginning of a large > file. Then compare the timings with different font-lock arrangements. > > A variant is to scroll by N lines, not by pages. Just change the > above to call scroll-up with the argument of N, for example 1 (or any > other number, if you want). > > Joseph can you try these variations? They're slightly more exact. Also sh= ow at least one of the large lisp files or tell me how to generate > one. If you still don't find any significant slowdown, I think we can mer= ge your patch. I'm happy to try Eli's variation if you don't beat me to it ;) My large lisp file consisted of copy-pasting with a kbd macro the body of https://git.sr.ht/~ushin/hyperdrive.el/tree/master/item/hyperdrive-lib.el until the file reached ~50K lines -- well over the limit I expected to reach on my machine. One potential issue with the patch is that multiple shorthand prefixes might match, while assoc will return the first matching cons pair read-symbol-shorthand. For example in hyperdrive-lib.el, we use the following shorthands in order to display "//" instead of "/-" as the prefix separator for private symbols, like "h//format-entry" instead of "h/-format-entry": ;; read-symbol-shorthands: ( ;; ("he//" . "hyperdrive-entry--") ;; ("he/" . "hyperdrive-entry-") ;; ("h//" . "hyperdrive--") ;; ("h/" . "hyperdrive-")) However, if we rearrange the values like: ;; read-symbol-shorthands: ( ;; ("he/" . "hyperdrive-entry-") ;; ("he//" . "hyperdrive-entry--") ;; ("h/" . "hyperdrive-") ;; ("h//" . "hyperdrive--")) then shorthands doesn't add fontification for either "h//" or "he//". (This surprised me - I was expecting to see just the "h/" and "he/" highlit) However, I'm starting to wonder whether this is a case of user error. Should we avoid overlapping shorthand prefixes? Thank you!! Joseph From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 29 08:30:51 2023 Received: (at 67390) by debbugs.gnu.org; 29 Nov 2023 13:30:52 +0000 Received: from localhost ([127.0.0.1]:49133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8KeR-0000W4-GV for submit@debbugs.gnu.org; Wed, 29 Nov 2023 08:30:51 -0500 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:42284) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8KeO-0000DT-KB for 67390@debbugs.gnu.org; Wed, 29 Nov 2023 08:30:50 -0500 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-50bb92811c0so906955e87.1 for <67390@debbugs.gnu.org>; Wed, 29 Nov 2023 05:30:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701264634; x=1701869434; 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=xmDdKT7PqhoJTPHKxQ3qAxG2j7oH+E/LMwnMF9VrTHo=; b=DD8o0iyMXSZARBgPHHNNruvPXOo11mDRHo/djqulOyLIb82PJAtrusmUU7m7O547Ub ZilYcsz79QtzSg92f22YGs/3SuAJ+LGCuB08CTIAtAtZKKdGFx2VJlpvEPaKUw27uOxH XkjwsaobgNwx9aL2Ihfx8SqqN53GUoT2AedXLaHji+DF0aor9YAjxE913vNiUvUEJeQT 4RDtU5pn21GxPu0v4VKqiudAkBpNcL9UY9345rmAVl2gBelc0KudBgMm81lbRg9gjY15 HFlWwZndWggnXVnzjvZx/9nEyba0FF9ChtvdSCsyo+Hr/0tKMahHiMHdbGVSW+EBvt2R 3eBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701264634; x=1701869434; 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=xmDdKT7PqhoJTPHKxQ3qAxG2j7oH+E/LMwnMF9VrTHo=; b=gDylr8COj3bMkDKazhviFzcHJdoqe1UgNqZe+uOOz2hJV+VTGPJ+bu9LBuE7idB8Gk yl3+/E95x6WRpWSgboDt8ITKE0tDzB0Fvvv7kszdIJ1rhYloLAvUmQpy0MtW4D6OW4UE DAcQFIYxaGpQwo4zlSYE13h6OIBh+/Aq0w1eTcHE0Sncx1a/cySe+2y2MWgkHDAeOYts X8V/DjHc7MV4SfEybzTcJPTTrc5GV1UPmn1Sxn6HCNBFuKPTByqxlrns5qfvDxrpqxwM 2wdcwbBQ6uLyAkaUbPFPrWprXg3x5TVCc25n0rkg+6lmLuRsUWS89kZ3EH2xxHnpc7D1 CPOg== X-Gm-Message-State: AOJu0YwesyG41UrNYw9f+UNmCPRVYmTPjYFbVkrqKvgq/PehTrDKV3GW CJJFO9QFYpwlFHi5kFjiNdOgryZ098FAOpy/sj/A5D/nviw6SA== X-Google-Smtp-Source: AGHT+IFX6s+xpsXR7PU5u9SXJs0Tb5Wwmxr3EgGBEfZvdvkLWRk4ms+k4D+fmOR2xSBEGI3pnliXSxlbyQMeihZLnBM= X-Received: by 2002:a05:6512:41c:b0:50b:c5b3:6445 with SMTP id u28-20020a056512041c00b0050bc5b36445mr530077lfk.8.1701264633982; Wed, 29 Nov 2023 05:30:33 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> In-Reply-To: <87sf4tg6ts.fsf@bernoul.li> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Wed, 29 Nov 2023 13:30:22 +0000 Message-ID: Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Jonas Bernoulli Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: Joseph Turner , 67390@debbugs.gnu.org, Adam Porter 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 (-) On Sat, Nov 25, 2023 at 4:03=E2=80=AFPM Jonas Bernoulli via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > > Joseph Turner writes: > > > + (car (shorthands--find-if > > + (lambda (short) > > + (string-prefix-p short (match-string= 1))) > > + read-symbol-shorthands #'car))))) > > Or simply: > (car (assoc (match-string 1) > read-symbol-shorthands > #'string-prefix-p)) I don't think it works, at least in my 'assoc', the order of string-prefix-p arguments must be switched. Pity assoc or string-prefix-p decs didn't coordinate this. (assoc probe read-symbol-shorthands (lambda (a b) (string-prefix-p b a))) works From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 29 08:56:57 2023 Received: (at 67390) by debbugs.gnu.org; 29 Nov 2023 13:56:57 +0000 Received: from localhost ([127.0.0.1]:49160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8L3g-0001hZ-ME for submit@debbugs.gnu.org; Wed, 29 Nov 2023 08:56:57 -0500 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:48577) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8L3e-0001hJ-8E for 67390@debbugs.gnu.org; Wed, 29 Nov 2023 08:56:55 -0500 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50bbef0e5d5so2300278e87.1 for <67390@debbugs.gnu.org>; Wed, 29 Nov 2023 05:56:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701266201; x=1701871001; 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=LDaKNzgnx79HYT/ba6Jv/zFJ2VDZguVQV4914W8w0Yc=; b=Uwi0XifDbZkDyXaADsWtKsrGyriQkIfnvuS+tH2bOvdbonBQWQU2NEg+HkuHBp8SZQ 6OV/TAoi4C8uXBSe/XAv6UX54tXSZFKCEtU/bn3R2A2wYXgVEZV+zjcUyJH2AebbrVzb T9Wx8kx2nSrujYUldGEodk3QYu7maJukrjjqMZElzVHOmnmnGYoTQHaw7fiAWc4/QXCi KQJ4G64G/Iqcr31lVNmZaRbx9YyYGH+AbpDAG7lxnoC2o4XI4z4wupdzo7Ftuq0UxGbc FQ2XN+j6Q5ZI4BSBIvG4v0FD4MQG0dW3opavJqb5vPAArqW3toSxFS7tJ4lecAXJYfXm /u6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701266201; x=1701871001; 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=LDaKNzgnx79HYT/ba6Jv/zFJ2VDZguVQV4914W8w0Yc=; b=FElebSV8uDH3BCcz1XIHeBSTnlb0GMmz61VRQ1XbrHuDZEMJIxCsYoWjEi57sUouxC gNn2niZTf4R8K3pOWZ8aPS6dGCQwx2nvB6EZx2vuk/6xWivxInNmqTF7adZLvIVr60KT FCuxS4d+PGTOBcqqAu4QQ3NJbnK/haLjcTt1f92pshdV20K5A7GY5iFxTRvcTSJl82R2 1+CY3A0GWHUUfrSLbUQpkj5v0USKg+1NZvvP/D1pJAudIP9eqLhsWi7SG0SaooKFndrT NxnJXp10yy449usU4UszeqGy9mxCw2qqv/XN74j8D290tmkLjuKFOmof4ezoFvFVdft6 Ha/A== X-Gm-Message-State: AOJu0Yz/tf3vIG84yG/X1YNBPR6FH7904u8HrME1p79rZJlwEnXAl1/H UC26CJG6zEUSIU3YoH2mLhu2UnpkxUEEe09Y1kg= X-Google-Smtp-Source: AGHT+IFDvaZrYViYFceY8uFKd76zjhXYSgftJYaRoubUeoku7TOmez2HC/HopqIUU3bxJlJgOgOhi2lND1H4NehUv9A= X-Received: by 2002:a05:6512:e84:b0:50b:c975:8b30 with SMTP id bi4-20020a0565120e8400b0050bc9758b30mr182715lfb.66.1701266200452; Wed, 29 Nov 2023 05:56:40 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> <871qccqmgi.fsf@ushin.org> <83bkbf9z1u.fsf@gnu.org> <87jzq0gb5x.fsf@ushin.org> In-Reply-To: <87jzq0gb5x.fsf@ushin.org> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Wed, 29 Nov 2023 13:56:28 +0000 Message-ID: Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Joseph Turner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli 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 (-) On Wed, Nov 29, 2023 at 9:29=E2=80=AFAM Joseph Turner wr= ote: > > Joseph can you try these variations? They're slightly more exact. Also = show at least one of the large lisp files or tell me how to generate > > one. If you still don't find any significant slowdown, I think we can m= erge your patch. > > I'm happy to try Eli's variation if you don't beat me to it ;) Great. No I don't think I will beat you to it :-), you have the machinery setup already. > However, if we rearrange the values like: > > ;; read-symbol-shorthands: ( > ;; ("he/" . "hyperdrive-entry-") > ;; ("he//" . "hyperdrive-entry--") > ;; ("h/" . "hyperdrive-") > ;; ("h//" . "hyperdrive--")) > > then shorthands doesn't add fontification for either "h//" or "he//". > (This surprised me - I was expecting to see just the "h/" and "he/" > highlit) > > However, I'm starting to wonder whether this is a case of user error. > Should we avoid overlapping shorthand prefixes? No, but you should make sure the longer prefixes appear before. It's not only a font-locking issue, if the shorter shorthand appears before it could read to an unintended symbol. If shorthands are (("h/" . "hello-") ("h//" . "hyperdrive--")) and you type "h//warp" , I'm fairly sure this will be read to "hello-/warp" , which is probably not what you intended The documentation doesn't mention this, but it should, so patches welcome for that. In theory, lread.c could do this sorting for you. I don't think this would affect performance, so patches welcome for that, too. Anyway, here's another patch that more or less bridges our two patches and seems to do the right thing every time, even making you aware of that ordering pitfall. It could be more performant (or less, or about the same), so if you can, please include it in your benchmarks. It does less work when presented with a "/"-ending shorthand for a "-"-separated symbol, so I'm starting to think that this "/" idea is a good convention for shorthands (useful for distinguishing them in github code, for example). I've tested it briefly with those 'he/', 'he//', etc cases. diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el index b0665a55695..69e9e252aee 100644 --- a/lisp/emacs-lisp/shorthands.el +++ b/lisp/emacs-lisp/shorthands.el @@ -76,14 +76,19 @@ shorthands-font-lock-shorthands (sname (and probe (symbol-name probe))) (mismatch (and sname (shorthands--mismatch-from-end (match-string 1) sname))) - (guess (and mismatch (1+ mismatch)))) - (when guess - (when (and (< guess (1- (length (match-string 1)))) - ;; In bug#67390 we allow other separators - (eq (char-syntax (aref (match-string 1) guess)) ?_)) - (setq guess (1+ guess))) + probe2) + (when mismatch + (unless (eq (char-syntax (aref (match-string 1) mismatch)) ?_) + (or probe2 + (setq probe2 + (buffer-substring (match-beginning 1) + (+ (match-beginning 1) mismatch)))= ) + (setq mismatch (1- (length + (car (assoc probe2 + read-symbol-shorthands + (lambda (a b) (string-prefix-p b a)))))))) (add-face-text-property (match-beginning 1) - (+ (match-beginning 1) guess) + (+ (match-beginning 1) (1+ mismatch)) 'elisp-shorthand-font-lock-face)))))) (font-lock-add-keywords 'emacs-lisp-mode '((shorthands-font-lock-shorthands)) t) From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 29 18:27:29 2023 Received: (at 67390) by debbugs.gnu.org; 29 Nov 2023 23:27:29 +0000 Received: from localhost ([127.0.0.1]:51708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8Txp-0006am-CC for submit@debbugs.gnu.org; Wed, 29 Nov 2023 18:27:29 -0500 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:43017) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8Txm-0006aX-TZ for 67390@debbugs.gnu.org; Wed, 29 Nov 2023 18:27:28 -0500 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50bb8ff22e6so1493756e87.0 for <67390@debbugs.gnu.org>; Wed, 29 Nov 2023 15:27:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701300433; x=1701905233; 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=rcS+YXczQRd9WNtwPEoAro9rkASLuybMpdsZbZuFCI4=; b=ap50IUK99+Arc9xv7m9ZQpIQhQyMVvkC/9b2EaC5VxsBGnmKK84pjKP6mKlhpCTiq+ 8GwvBgyiVgOUX+g7awZtpMEw2Hkc6Z1CEhvq4TClmy1AEHbnMZoeCPu/AXzrwWmVtGwN aSkNKzQPybrkwRpFANIvK2jMi5kOgIzpyIGLKujRwWVy6mXawZfbk+zQ4Gusn+wvEXGQ ZXFGuGjSQ7XIGd1bHYGgBzEaSiwSUTDy1RDBsPzX7ZyJNUUAROqiH9Ov5bK84yFo2IE1 pLfz+F2CFhgfgshXlDbvJyxV31UNKsPJtfS9FqRJb2XogF04Js7o4aheU7IxqP/gWXqe 8h5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701300433; x=1701905233; 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=rcS+YXczQRd9WNtwPEoAro9rkASLuybMpdsZbZuFCI4=; b=FthUrHz6onpLCbcf+f8+En/7LvewID3P/fkrKj54d8S+VL8adamoLbDiZ3RvZawKuq h+TdUJu0Wpo9hR9uNtdGnbd1QFVWQY7pLyZv8gsbqiQ9QOG+DkMmNjx1lBzc7h4+28H2 /i4TFwmH4LOf38zAN6QZyKgQRouYK16wqHj7FDh2THppmA8T3WeHI4oF5zbq66p4Z7tf AgkICe9vjUB7IuSCcar2HxRGul56ciCxJDDFQdUu/i1vVj5fkbPdNdPnumzZMfmC2X6Y Ds2x64Q/6pdVsD8rwzwKzmJFzu1P3mGh1RGZzFbG25BSP3tL1s6Xu5GTbHxSPTBkQmmj YMVw== X-Gm-Message-State: AOJu0YwZ3m0ePG5lY27iQvCDbJxCTN4CFzkmIenZElxnvFsHhDHHu1t3 /+d+5CeOEvS1RjeSJ4+ZjIK39Q17ffc/eZPghnthcrtK X-Google-Smtp-Source: AGHT+IHMH4pYPwAMzyoSwmEhQ1Ao2oLJsCK5uyG9yRxKWsmbfV85fwSOtgkYPlKSY/QvqrPKYmSUwKWKLBLNxP1te74= X-Received: by 2002:a05:6512:108d:b0:50b:c8c3:4580 with SMTP id j13-20020a056512108d00b0050bc8c34580mr714519lfg.10.1701300432311; Wed, 29 Nov 2023 15:27:12 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Wed, 29 Nov 2023 23:27:00 +0000 Message-ID: Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Jonas Bernoulli Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: Joseph Turner , 67390@debbugs.gnu.org, Adam Porter 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 (-) On Wed, Nov 29, 2023 at 1:30=E2=80=AFPM Jo=C3=A3o T=C3=A1vora wrote: > > On Sat, Nov 25, 2023 at 4:03=E2=80=AFPM Jonas Bernoulli via Bug reports f= or > GNU Emacs, the Swiss army knife of text editors > wrote: > > > > Joseph Turner writes: > > > > > + (car (shorthands--find-if > > > + (lambda (short) > > > + (string-prefix-p short (match-stri= ng 1))) > > > + read-symbol-shorthands #'car))))) > > > > Or simply: > > (car (assoc (match-string 1) > > read-symbol-shorthands > > #'string-prefix-p)) > > I don't think it works, at least in my 'assoc', the order > of string-prefix-p arguments must be switched. Pity > assoc or string-prefix-p decs didn't coordinate this. nevermind, it does work if what you want is to see if the cars of the alist are prefixes to the key, which is probably your intention in this snippet. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 30 09:17:20 2023 Received: (at 67390) by debbugs.gnu.org; 30 Nov 2023 14:17:20 +0000 Received: from localhost ([127.0.0.1]:52657 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8hqx-0007I3-OF for submit@debbugs.gnu.org; Thu, 30 Nov 2023 09:17:20 -0500 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:44367) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8hqv-0007Hq-GK for 67390@debbugs.gnu.org; Thu, 30 Nov 2023 09:17:18 -0500 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50bc501081fso1485925e87.1 for <67390@debbugs.gnu.org>; Thu, 30 Nov 2023 06:17:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701353823; x=1701958623; 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=cWasUgL5Nm0BlX8buvOpHGuIrZV6Kyjb4w2phk+yPxU=; b=IJqpTu8SbkX7V/Akm6wx4t8+vCFb+pwxYblCLxC6nDS8IJew3CnJVIId3XPBXtES9I 8jTHxxG25v1ykOMAqeVSVvwo2UWAjx5MlKSaJHJUM82xMIhFv+d4e5ekiFW/PDpY0ioj 1SDysspPmD9OnyAXFEHiC4Zit6ufVZ7nsORWKlfgp3H7ovAX1n27MA+SsqzQRVerRgtm z9hoJ+FHKgJe/fK9hCczdyIFz1mN+N5n44f/Kqi47o07OMeGdpGMoMBNs9eZ/TUNfAVQ T9d8VxokRKryQACAldX+9wZt1cZe+x5PuiBUBIbZz405IgEC6UuVbaIYt0NdhKkmZR/7 LGqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701353823; x=1701958623; 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=cWasUgL5Nm0BlX8buvOpHGuIrZV6Kyjb4w2phk+yPxU=; b=A/68zvUQ/bR8VF6Vsa9M8aIp6vHgfIFFnFT910MxEb33UcFTjojnDnEEE2JXGgoVL9 BTuqc/pL+I1qftyQK/egwAelSlnW5JIrbSOfb80+a54aVT5uVgOa/9aHZMcgtSxM3Dep R3yYEyKsRNZDzJRKodVxoiq/MrelF6tKV97Cj/kzrp6PmCXZx3ogaVb88pFngyNEavYe gk4z4smwJEbm1ztB31OEAZdJ06/gB5iJojLK3zxLRsiHJ1ROxAQfhAjcv0/9ma7Fx8q0 vQlMjzba7dCm9qYRFFEn1gLZv0lKiU5t7/PWEnMYjrywlP44u7PqRr0oP/wRJ4MDmRZ5 UVtg== X-Gm-Message-State: AOJu0YxMr/I2I2xUZtmbuF8TJ4jpQky+91WEEXnbqGjerAsNSsOGc3V8 UZZ/z7BiC+V/d3s1ajEonUYmXrm06wo/tBWRH1M= X-Google-Smtp-Source: AGHT+IHBwcDCWcUS0t1DnO3xZ29lnJVzqTiI7eKkSbaBa98Jv1J1wAstamWjhegZx+NHJBZ7O6IzvHYNkX+Tassq8Lk= X-Received: by 2002:ac2:5550:0:b0:50b:bb4a:c0b5 with SMTP id l16-20020ac25550000000b0050bbb4ac0b5mr5888058lfk.60.1701353822925; Thu, 30 Nov 2023 06:17:02 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Thu, 30 Nov 2023 14:16:51 +0000 Message-ID: Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Jonas Bernoulli , Eli Zaretskii Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: Joseph Turner , 67390@debbugs.gnu.org, Adam Porter 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 (-) Hi all, I've been working on all these shorthand-related issues over the last two days and I have reasonably short fixes for all of them. For this particular issue (bug#67309), I've opted to use Joseph's patch with very slight adjustments, as it's the only one that guarantees correct behaviour and doesn't seem to impact performance. The other issues are: bug#63480 (loaddefs-gen.el doesn't know about shorthands) bug#67325 (prefix discovery i.e. register-definition-prefixes) bug#67523 (check-declare.el doesn't know about shorthands) I have all this in 6 commits in the bugfix/shorthand-fixes branch. Here's the full patch minus whitespace changes. If there are no comments I'll push in a few days' time. Jo=C3=A3o diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi index 1f3b677d7fb..18e80311177 100644 --- a/doc/lispref/symbols.texi +++ b/doc/lispref/symbols.texi @@ -761,6 +761,23 @@ Shorthands ;; End: @end example +Note that if you have two shorthands in the same file where one is the +prefix of the other, the longer shorthand will be attempted first. +This happens regardless of the order you specify shorthands in the +local variables section of your file. + +@example +'( + t//foo ; reads to 'my-tricks--foo', not 'my-tricks-/foo' + t/foo ; reads to 'my-tricks-foo' + ) + +;; Local Variables: +;; read-symbol-shorthands: (("t/" . "my-tricks-") +;; ("t//" . "my-tricks--") +;; End: +@end example + @subsection Exceptions There are two exceptions to rules governing Shorthand transformations: diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-decla= re.el index c887d95210c..b19aedf314d 100644 --- a/lisp/emacs-lisp/check-declare.el +++ b/lisp/emacs-lisp/check-declare.el @@ -145,21 +145,26 @@ check-declare-verify (if (file-regular-p fnfile) (with-temp-buffer (insert-file-contents fnfile) + (unless cflag + ;; If in Elisp, ensure syntax and shorthands available + (set-syntax-table emacs-lisp-mode-syntax-table) + (let (enable-local-variables) (hack-local-variables))) ;; defsubst's don't _have_ to be known at compile time. - (setq re (format (if cflag - "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" + (setq re (if cflag + (format "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" + (regexp-opt (mapcar 'cadr fnlist) t)) "^[ \t]*(\\(fset[ \t]+'\\|\ cl-def\\(?:generic\\|method\\|un\\)\\|\ def\\(?:un\\|subst\\|foo\\|method\\|class\\|\ ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\\|= \ \\(?:ine-obsolete-function-\\)?alias[ \t]+'\\|\ ine-overloadable-function\\)\\)\ -[ \t]*%s\\([ \t;]+\\|$\\)") - (regexp-opt (mapcar 'cadr fnlist) t))) +[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\([ \t;]+\\|$\\)")) (while (re-search-forward re nil t) (skip-chars-forward " \t\n") - (setq fn (match-string 2) - type (match-string 1) + (setq fn (symbol-name (car (read-from-string (match-string 2))= ))) + (when (member fn (mapcar 'cadr fnlist)) + (setq type (match-string 1) ;; (min . max) for a fixed number of arguments, or ;; arglists with optional elements. ;; (min) for arglists with &rest. @@ -202,7 +207,7 @@ check-declare-verify (t 'err)) ;; alist of functions and arglist signatures. - siglist (cons (cons fn sig) siglist))))) + siglist (cons (cons fn sig) siglist)))))) (dolist (e fnlist) (setq arglist (nth 2 e) type diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen= .el index 04bea4723a2..e8093200bec 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -378,6 +378,7 @@ loaddefs-generate--parse-file (let ((defs nil) (load-name (loaddefs-generate--file-load-name file main-outfile)) (compute-prefixes t) + read-symbol-shorthands local-outfile inhibit-autoloads) (with-temp-buffer (insert-file-contents file) @@ -399,7 +400,19 @@ loaddefs-generate--parse-file (setq inhibit-autoloads (read (current-buffer))))) (save-excursion (when (re-search-forward "autoload-compute-prefixes: *" nil t) - (setq compute-prefixes (read (current-buffer)))))) + (setq compute-prefixes (read (current-buffer))))) + (save-excursion + ;; since we're "open-coding" we have to repeat more + ;; complicated logic in `hack-local-variables'. + (when (re-search-forward "read-symbol-shorthands: *" nil t) + (let* ((commentless (replace-regexp-in-string + "\n\\s-*;+" "" + (buffer-substring (point) (point-max)))) + (unsorted-shorthands (car (read-from-string commentless= )))) + (setq read-symbol-shorthands + (sort unsorted-shorthands + (lambda (sh1 sh2) + (> (length (car sh1)) (length (car sh2))))))))= )) ;; We always return the package version (even for pre-dumped ;; files). @@ -486,7 +499,11 @@ loaddefs-generate--compute-prefixes (while (re-search-forward "^(\\(def[^ \t\n]+\\)[ \t\n]+['(]*\\([^' ()\"\n]+\\)[\n \t]" n= il t) (unless (member (match-string 1) autoload-ignored-definitions) - (let ((name (match-string-no-properties 2))) + (let* ((name (match-string-no-properties 2)) + ;; Consider `read-symbol-shorthands'. + (probe (let ((obarray (obarray-make))) + (car (read-from-string name))))) + (setq name (symbol-name probe)) (when (save-excursion (goto-char (match-beginning 0)) (or (bobp) diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el index b0665a55695..69b562e3c7e 100644 --- a/lisp/emacs-lisp/shorthands.el +++ b/lisp/emacs-lisp/shorthands.el @@ -52,38 +52,26 @@ elisp-shorthand-font-lock-face :version "28.1" :group 'font-lock-faces) -(defun shorthands--mismatch-from-end (str1 str2) - "Tell index of first mismatch in STR1 and STR2, from end. -The index is a valid 0-based index on STR1. Returns nil if STR1 -equals STR2. Return 0 if STR1 is a suffix of STR2." - (cl-loop with l1 =3D (length str1) with l2 =3D (length str2) - for i from 1 - for i1 =3D (- l1 i) for i2 =3D (- l2 i) - while (eq (aref str1 i1) (aref str2 i2)) - if (zerop i2) return (if (zerop i1) nil i1) - if (zerop i1) return 0 - finally (return i1))) - (defun shorthands-font-lock-shorthands (limit) + "Font lock until LIMIT considering `read-symbol-shorthands'." (when read-symbol-shorthands (while (re-search-forward (concat "\\_<\\(" (rx lisp-mode-symbol) "\\)\\_>") limit t) (let* ((existing (get-text-property (match-beginning 1) 'face)) + (print-name (match-string 1)) (probe (and (not (memq existing '(font-lock-comment-face font-lock-string-face))) - (intern-soft (match-string 1)))) - (sname (and probe (symbol-name probe))) - (mismatch (and sname (shorthands--mismatch-from-end - (match-string 1) sname))) - (guess (and mismatch (1+ mismatch)))) - (when guess - (when (and (< guess (1- (length (match-string 1)))) - ;; In bug#67390 we allow other separators - (eq (char-syntax (aref (match-string 1) guess)) ?_)) - (setq guess (1+ guess))) + (intern-soft print-name))) + (symbol-name (and probe (symbol-name probe))) + (prefix (and symbol-name + (not (string-equal print-name symbol-name)) + (car (assoc print-name + read-symbol-shorthands + #'string-prefix-p))))) + (when prefix (add-face-text-property (match-beginning 1) - (+ (match-beginning 1) guess) + (+ (match-beginning 1) (length prefix)) 'elisp-shorthand-font-lock-face)))))) (font-lock-add-keywords 'emacs-lisp-mode '((shorthands-font-lock-shorthands)) t) diff --git a/lisp/files.el b/lisp/files.el index 1cdcec23b11..b266d0727ec 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3735,7 +3735,8 @@ before-hack-local-variables-hook This hook is called only if there is at least one file-local variable to set.") -(defvar permanently-enabled-local-variables '(lexical-binding) +(defvar permanently-enabled-local-variables + '(lexical-binding read-symbol-shorthands) "A list of file-local variables that are always enabled. This overrides any `enable-local-variables' setting.") @@ -4171,6 +4172,13 @@ hack-local-variables--find-variables ;; to use 'thisbuf's name in the ;; warning message. (or (buffer-file-name thisbuf) "")))))) + ((eq var 'read-symbol-shorthands) + ;; Sort automatically by shorthand length + ;; descending + (setq val (sort val + (lambda (sh1 sh2) (> (length (car sh1)) + (length (car sh2)))))) + (push (cons 'read-symbol-shorthands val) result= )) ((and (eq var 'mode) handle-mode)) (t (ignore-errors From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 30 10:23:28 2023 Received: (at 67390) by debbugs.gnu.org; 30 Nov 2023 15:23:29 +0000 Received: from localhost ([127.0.0.1]:54384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8isy-0001Lq-Hj for submit@debbugs.gnu.org; Thu, 30 Nov 2023 10:23:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40446) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8isw-0001Le-Qt for 67390@debbugs.gnu.org; Thu, 30 Nov 2023 10:23:27 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8ish-0002ia-Go; Thu, 30 Nov 2023 10:23:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=bjtyTdmYYZVdzkQfqyWz76UqmoUp3+3ejVmZp8pxZIk=; b=L7B7rAfTLZuJgxHtv0xE HQDKdPwQpyZ5AGOxT/0oDp9VKqvI86lh7UFC7SUra3ZfSx8hShij8RjwRKtxaUL42fRWx6zrmj6Yw 5rvx9Qx2V8qTXINI2OxlheDQCKs17bP97Y0NQTYYg/3lNBbtTV0DiA9O3Ch6V7G/pDjlSd0F4ea+A cfoa3pUrUUWqKIU/sSz7bBIKwgu/XmR2ElrkT8KBOJfVdrwDB5sT64p1GPe2D04YhFyRnODC/QZuv rcbMOhQcJZdRtvGB3WW0A0X3pe9GzmT4Eyc/CAd0dwmJ2UxQTbZUi5QCYglgU4el9uwz9P782deEI /sCZvE/8UDkawA==; Date: Thu, 30 Nov 2023 17:23:04 +0200 Message-Id: <83sf4nb6zr.fsf@gnu.org> From: Eli Zaretskii To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= In-Reply-To: (message from =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= on Thu, 30 Nov 2023 14:16:51 +0000) Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67390 Cc: joseph@ushin.org, 67390@debbugs.gnu.org, jonas@bernoul.li, adam@alphapapa.net 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: -3.3 (---) > From: João Távora > Date: Thu, 30 Nov 2023 14:16:51 +0000 > Cc: Joseph Turner , 67390@debbugs.gnu.org, > Adam Porter > > Hi all, > > I've been working on all these shorthand-related issues over the last > two days and I have reasonably short fixes for all of them. > > For this particular issue (bug#67309), I've opted to > use Joseph's patch with very slight adjustments, as it's the > only one that guarantees correct behaviour and doesn't seem > to impact performance. > > The other issues are: > > bug#63480 (loaddefs-gen.el doesn't know about shorthands) > bug#67325 (prefix discovery i.e. register-definition-prefixes) > bug#67523 (check-declare.el doesn't know about shorthands) > > I have all this in 6 commits in the bugfix/shorthand-fixes branch. Thanks. > Here's the full patch minus whitespace changes. If there are > no comments I'll push in a few days' time. The plan is to merge these to the master branch, right? From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 30 10:29:51 2023 Received: (at 67390) by debbugs.gnu.org; 30 Nov 2023 15:29:51 +0000 Received: from localhost ([127.0.0.1]:54389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8iz9-0001WG-EY for submit@debbugs.gnu.org; Thu, 30 Nov 2023 10:29:51 -0500 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:46134) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8iz7-0001W1-7F for 67390@debbugs.gnu.org; Thu, 30 Nov 2023 10:29:49 -0500 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50bc8b7d8ffso1639491e87.0 for <67390@debbugs.gnu.org>; Thu, 30 Nov 2023 07:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701358175; x=1701962975; 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=/Bkn2Qn2u2Yfj0DL4aWPnjS4/0n+diFLsd4T7KxA1Kk=; b=fUF7I7n7bMBfI4SB/PVQoQmqqfZUmariDsAvAfMZzMZRY9/SG74FxLSafT9KPNxZQe mS1Im9HCdo4G/Krtabrf142kwAkkjzI20j625CHCo4WjtXcu9bqKmwYCXK7+MzcOOMx0 +7FENaqr1TDH/J+oDADNNcrs+tYTUvHrHKMpPNkDr7NverJ8hvqzd0kZ9mkLHb17qSt0 7hnj8xEBQwp1S7d/xpaDZwfN25gvvZfH9cS2f8j95V/+n33BpAxoAGaPfE41SVMNq39D fyIjFvn6gIr0WdTf70UR/+jYNF7MqohgQjkqF1XxWT7t6xNfK4vu3klPJI+5KBNC/spr PaTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701358175; x=1701962975; 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=/Bkn2Qn2u2Yfj0DL4aWPnjS4/0n+diFLsd4T7KxA1Kk=; b=P5rRyDQT31a/gbl/CZaKZoJrPSVFqDf5PgXugED+FmHHhOcKvK+CH4nVBG9EPCSdZU 8hFUjwRIucvugM0JAxV4N8eMKedY3yYuOkFSlaquVN3GycdzNEnTTXDvweKhN4m3RXP0 qVp45CMXsbm8x7KlGEQHNRhUs5meRyXnOV8i0v2Lh0SX01+Q5qFXDwMMtS6a9zIM9TOo eBqkEdpMA9M+JuQIqWD+u+LizrWmHTsRfW3hu6sUHY6LGQBUFMAgrcTBfwly7JDp9q7x qyDZG8JsKZcJsBhSZMoskZxbjNasVnEwrLvL6nYUgg2iEGm+Iiib1StMXKpHJMnA4SXW kKAA== X-Gm-Message-State: AOJu0YxEXjX9YXGWVbK0aVJXMRmr7TrvSqlV/nAoKEs0EjPvjmYSf9lv tnlOjSqvxtqXmv8MYgelRTAXB0VmbgmogNT5avk= X-Google-Smtp-Source: AGHT+IGJRHOBgMAjAwAaRYwBbp0M5Dj3GukBoJ+8CLa22SdEMEUEwwusCfjZxnaouCqc33WhEMv/ZdsVnQR6oyvxqDE= X-Received: by 2002:ac2:495c:0:b0:50b:d39f:b3cb with SMTP id o28-20020ac2495c000000b0050bd39fb3cbmr807485lfi.6.1701358174916; Thu, 30 Nov 2023 07:29:34 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <83sf4nb6zr.fsf@gnu.org> In-Reply-To: <83sf4nb6zr.fsf@gnu.org> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Thu, 30 Nov 2023 15:29:23 +0000 Message-ID: Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: joseph@ushin.org, 67390@debbugs.gnu.org, jonas@bernoul.li, adam@alphapapa.net 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 (-) On Thu, Nov 30, 2023 at 3:23=E2=80=AFPM Eli Zaretskii wrote: > > I have all this in 6 commits in the bugfix/shorthand-fixes branch. > > Thanks. > > > Here's the full patch minus whitespace changes. If there are > > no comments I'll push in a few days' time. > > The plan is to merge these to the master branch, right? Yes From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 10 05:52:56 2023 Received: (at 67390) by debbugs.gnu.org; 10 Dec 2023 10:52:56 +0000 Received: from localhost ([127.0.0.1]:49572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCHQd-0007HJ-Ka for submit@debbugs.gnu.org; Sun, 10 Dec 2023 05:52:56 -0500 Received: from out-170.mta1.migadu.com ([95.215.58.170]:42292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCHQb-0007HA-CG for 67390@debbugs.gnu.org; Sun, 10 Dec 2023 05:52:55 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1702205557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VV1lIK9ryniyV/AsGqiqDL2lY21BlUxt3QLfH8cpCa4=; b=pL0UP47Q0EdMd6S5hO457CEjAoJC9B3EryARMoSw5iA5aieOuejueIsQ9gcKzMEsab3MwW +r4AFYvDmJcG5UlyXLsT9nSckKi/UTQX/6kfuADpDUkWsUA2081WSGGKSJn7KRrGzDjeJ/ 0dMmJCBy0sPbk5Y46/dW4sylJtfDD0hqaxJo/QCBZzmJg1XSw5BjPcKPFj9Z3RVY/JoomG dj7+wSpU0mtsKXJECbLeoqTol+kgP1VVZCp4IORNvl4hJZF6AOCW8rfIdJJ0lVBzNZvJOi aLC79lvlLr+fc48tyyUyLWQX0d+CDoAvArjl+1mqoBdUcoSUVWE6kz0O08j5gg== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Sat, 09 Dec 2023 10:50:16 -0800 In-reply-to: Message-ID: <87ttoqnxci.fsf@ushin.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli 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.2 (/) Hi Jo=C3=A3o! Thanks for your patience - preparing for EmacsConf was a bla= st, and now I'm on a plane to go visit my grandmother! Jo=C3=A3o T=C3=A1vora writes: > Hi all, > > I've been working on all these shorthand-related issues over the last > two days and I have reasonably short fixes for all of them. > > For this particular issue (bug#67309), I've opted to > use Joseph's patch with very slight adjustments, as it's the > only one that guarantees correct behaviour and doesn't seem > to impact performance. > > The other issues are: > > bug#63480 (loaddefs-gen.el doesn't know about shorthands) > bug#67325 (prefix discovery i.e. register-definition-prefixes) > bug#67523 (check-declare.el doesn't know about shorthands) > > I have all this in 6 commits in the bugfix/shorthand-fixes branch. > > Here's the full patch minus whitespace changes. If there are > no comments I'll push in a few days' time. > > Jo=C3=A3o > > diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi > index 1f3b677d7fb..18e80311177 100644 > --- a/doc/lispref/symbols.texi > +++ b/doc/lispref/symbols.texi > @@ -761,6 +761,23 @@ Shorthands > ;; End: > @end example > > +Note that if you have two shorthands in the same file where one is the > +prefix of the other, the longer shorthand will be attempted first. > +This happens regardless of the order you specify shorthands in the > +local variables section of your file. > + > +@example > +'( > + t//foo ; reads to 'my-tricks--foo', not 'my-tricks-/foo' > + t/foo ; reads to 'my-tricks-foo' > + ) > + > +;; Local Variables: > +;; read-symbol-shorthands: (("t/" . "my-tricks-") > +;; ("t//" . "my-tricks--") > +;; End: > +@end example > + > @subsection Exceptions Clear and concise. > There are two exceptions to rules governing Shorthand transformations: > diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-dec= lare.el > index c887d95210c..b19aedf314d 100644 > --- a/lisp/emacs-lisp/check-declare.el > +++ b/lisp/emacs-lisp/check-declare.el > @@ -145,21 +145,26 @@ check-declare-verify > (if (file-regular-p fnfile) > (with-temp-buffer > (insert-file-contents fnfile) > + (unless cflag > + ;; If in Elisp, ensure syntax and shorthands available > + (set-syntax-table emacs-lisp-mode-syntax-table) > + (let (enable-local-variables) (hack-local-variables))) > ;; defsubst's don't _have_ to be known at compile time. > - (setq re (format (if cflag > - "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" > + (setq re (if cflag > + (format "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" > + (regexp-opt (mapcar 'cadr fnlist) t)) > "^[ \t]*(\\(fset[ \t]+'\\|\ > cl-def\\(?:generic\\|method\\|un\\)\\|\ > def\\(?:un\\|subst\\|foo\\|method\\|class\\|\ > ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\= \|\ > \\(?:ine-obsolete-function-\\)?alias[ \t]+'\\|\ > ine-overloadable-function\\)\\)\ > -[ \t]*%s\\([ \t;]+\\|$\\)") > - (regexp-opt (mapcar 'cadr fnlist) t))) > +[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\([ \t;]+\\|$\\)")) Would you explain what this regexp is intended to match? > (while (re-search-forward re nil t) > (skip-chars-forward " \t\n") > - (setq fn (match-string 2) > - type (match-string 1) > + (setq fn (symbol-name (car (read-from-string (match-string 2= ))))) > + (when (member fn (mapcar 'cadr fnlist)) > + (setq type (match-string 1) > ;; (min . max) for a fixed number of arguments, or > ;; arglists with optional elements. > ;; (min) for arglists with &rest. > @@ -202,7 +207,7 @@ check-declare-verify > (t > 'err)) > ;; alist of functions and arglist signatures. > - siglist (cons (cons fn sig) siglist))))) > + siglist (cons (cons fn sig) siglist)))))) > (dolist (e fnlist) > (setq arglist (nth 2 e) > type On my machine, this patch removes some of the check-declare "function not found" errors, but not all. For example, with hyperdrive-lib.el: (check-declare-file "~/.local/src/hyperdrive.el/hyperdrive-lib.el") Before this patch, the "*Check Declarations Warnings*" buffer shows: --8<---------------cut here---------------start------------->8--- =E2=96=A0 hyperdrive-lib.el:44:Warning (check-declare): said =E2=80=98h/mo= de=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive.el: function not found =E2=96=A0 hyperdrive-lib.el:508:Warning (check-declare): said =E2=80=98h/h= istory=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-history.el: function not found =E2=96=A0 hyperdrive-lib.el:1283:Warning (check-declare): said =E2=80=98h/= org--link-goto=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-org.el: function not found =E2=96=A0 hyperdrive-lib.el:45:Warning (check-declare): said =E2=80=98h/di= r-mode=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-dir.el: function not fo= und =E2=96=A0 hyperdrive-lib.el:1069:Warning (check-declare): said =E2=80=98h/dir--entry-at-point=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-dir.el: function not found =E2=96=A0 hyperdrive-lib.el:1332:Warning (check-declare): said =E2=80=98h/= dir-handler=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-dir.el: function not found --8<---------------cut here---------------end--------------->8--- and after your patch: --8<---------------cut here---------------start------------->8--- =E2=96=A0 hyperdrive-lib.el:44:Warning (check-declare): said =E2=80=98h/mo= de=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive.el: function not found =E2=96=A0 hyperdrive-lib.el:508:Warning (check-declare): said =E2=80=98h/h= istory=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-history.el: function not found =E2=96=A0 hyperdrive-lib.el:1332:Warning (check-declare): said =E2=80=98h/= dir-handler=E2=80=99 was defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-dir.el: function not found --8<---------------cut here---------------end--------------->8--- Are you able to reproduce this on your machine? > diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-g= en.el > index 04bea4723a2..e8093200bec 100644 > --- a/lisp/emacs-lisp/loaddefs-gen.el > +++ b/lisp/emacs-lisp/loaddefs-gen.el > @@ -378,6 +378,7 @@ loaddefs-generate--parse-file > (let ((defs nil) > (load-name (loaddefs-generate--file-load-name file main-outfile)) > (compute-prefixes t) > + read-symbol-shorthands > local-outfile inhibit-autoloads) > (with-temp-buffer > (insert-file-contents file) > @@ -399,7 +400,19 @@ loaddefs-generate--parse-file > (setq inhibit-autoloads (read (current-buffer))))) > (save-excursion > (when (re-search-forward "autoload-compute-prefixes: *" nil t) > - (setq compute-prefixes (read (current-buffer)))))) > + (setq compute-prefixes (read (current-buffer))))) > + (save-excursion > + ;; since we're "open-coding" we have to repeat more > + ;; complicated logic in `hack-local-variables'. > + (when (re-search-forward "read-symbol-shorthands: *" nil t) > + (let* ((commentless (replace-regexp-in-string > + "\n\\s-*;+" "" > + (buffer-substring (point) (point-max)))) > + (unsorted-shorthands (car (read-from-string commentle= ss)))) > + (setq read-symbol-shorthands > + (sort unsorted-shorthands > + (lambda (sh1 sh2) > + (> (length (car sh1)) (length (car sh2))))))= )))) IIUC, the intention here is to jump to a final "Local Variables" declaration at the end of the file, then remove ";;", then read in the uncommented value of `read-symbol-shorthands'. Since `read-from-string' just reads one expression, the above hunk works when there are more local variables after read-symbol-shorthands: ;; Local Variables: ;; read-symbol-shorthands: (("bc-" . "breadcrumb-")) ;; autoload-compute-prefixes: nil ;; End: But if the read-symbol-shorthands declaration comes at the top, as in... -*- read-symbol-shorthands: (("bc-" . "breadcrumb-")); -*- ...then this form will allocate two strings almost as long as the file. Here's an alternative hack attempting to uncomment and read the minimum: diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen= .el index e8093200bec..406e4b28f1f 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -404,10 +404,13 @@ don't include." (save-excursion ;; since we're "open-coding" we have to repeat more ;; complicated logic in `hack-local-variables'. - (when (re-search-forward "read-symbol-shorthands: *" nil t) - (let* ((commentless (replace-regexp-in-string + (when-let ((beg + (re-search-forward "read-symbol-shorthands: *" nil t= ))) + ;; `read-symbol-shorthands' alist ends with two parens. + (let* ((end (re-search-forward ")[;\n\s]*)")) + (commentless (replace-regexp-in-string "\n\\s-*;+" "" - (buffer-substring (point) (point-max)))) + (buffer-substring beg end))) (unsorted-shorthands (car (read-from-string commentless= )))) (setq read-symbol-shorthands (sort unsorted-shorthands > ;; We always return the package version (even for pre-dumped > ;; files). > @@ -486,7 +499,11 @@ loaddefs-generate--compute-prefixes > (while (re-search-forward > "^(\\(def[^ \t\n]+\\)[ \t\n]+['(]*\\([^' ()\"\n]+\\)[\n \t]"= nil t) > (unless (member (match-string 1) autoload-ignored-definitions) > - (let ((name (match-string-no-properties 2))) > + (let* ((name (match-string-no-properties 2)) > + ;; Consider `read-symbol-shorthands'. > + (probe (let ((obarray (obarray-make))) > + (car (read-from-string name))))) > + (setq name (symbol-name probe)) > (when (save-excursion > (goto-char (match-beginning 0)) > (or (bobp) > diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.el > index b0665a55695..69b562e3c7e 100644 > --- a/lisp/emacs-lisp/shorthands.el > +++ b/lisp/emacs-lisp/shorthands.el > @@ -52,38 +52,26 @@ elisp-shorthand-font-lock-face > :version "28.1" > :group 'font-lock-faces) > > -(defun shorthands--mismatch-from-end (str1 str2) > - "Tell index of first mismatch in STR1 and STR2, from end. > -The index is a valid 0-based index on STR1. Returns nil if STR1 > -equals STR2. Return 0 if STR1 is a suffix of STR2." > - (cl-loop with l1 =3D (length str1) with l2 =3D (length str2) > - for i from 1 > - for i1 =3D (- l1 i) for i2 =3D (- l2 i) > - while (eq (aref str1 i1) (aref str2 i2)) > - if (zerop i2) return (if (zerop i1) nil i1) > - if (zerop i1) return 0 > - finally (return i1))) > - > (defun shorthands-font-lock-shorthands (limit) > + "Font lock until LIMIT considering `read-symbol-shorthands'." > (when read-symbol-shorthands > (while (re-search-forward > (concat "\\_<\\(" (rx lisp-mode-symbol) "\\)\\_>") > limit t) > (let* ((existing (get-text-property (match-beginning 1) 'face)) > + (print-name (match-string 1)) > (probe (and (not (memq existing '(font-lock-comment-face > font-lock-string-face))) > - (intern-soft (match-string 1)))) > - (sname (and probe (symbol-name probe))) > - (mismatch (and sname (shorthands--mismatch-from-end > - (match-string 1) sname))) > - (guess (and mismatch (1+ mismatch)))) > - (when guess > - (when (and (< guess (1- (length (match-string 1)))) > - ;; In bug#67390 we allow other separators > - (eq (char-syntax (aref (match-string 1) guess)) ?_)) > - (setq guess (1+ guess))) > + (intern-soft print-name))) > + (symbol-name (and probe (symbol-name probe))) > + (prefix (and symbol-name > + (not (string-equal print-name symbol-name)) > + (car (assoc print-name > + read-symbol-shorthands > + #'string-prefix-p))))) > + (when prefix > (add-face-text-property (match-beginning 1) > - (+ (match-beginning 1) guess) > + (+ (match-beginning 1) (length prefix)) > 'elisp-shorthand-font-lock-face)))))) Works well. let-binding `symbol-name' and `print-name' is good improvement. > (font-lock-add-keywords 'emacs-lisp-mode > '((shorthands-font-lock-shorthands)) t) > diff --git a/lisp/files.el b/lisp/files.el > index 1cdcec23b11..b266d0727ec 100644 > --- a/lisp/files.el > +++ b/lisp/files.el > @@ -3735,7 +3735,8 @@ before-hack-local-variables-hook > This hook is called only if there is at least one file-local > variable to set.") > > -(defvar permanently-enabled-local-variables '(lexical-binding) > +(defvar permanently-enabled-local-variables > + '(lexical-binding read-symbol-shorthands) > "A list of file-local variables that are always enabled. > This overrides any `enable-local-variables' setting.") > > @@ -4171,6 +4172,13 @@ hack-local-variables--find-variables > ;; to use 'thisbuf's name in the > ;; warning message. > (or (buffer-file-name thisbuf) "")))))) > + ((eq var 'read-symbol-shorthands) > + ;; Sort automatically by shorthand length > + ;; descending > + (setq val (sort val > + (lambda (sh1 sh2) (> > (length (car sh1)) > + > (length (car sh2)))))) > + (push (cons 'read-symbol-shorthands val) resu= lt)) > ((and (eq var 'mode) handle-mode)) > (t > (ignore-errors Good catch. I agree that longer shorthands should be applied first. ----- A couple typo nits on the commit message of "Improve shorthands-font-lock-shorthands (bug#67390)": - h//thingy ; hilits "//" reads to 'hyperdrive--thingy' + h//thingy ; hilits "h//" reads to 'hyperdrive--thingy' - Co-authored-by: Jo=C3=A3o T=C3=A1vora + Co-authored-by: Joseph Turner Thank you! Joseph From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 03 02:10:36 2024 Received: (at 67390) by debbugs.gnu.org; 3 Feb 2024 07:10:37 +0000 Received: from localhost ([127.0.0.1]:45802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWAAe-000449-1J for submit@debbugs.gnu.org; Sat, 03 Feb 2024 02:10:36 -0500 Received: from out-175.mta1.migadu.com ([95.215.58.175]:43101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWAAZ-00043x-FF for 67390@debbugs.gnu.org; Sat, 03 Feb 2024 02:10:34 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <87ttoqnxci.fsf@ushin.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1706944218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hiUvm/mQuuNsSQvdPGy5Mys+FvzAPkrxYI7iZWlOtm0=; b=r0BRp7Tam51dWjZczeUNmeMV/KP9BPsSwHJQai0EIcx7erZ1jGgX3hZ7T4wpz+qQvAaBT6 hWB7Wm3aepgxfnh6Kdi7ZS7oe9QxvqSMnYpW1BM6JmC1Wh/UfOyWits/psT9pEMQvi7EAW AFFWApDpu9qYlMOrVxSMOrQvphiF73575CZ1GB+cT1xZ4w2PKJvMhzP1fqqy9XdkPRa/fV h7vL9I0aYGrZKc0oZeUl1tqG4yeYYiFFEscx4ivM1lE8wfjfQOxEXqbNo/a/vHK0+QF6PF jpdsIG3IaLmH/YBhYdsVmVczgxDOk6CUfFRL53KgT9Ef45UJ65vTIFJdAES/2A== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= , Jonas Bernoulli , Eli Zaretskii , 67390@debbugs.gnu.org, Adam Porter Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Fri, 02 Feb 2024 23:10:00 -0800 In-reply-to: <87ttoqnxci.fsf@ushin.org> Message-ID: <87sf2at44r.fsf@ushin.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 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 (-) Joseph Turner writes: > Hi Jo=C3=A3o! Thanks for your patience - preparing for EmacsConf was a b= last, > and now I'm on a plane to go visit my grandmother! > > Jo=C3=A3o T=C3=A1vora writes: > >> Hi all, >> >> I've been working on all these shorthand-related issues over the last >> two days and I have reasonably short fixes for all of them. >> >> For this particular issue (bug#67309), I've opted to >> use Joseph's patch with very slight adjustments, as it's the >> only one that guarantees correct behaviour and doesn't seem >> to impact performance. >> >> The other issues are: >> >> bug#63480 (loaddefs-gen.el doesn't know about shorthands) >> bug#67325 (prefix discovery i.e. register-definition-prefixes) >> bug#67523 (check-declare.el doesn't know about shorthands) >> >> I have all this in 6 commits in the bugfix/shorthand-fixes branch. >> >> Here's the full patch minus whitespace changes. If there are >> no comments I'll push in a few days' time. >> >> Jo=C3=A3o >> >> diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi >> index 1f3b677d7fb..18e80311177 100644 >> --- a/doc/lispref/symbols.texi >> +++ b/doc/lispref/symbols.texi >> @@ -761,6 +761,23 @@ Shorthands >> ;; End: >> @end example >> >> +Note that if you have two shorthands in the same file where one is the >> +prefix of the other, the longer shorthand will be attempted first. >> +This happens regardless of the order you specify shorthands in the >> +local variables section of your file. >> + >> +@example >> +'( >> + t//foo ; reads to 'my-tricks--foo', not 'my-tricks-/foo' >> + t/foo ; reads to 'my-tricks-foo' >> + ) >> + >> +;; Local Variables: >> +;; read-symbol-shorthands: (("t/" . "my-tricks-") >> +;; ("t//" . "my-tricks--") >> +;; End: >> +@end example >> + >> @subsection Exceptions > > Clear and concise. > >> There are two exceptions to rules governing Shorthand transformations: >> diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-de= clare.el >> index c887d95210c..b19aedf314d 100644 >> --- a/lisp/emacs-lisp/check-declare.el >> +++ b/lisp/emacs-lisp/check-declare.el >> @@ -145,21 +145,26 @@ check-declare-verify >> (if (file-regular-p fnfile) >> (with-temp-buffer >> (insert-file-contents fnfile) >> + (unless cflag >> + ;; If in Elisp, ensure syntax and shorthands available >> + (set-syntax-table emacs-lisp-mode-syntax-table) >> + (let (enable-local-variables) (hack-local-variables))) >> ;; defsubst's don't _have_ to be known at compile time. >> - (setq re (format (if cflag >> - "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" >> + (setq re (if cflag >> + (format "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" >> + (regexp-opt (mapcar 'cadr fnlist) t)) >> "^[ \t]*(\\(fset[ \t]+'\\|\ >> cl-def\\(?:generic\\|method\\|un\\)\\|\ >> def\\(?:un\\|subst\\|foo\\|method\\|class\\|\ >> ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode= \\|\ >> \\(?:ine-obsolete-function-\\)?alias[ \t]+'\\|\ >> ine-overloadable-function\\)\\)\ >> -[ \t]*%s\\([ \t;]+\\|$\\)") >> - (regexp-opt (mapcar 'cadr fnlist) t))) >> +[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\([ \t;]+\\|$\\)")) > > Would you explain what this regexp is intended to match? > >> (while (re-search-forward re nil t) >> (skip-chars-forward " \t\n") >> - (setq fn (match-string 2) >> - type (match-string 1) >> + (setq fn (symbol-name (car (read-from-string (match-string = 2))))) >> + (when (member fn (mapcar 'cadr fnlist)) >> + (setq type (match-string 1) >> ;; (min . max) for a fixed number of arguments, or >> ;; arglists with optional elements. >> ;; (min) for arglists with &rest. >> @@ -202,7 +207,7 @@ check-declare-verify >> (t >> 'err)) >> ;; alist of functions and arglist signatures. >> - siglist (cons (cons fn sig) siglist))))) >> + siglist (cons (cons fn sig) siglist)))))) >> (dolist (e fnlist) >> (setq arglist (nth 2 e) >> type > > On my machine, this patch removes some of the check-declare "function > not found" errors, but not all. For example, with hyperdrive-lib.el: > > (check-declare-file "~/.local/src/hyperdrive.el/hyperdrive-lib.el") > > Before this patch, the "*Check Declarations Warnings*" buffer shows: > > --8<---------------cut here---------------start------------->8--- > =E2=96=A0 hyperdrive-lib.el:44:Warning (check-declare): said =E2=80=98h/= mode=E2=80=99 was defined in > ../../../.emacs.d/elpa/hyperdrive/hyperdrive.el: function not found > =E2=96=A0 hyperdrive-lib.el:508:Warning (check-declare): said =E2=80=98h= /history=E2=80=99 was defined > in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-history.el: function = not > found > =E2=96=A0 hyperdrive-lib.el:1283:Warning (check-declare): said =E2=80=98= h/org--link-goto=E2=80=99 was > defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-org.el: funct= ion > not found > =E2=96=A0 hyperdrive-lib.el:45:Warning (check-declare): said =E2=80=98h/= dir-mode=E2=80=99 was defined > in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-dir.el: function not = found > =E2=96=A0 hyperdrive-lib.el:1069:Warning (check-declare): said > =E2=80=98h/dir--entry-at-point=E2=80=99 was defined in > ../../../.emacs.d/elpa/hyperdrive/hyperdrive-dir.el: function not fou= nd > =E2=96=A0 hyperdrive-lib.el:1332:Warning (check-declare): said =E2=80=98= h/dir-handler=E2=80=99 was > defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-dir.el: funct= ion > not found > --8<---------------cut here---------------end--------------->8--- > > > and after your patch: > > --8<---------------cut here---------------start------------->8--- > =E2=96=A0 hyperdrive-lib.el:44:Warning (check-declare): said =E2=80=98h/= mode=E2=80=99 was defined in > ../../../.emacs.d/elpa/hyperdrive/hyperdrive.el: function not found > =E2=96=A0 hyperdrive-lib.el:508:Warning (check-declare): said =E2=80=98h= /history=E2=80=99 was defined > in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-history.el: function = not > found > =E2=96=A0 hyperdrive-lib.el:1332:Warning (check-declare): said =E2=80=98= h/dir-handler=E2=80=99 was > defined in ../../../.emacs.d/elpa/hyperdrive/hyperdrive-dir.el: funct= ion > not found > --8<---------------cut here---------------end--------------->8--- > > Are you able to reproduce this on your machine? > >> diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-= gen.el >> index 04bea4723a2..e8093200bec 100644 >> --- a/lisp/emacs-lisp/loaddefs-gen.el >> +++ b/lisp/emacs-lisp/loaddefs-gen.el >> @@ -378,6 +378,7 @@ loaddefs-generate--parse-file >> (let ((defs nil) >> (load-name (loaddefs-generate--file-load-name file main-outfile= )) >> (compute-prefixes t) >> + read-symbol-shorthands >> local-outfile inhibit-autoloads) >> (with-temp-buffer >> (insert-file-contents file) >> @@ -399,7 +400,19 @@ loaddefs-generate--parse-file >> (setq inhibit-autoloads (read (current-buffer))))) >> (save-excursion >> (when (re-search-forward "autoload-compute-prefixes: *" nil t) >> - (setq compute-prefixes (read (current-buffer)))))) >> + (setq compute-prefixes (read (current-buffer))))) >> + (save-excursion >> + ;; since we're "open-coding" we have to repeat more >> + ;; complicated logic in `hack-local-variables'. >> + (when (re-search-forward "read-symbol-shorthands: *" nil t) >> + (let* ((commentless (replace-regexp-in-string >> + "\n\\s-*;+" "" >> + (buffer-substring (point) (point-max))= )) >> + (unsorted-shorthands (car (read-from-string commentl= ess)))) >> + (setq read-symbol-shorthands >> + (sort unsorted-shorthands >> + (lambda (sh1 sh2) >> + (> (length (car sh1)) (length (car sh2)))))= ))))) > > IIUC, the intention here is to jump to a final "Local Variables" > declaration at the end of the file, then remove ";;", then read in the > uncommented value of `read-symbol-shorthands'. > > Since `read-from-string' just reads one expression, the above hunk works > when there are more local variables after read-symbol-shorthands: > > ;; Local Variables: > ;; read-symbol-shorthands: (("bc-" . "breadcrumb-")) > ;; autoload-compute-prefixes: nil > ;; End: > > But if the read-symbol-shorthands declaration comes at the top, as in... > > -*- read-symbol-shorthands: (("bc-" . "breadcrumb-")); -*- > > ...then this form will allocate two strings almost as long as the file. > > Here's an alternative hack attempting to uncomment and read the minimum: > > diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-g= en.el > index e8093200bec..406e4b28f1f 100644 > --- a/lisp/emacs-lisp/loaddefs-gen.el > +++ b/lisp/emacs-lisp/loaddefs-gen.el > @@ -404,10 +404,13 @@ don't include." > (save-excursion > ;; since we're "open-coding" we have to repeat more > ;; complicated logic in `hack-local-variables'. > - (when (re-search-forward "read-symbol-shorthands: *" nil t) > - (let* ((commentless (replace-regexp-in-string > + (when-let ((beg > + (re-search-forward "read-symbol-shorthands: *" nil= t))) > + ;; `read-symbol-shorthands' alist ends with two parens. > + (let* ((end (re-search-forward ")[;\n\s]*)")) > + (commentless (replace-regexp-in-string > "\n\\s-*;+" "" > - (buffer-substring (point) (point-max)))) > + (buffer-substring beg end))) > (unsorted-shorthands (car (read-from-string commentle= ss)))) > (setq read-symbol-shorthands > (sort unsorted-shorthands > >> ;; We always return the package version (even for pre-dumped >> ;; files). >> @@ -486,7 +499,11 @@ loaddefs-generate--compute-prefixes >> (while (re-search-forward >> "^(\\(def[^ \t\n]+\\)[ \t\n]+['(]*\\([^' ()\"\n]+\\)[\n \t]= " nil t) >> (unless (member (match-string 1) autoload-ignored-definitions) >> - (let ((name (match-string-no-properties 2))) >> + (let* ((name (match-string-no-properties 2)) >> + ;; Consider `read-symbol-shorthands'. >> + (probe (let ((obarray (obarray-make))) >> + (car (read-from-string name))))) >> + (setq name (symbol-name probe)) >> (when (save-excursion >> (goto-char (match-beginning 0)) >> (or (bobp) >> diff --git a/lisp/emacs-lisp/shorthands.el b/lisp/emacs-lisp/shorthands.= el >> index b0665a55695..69b562e3c7e 100644 >> --- a/lisp/emacs-lisp/shorthands.el >> +++ b/lisp/emacs-lisp/shorthands.el >> @@ -52,38 +52,26 @@ elisp-shorthand-font-lock-face >> :version "28.1" >> :group 'font-lock-faces) >> >> -(defun shorthands--mismatch-from-end (str1 str2) >> - "Tell index of first mismatch in STR1 and STR2, from end. >> -The index is a valid 0-based index on STR1. Returns nil if STR1 >> -equals STR2. Return 0 if STR1 is a suffix of STR2." >> - (cl-loop with l1 =3D (length str1) with l2 =3D (length str2) >> - for i from 1 >> - for i1 =3D (- l1 i) for i2 =3D (- l2 i) >> - while (eq (aref str1 i1) (aref str2 i2)) >> - if (zerop i2) return (if (zerop i1) nil i1) >> - if (zerop i1) return 0 >> - finally (return i1))) >> - >> (defun shorthands-font-lock-shorthands (limit) >> + "Font lock until LIMIT considering `read-symbol-shorthands'." >> (when read-symbol-shorthands >> (while (re-search-forward >> (concat "\\_<\\(" (rx lisp-mode-symbol) "\\)\\_>") >> limit t) >> (let* ((existing (get-text-property (match-beginning 1) 'face)) >> + (print-name (match-string 1)) >> (probe (and (not (memq existing '(font-lock-comment-face >> font-lock-string-face))) >> - (intern-soft (match-string 1)))) >> - (sname (and probe (symbol-name probe))) >> - (mismatch (and sname (shorthands--mismatch-from-end >> - (match-string 1) sname))) >> - (guess (and mismatch (1+ mismatch)))) >> - (when guess >> - (when (and (< guess (1- (length (match-string 1)))) >> - ;; In bug#67390 we allow other separators >> - (eq (char-syntax (aref (match-string 1) guess)) ?_= )) >> - (setq guess (1+ guess))) >> + (intern-soft print-name))) >> + (symbol-name (and probe (symbol-name probe))) >> + (prefix (and symbol-name >> + (not (string-equal print-name symbol-name)) >> + (car (assoc print-name >> + read-symbol-shorthands >> + #'string-prefix-p))))) >> + (when prefix >> (add-face-text-property (match-beginning 1) >> - (+ (match-beginning 1) guess) >> + (+ (match-beginning 1) (length prefix= )) >> 'elisp-shorthand-font-lock-face)))))) > > Works well. let-binding `symbol-name' and `print-name' is good improveme= nt. > >> (font-lock-add-keywords 'emacs-lisp-mode >> '((shorthands-font-lock-shorthands)) t) >> diff --git a/lisp/files.el b/lisp/files.el >> index 1cdcec23b11..b266d0727ec 100644 >> --- a/lisp/files.el >> +++ b/lisp/files.el >> @@ -3735,7 +3735,8 @@ before-hack-local-variables-hook >> This hook is called only if there is at least one file-local >> variable to set.") >> >> -(defvar permanently-enabled-local-variables '(lexical-binding) >> +(defvar permanently-enabled-local-variables >> + '(lexical-binding read-symbol-shorthands) >> "A list of file-local variables that are always enabled. >> This overrides any `enable-local-variables' setting.") >> >> @@ -4171,6 +4172,13 @@ hack-local-variables--find-variables >> ;; to use 'thisbuf's name in the >> ;; warning message. >> (or (buffer-file-name thisbuf) "")))))) >> + ((eq var 'read-symbol-shorthands) >> + ;; Sort automatically by shorthand length >> + ;; descending >> + (setq val (sort val >> + (lambda (sh1 sh2) (> >> (length (car sh1)) >> + >> (length (car sh2)))))) >> + (push (cons 'read-symbol-shorthands val) res= ult)) >> ((and (eq var 'mode) handle-mode)) >> (t >> (ignore-errors > > Good catch. I agree that longer shorthands should be applied first. > > ----- > > A couple typo nits on the commit message of "Improve > shorthands-font-lock-shorthands (bug#67390)": > > - h//thingy ; hilits "//" reads to 'hyperdrive--thingy' > + h//thingy ; hilits "h//" reads to 'hyperdrive--thingy' > > - Co-authored-by: Jo=C3=A3o T=C3=A1vora > + Co-authored-by: Joseph Turner > > > Thank you! > > Joseph Ping! From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 03 09:50:33 2024 Received: (at 67390) by debbugs.gnu.org; 3 Feb 2024 14:50:33 +0000 Received: from localhost ([127.0.0.1]:46011 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWHLk-0007WV-QN for submit@debbugs.gnu.org; Sat, 03 Feb 2024 09:50:33 -0500 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:47497) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWHLi-0007WH-Ss for 67390@debbugs.gnu.org; Sat, 03 Feb 2024 09:50:31 -0500 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2cf206e4d56so40169081fa.3 for <67390@debbugs.gnu.org>; Sat, 03 Feb 2024 06:50:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706971813; x=1707576613; 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=QMXq86IN/lpt4VFJOL1OdxF4HRDY8Pzl0STK0ruGeNE=; b=ErW//pJcuxhO5zu91e2EyFpt2Nag0LPVp0cgDmdHNvEIPfq86SYSeePVHiavf0zJMK 2/3RhxnisohPZ8iUT6t/iYiAc73QakJO3cW3eaOULcLzo1ZVKFY1nIdDfzj1vBbh9aXQ uOHDlcwdikSE517IanTDjuVACTEV9Dbj+6alDhwb7XhfYy7JCo1BdbBpTvn7uZDEZ7xK C3gUUieV4S/t2kJrDnzbRTWNkbe8kJT1cL1KZRcNF2LuG7gFVfycd1hjB3sMP4KCcPEk m4Pe03JI5dpT540TlR3OnYEj1KDwphwhig7tvBkBatFyNtr/O5EJ8b1Z8u2BTftd2wUS vveQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706971813; x=1707576613; 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=QMXq86IN/lpt4VFJOL1OdxF4HRDY8Pzl0STK0ruGeNE=; b=mttH1CP0CMqSrsQCFI6HwpS92dlt7RvAQBA48p0QiudbHKc4s2UzpUrDnkPxa/Hub4 2Wc2K2Z1JOJd6JQxNaVT7QyxD2MuRhKUCZlpYBbyVur8k4R1FTkhZH2P2fk0I2UAJ4Gu WUnFtaXEd1fxYkDQbNfc+U7uXmeWrBvecZUEoTHqMKdgzdQ8HjCp/wgglEdvexqoE9Xt /IC11DQTudgqNox39ubNZSytZcgCinnT6cyjT6GrjKHwSpCHCe9mcXcRg/GdM17l23+O EpwnKGoDr+ITPeaCk0ZG31PuUsCzFmbDrJNintTVTkyJd2AExPhStIbVgJC59vrigTkL 0SNQ== X-Gm-Message-State: AOJu0YwiIM73ivmIcQugrVTC5tAoBUqK8I8nXVosgURwFHU2mPA/9vxb NeeDCb/5W1ICeJTTar7Scd2Iv87KAHOlaG/3qlRrgZ7l9QJ2gPCJ1rA605ZpwlC90reKcJPe/Px vMBf4MZ6xTL7EqxRJc+Scf0jLHr4= X-Google-Smtp-Source: AGHT+IECW4fUuDef8kr/Vl03/CNTZOdzc+QIapGO9wKSMEH24wG4DiM8RsxxOavvVWXvjMq/PQDKwQfnz+1quNClgc0= X-Received: by 2002:a2e:8781:0:b0:2d0:9f2f:e94 with SMTP id n1-20020a2e8781000000b002d09f2f0e94mr649943lji.34.1706971812966; Sat, 03 Feb 2024 06:50:12 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <87ttoqnxci.fsf@ushin.org> <87sf2at44r.fsf@ushin.org> In-Reply-To: <87sf2at44r.fsf@ushin.org> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sat, 3 Feb 2024 14:50:01 +0000 Message-ID: Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Joseph Turner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli 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 (-) Sorry, this flew under the radar. I thought I had already pushed to master but didn't. So I went through the commits again, addressed your concerns, = and applied your suggestions. Pushed to master now. On Sat, Feb 3, 2024 at 7:10=E2=80=AFAM Joseph Turner wro= te: >> -[ \t]*%s\\([ \t;]+\\|$\\)") >> - (regexp-opt (mapcar 'cadr fnlist) t))) >> +[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\([ \t;]+\\|$\\)")) > > Would you explain what this regexp is intended to match? A very complicated one, right? Well ask the author, but I think it's inten= ded to find many definition-like forms. No idea why this is done with regexps= and not with 'read' as it is a classical parsing pitfall in the long run. Maybe there was a reason. Anyway, I just added a bit of logic so that it considers read-symbol-shorthands if there are any. > Are you able to reproduce this on your machine? Yes, and I fixed it. > ...then this form will allocate two strings almost as long as the file. > > Here's an alternative hack attempting to uncomment and read the minimum: Thanks, I think that's a good idea and I added a commit in your name. > A couple typo nits on the commit message of "Improve > shorthands-font-lock-shorthands (bug#67390)": > > - h//thingy ; hilits "//" reads to 'hyperdrive--thingy' > + h//thingy ; hilits "h//" reads to 'hyperdrive--thingy' > > - Co-authored-by: Jo=C3=A3o T=C3=A1vora > + Co-authored-by: Joseph Turner I fixed these, too. If you succesfully test this, I think we can close thi= s bug (and the other ones, too). Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 03 15:02:17 2024 Received: (at submit) by debbugs.gnu.org; 3 Feb 2024 20:02:17 +0000 Received: from localhost ([127.0.0.1]:47127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWMDR-0004gS-7j for submit@debbugs.gnu.org; Sat, 03 Feb 2024 15:02:17 -0500 Received: from lists.gnu.org ([2001:470:142::17]:56300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWMDP-0004g1-Bb for submit@debbugs.gnu.org; Sat, 03 Feb 2024 15:02:16 -0500 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 1rWMD7-0004tI-To for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2024 15:01:58 -0500 Received: from out-170.mta0.migadu.com ([2001:41d0:1004:224b::aa]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWMD5-0000oz-Hm for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2024 15:01:57 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <87ttoqnxci.fsf@ushin.org> <87sf2at44r.fsf@ushin.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1706990510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tlh7qL/+XXS8+1hCJGZdQ0sIWQK5Xkn3MIZtWxvzY70=; b=nEnpcu47WoKM8cnr90hLfC90EOkb3/HFmgFgP37TwdYb9SroMMmNNJdOUd5UKEMlYa1WtI LnoV040zgrmaM5VLlS0SIzyYKHCh+v1bj0Qhx/O95/qdlbu7dknMlQ/GltZizI89lEsGvq pO5V8eUqEjdcuhYJbKQypAy52vThQbU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Sat, 03 Feb 2024 11:43:03 -0800 In-reply-to: Message-ID: <87bk8xxqom.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::aa; envelope-from=joseph@breatheoutbreathe.in; helo=out-170.mta0.migadu.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli , 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: -0.1 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jo=C3=A3o T=C3=A1vora writes: > Sorry, this flew under the radar. I thought I had already pushed to mast= er > but didn't. So I went through the commits again, addressed your concerns= , and > applied your suggestions. Pushed to master now. Thank you! > On Sat, Feb 3, 2024 at 7:10=E2=80=AFAM Joseph Turner w= rote: > > >>> -[ \t]*%s\\([ \t;]+\\|$\\)") >>> - (regexp-opt (mapcar 'cadr fnlist) t))) >>> +[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\([ \t;]+\\|$\\)")) >> >> Would you explain what this regexp is intended to match? > > A very complicated one, right? Well ask the author, but I think it's int= ended > to find many definition-like forms. No idea why this is done with regex= ps and > not with 'read' as it is a classical parsing pitfall in the long run. > Maybe there > was a reason. > > Anyway, I just added a bit of logic so that it considers > read-symbol-shorthands if > there are any. That makes sense. >> Are you able to reproduce this on your machine? > > Yes, and I fixed it. > >> ...then this form will allocate two strings almost as long as the file. >> >> Here's an alternative hack attempting to uncomment and read the minimum: > > Thanks, I think that's a good idea and I added a commit in your name. Thanks! >> A couple typo nits on the commit message of "Improve >> shorthands-font-lock-shorthands (bug#67390)": >> >> - h//thingy ; hilits "//" reads to 'hyperdrive--thingy' >> + h//thingy ; hilits "h//" reads to 'hyperdrive--thingy' >> >> - Co-authored-by: Jo=C3=A3o T=C3=A1vora >> + Co-authored-by: Joseph Turner > > I fixed these, too. If you succesfully test this, I think we can close t= his bug > (and the other ones, too). I'm still reproducing the check-declare bug on my machine. It appears that binding `enable-local-variables' to nil around the call to `hack-local-variables' means that `read-symbol-shorthands' is not set. Can we bind `enable-local-variables' to `:safe' instead? (let ( ;; (enable-local-variables t) ; works ;; (enable-local-variables) ; doesn't work (enable-local-variables :safe) ; works ) (with-temp-buffer (insert-file-contents "~/.local/src/hyperdrive.el/hyperdrive-lib.el") (hack-local-variables) read-symbol-shorthands)) See attached patch. There's no way to hack just a single file- or dir-local variable, right? Thank you! Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Bind-enable-local-variables-to-safe-for-shorthands-b.patch >From f301d839031f78b303d698d7bca1f0b27264d2d8 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 3 Feb 2024 11:56:31 -0800 Subject: [PATCH] ; Bind enable-local-variables to :safe for shorthands (bug#67523) * lisp/emacs-lisp/check-declare.el (check-declare-scan): (check-declare-verify): --- lisp/emacs-lisp/check-declare.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-declare.el index a6d1a330d90..eff37828f65 100644 --- a/lisp/emacs-lisp/check-declare.el +++ b/lisp/emacs-lisp/check-declare.el @@ -87,7 +87,7 @@ don't know how to recognize (e.g. some macros)." (insert-file-contents file) ;; Ensure shorthands available, as we will be `read'ing Elisp ;; (bug#67523) - (let (enable-local-variables) (hack-local-variables)) + (let ((enable-local-variables :safe)) (hack-local-variables)) ;; FIXME we could theoretically be inside a string. (while (re-search-forward "^[ \t]*\\((declare-function\\)[ \t\n]" nil t) (let ((pos (match-beginning 1))) @@ -152,7 +152,7 @@ is a string giving details of the error." ;; If in Elisp, ensure syntax and shorthands available ;; (bug#67523) (set-syntax-table emacs-lisp-mode-syntax-table) - (let (enable-local-variables) (hack-local-variables))) + (let ((enable-local-variables :safe)) (hack-local-variables))) ;; defsubst's don't _have_ to be known at compile time. (setq re (if cflag (format "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 03 17:25:58 2024 Received: (at 67390) by debbugs.gnu.org; 3 Feb 2024 22:25:58 +0000 Received: from localhost ([127.0.0.1]:47212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWOSU-00007m-0D for submit@debbugs.gnu.org; Sat, 03 Feb 2024 17:25:58 -0500 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:47499) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWOSS-00007Y-KK for 67390@debbugs.gnu.org; Sat, 03 Feb 2024 17:25:57 -0500 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5113a97a565so2028914e87.3 for <67390@debbugs.gnu.org>; Sat, 03 Feb 2024 14:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706999138; x=1707603938; 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=t3xeLo32aIQle9n8q36WhtWkKaDQCbUF+ppVcHoWTgk=; b=ak1q+Cuf5ryrCy8+GAJjYzAQjOhcvgX/ynPbVlkYn3oes4LfKVeFAvd+FoEVBDbQxq ms/Dq/+rPf7FHnxto+4ug+yZ8uT9JMHM1HlDT+kKC4Fzih56S9QIojlxSIc+OtszWNh5 BBKelM7DC1UQz7Qir5iUFp6UQ+CCmBekMDMe2qsggSr5vJt9WPzOT14HEDEOp72VMwE8 iBDwvyxE8p6zsOFJdxtZcHL/2dIfICBPZFpjVTXDznkXBkJxSCE1xst5Bp7O2RPc3Ebh OpOGQUdCk+XbzT6hru+gmR9QZhA5yPLDWznm3GxzILhO27UenHgUxBh575ZOvf184qub 7Png== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706999138; x=1707603938; 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=t3xeLo32aIQle9n8q36WhtWkKaDQCbUF+ppVcHoWTgk=; b=biEl6RfzO2smbgUjSJvQYMeHoVCFi114p5YnI+qVCcYt76wHWxI64ayW3a6gMzmJtv 2o+LNOMvaI63m983i6NoVVtHUnCD3PeYfyB42or0t0C7Q+FqU099njMtmzWEI6k9Gb9T ZgjpcY/NoJecuFylbCcMs/v07T4Tyei7nuw4M46F2E9jmMWS9gIFJhwku3ewtoWZOgLu lb6TwBhKshWhninNKJkQSeTnNDJk+EMp8vhMft3ObTXal+lPd8EokxvuRptelN6AMFOw yJ8p5MBigKMnMhb3OyUoyxFiSWxi+cO302PtK85VexGCAQb9QX4hEHx3OSDP5gjozq2P Aehg== X-Gm-Message-State: AOJu0YyhCc9D3f1xQanXk2qpq00eSnVEn8MO308tZaJRWoq6aMHmWk0e 1wHO/4iJk8o0yJcmTqKf91fc5q/EjKb+cy13OobYkbr7iDjFHGQkfRry5f6lsZ8E1m4fXACBUG+ Mv+7hL9L4xKij7O3b0GcCi+fFhQ0= X-Google-Smtp-Source: AGHT+IHkO2kns/4mpP4BZsGayELvaNmoGDFmtxLT6gPVQjY+ChXSMq+nFjN0vH54K2pvutKuYjwuacFueKPrYYT6dZg= X-Received: by 2002:a05:6512:1103:b0:511:1796:aad6 with SMTP id l3-20020a056512110300b005111796aad6mr6915141lfg.35.1706999138310; Sat, 03 Feb 2024 14:25:38 -0800 (PST) MIME-Version: 1.0 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <87ttoqnxci.fsf@ushin.org> <87sf2at44r.fsf@ushin.org> <87bk8xxqom.fsf@breatheoutbreathe.in> In-Reply-To: <87bk8xxqom.fsf@breatheoutbreathe.in> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sat, 3 Feb 2024 22:25:26 +0000 Message-ID: Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator To: Joseph Turner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67390 Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli , 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 (-) On Sat, Feb 3, 2024 at 8:01=E2=80=AFPM Joseph Turner wrote: > I'm still reproducing the check-declare bug on my machine. It appears > that binding `enable-local-variables' to nil around the call to > `hack-local-variables' means that `read-symbol-shorthands' is not set. > Can we bind `enable-local-variables' to `:safe' instead? It could be some bootstrapping issue, since the safe spec of that particula= r variable itself needs to be autoloaded. I vaguely remember something like this and I _think_ it was fixed. Anyway, I can't reproduce this with this test: src/emacs -Q --batch --eval '(check-declare-file "~/tmp/hyperdrive.el/hyperdrive-lib.el")' where ~/tmp/hyperdrive.el is a checkout of your hyperdrive library. This doesn't output anything, which I think is the expected result. How are you testing? Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 03 18:53:11 2024 Received: (at submit) by debbugs.gnu.org; 3 Feb 2024 23:53:11 +0000 Received: from localhost ([127.0.0.1]:47299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWPot-0002VG-Aq for submit@debbugs.gnu.org; Sat, 03 Feb 2024 18:53:11 -0500 Received: from lists.gnu.org ([2001:470:142::17]:44488) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWPor-0002V1-Q2 for submit@debbugs.gnu.org; Sat, 03 Feb 2024 18:53:10 -0500 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 1rWPoa-0005bK-JE for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2024 18:52:52 -0500 Received: from out-171.mta1.migadu.com ([2001:41d0:203:375::ab]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWPoY-0006gZ-Tt for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2024 18:52:52 -0500 References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <87ttoqnxci.fsf@ushin.org> <87sf2at44r.fsf@ushin.org> <87bk8xxqom.fsf@breatheoutbreathe.in> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1707004367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F9xEPAAV0Bm2gcDae7Kxlx0OpGysqxll6yPaHY+NGso=; b=eJMxuPp6pmXhqGrq1y84s9dCeTMBP0Ziwa2GeK98PQK4Agbq7A2fjeHRX0ob7WJCd67o+R 1ZGiX/pBaaMCiH31iLXZzZac81ZSyLi4BShBAjOq88onENhejfrsLIGDS1xfLOuayj+o7/ olMnATBjAXfyA5tnVrijpsnRgHLMl84= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Sat, 03 Feb 2024 15:48:18 -0800 In-reply-to: Message-ID: <87y1c1w1fb.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::ab; envelope-from=joseph@breatheoutbreathe.in; helo=out-171.mta1.migadu.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli , 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: -0.1 (/) Jo=C3=A3o T=C3=A1vora writes: > On Sat, Feb 3, 2024 at 8:01=E2=80=AFPM Joseph Turner > wrote: > >> I'm still reproducing the check-declare bug on my machine. It appears >> that binding `enable-local-variables' to nil around the call to >> `hack-local-variables' means that `read-symbol-shorthands' is not set. >> Can we bind `enable-local-variables' to `:safe' instead? > > It could be some bootstrapping issue, since the safe spec of that particu= lar > variable itself needs to be autoloaded. I vaguely remember something like > this and I _think_ it was fixed. > > Anyway, I can't reproduce this with this test: > > src/emacs -Q --batch --eval '(check-declare-file > "~/tmp/hyperdrive.el/hyperdrive-lib.el")' > > where ~/tmp/hyperdrive.el is a checkout of your hyperdrive library. > > This doesn't output anything, which I think is the expected result. > > How are you testing? Hmm... I just compiled from master with ./configure --with-x-toolkit=3Dno --with-xpm=3Difavailable --with-jpeg=3Dif= available --with-gif=3Difavailable --with-tiff=3Difavailable --with-gnutls= =3Difavailable && make then I ran src/emacs -Q --batch --eval '(check-declare-file "~/.local/src/hyperdrive.e= l/hyperdrive-lib.el")' which produced uncompressing textsec-check.el.gz... uncompressing textsec-check.el.gz...done ../hyperdrive.el/hyperdrive-lib.el:44:Warning (check-declare): said =E2=80= =98h/mode=E2=80=99 was defined in ../hyperdrive.el/hyperdrive.el: function = not found ../hyperdrive.el/hyperdrive-lib.el:508:Warning (check-declare): said =E2=80= =98h/history=E2=80=99 was defined in ../hyperdrive.el/hyperdrive-history.el= : function not found ../hyperdrive.el/hyperdrive-lib.el:1332:Warning (check-declare): said =E2= =80=98h/dir-handler=E2=80=99 was defined in ../hyperdrive.el/hyperdrive-dir= .el: function not found Would someone else kindly attempt to reproduce the issue? Thanks! Joseph From debbugs-submit-bounces@debbugs.gnu.org Tue May 21 18:06:19 2024 Received: (at submit) by debbugs.gnu.org; 21 May 2024 22:06:19 +0000 Received: from localhost ([127.0.0.1]:51457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9Xcg-00077L-KP for submit@debbugs.gnu.org; Tue, 21 May 2024 18:06:19 -0400 Received: from lists.gnu.org ([209.51.188.17]:36004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9Xcb-000778-FK for submit@debbugs.gnu.org; Tue, 21 May 2024 18:06:17 -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 1s9XcV-0001kW-Og for bug-gnu-emacs@gnu.org; Tue, 21 May 2024 18:06:07 -0400 Received: from out-181.mta0.migadu.com ([91.218.175.181]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9XcS-000288-0C for bug-gnu-emacs@gnu.org; Tue, 21 May 2024 18:06:07 -0400 X-Envelope-To: bug-gnu-emacs@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1716329159; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uHiBVKYsO3C+wTwQ0WcibbnG7m8lrdeikdgiwdeUSCA=; b=Myr4javy26HGjInbD6xueqo0GGC49AtLd/3OaqAdKQW/ALXpzPrejJX4mf86ZWXgaDJUjx DU2y+GFo1a882CaAxThnfF9cEZveR9kH5vAZH4KSUSf25cUlPOS0KHLn9NRlB8X5qomO6E YyfNstN0vIxTTucCMDmTR0qMOAmLc2Y= X-Envelope-To: joaotavora@gmail.com X-Envelope-To: 67390@debbugs.gnu.org X-Envelope-To: adam@alphapapa.net X-Envelope-To: eliz@gnu.org X-Envelope-To: jonas@bernoul.li X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Subject: Re: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator In-Reply-To: <87y1c1w1fb.fsf@breatheoutbreathe.in> (Joseph Turner via's message of "Sat, 03 Feb 2024 15:48:18 -0800") References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <87ttoqnxci.fsf@ushin.org> <87sf2at44r.fsf@ushin.org> <87bk8xxqom.fsf@breatheoutbreathe.in> <87y1c1w1fb.fsf@breatheoutbreathe.in> Date: Tue, 21 May 2024 15:05:54 -0700 Message-ID: <8734qaes71.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.181; envelope-from=joseph@breatheoutbreathe.in; helo=out-181.mta0.migadu.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: 67390@debbugs.gnu.org, adam@alphapapa.net, eliz@gnu.org, jonas@bernoul.li, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= 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: -2.4 (--) Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text = editors" writes: > Jo=C3=A3o T=C3=A1vora writes: > >> On Sat, Feb 3, 2024 at 8:01=E2=80=AFPM Joseph Turner >> wrote: >> >>> I'm still reproducing the check-declare bug on my machine. It appears >>> that binding `enable-local-variables' to nil around the call to >>> `hack-local-variables' means that `read-symbol-shorthands' is not set. >>> Can we bind `enable-local-variables' to `:safe' instead? >> >> It could be some bootstrapping issue, since the safe spec of that partic= ular >> variable itself needs to be autoloaded. I vaguely remember something li= ke >> this and I _think_ it was fixed. >> >> Anyway, I can't reproduce this with this test: >> >> src/emacs -Q --batch --eval '(check-declare-file >> "~/tmp/hyperdrive.el/hyperdrive-lib.el")' >> >> where ~/tmp/hyperdrive.el is a checkout of your hyperdrive library. >> >> This doesn't output anything, which I think is the expected result. >> >> How are you testing? > > Hmm... I just compiled from master with > > ./configure --with-x-toolkit=3Dno --with-xpm=3Difavailable > --with-jpeg=3Difavailable --with-gif=3Difavailable --with-tiff=3Difavaila= ble > --with-gnutls=3Difavailable && make > > then I ran > > src/emacs -Q --batch --eval '(check-declare-file "~/.local/src/hyperdrive= .el/hyperdrive-lib.el")' > > which produced > > uncompressing textsec-check.el.gz... > uncompressing textsec-check.el.gz...done > ../hyperdrive.el/hyperdrive-lib.el:44:Warning (check-declare): said > =E2=80=98h/mode=E2=80=99 was defined in ../hyperdrive.el/hyperdrive.el: f= unction not > found > ../hyperdrive.el/hyperdrive-lib.el:508:Warning (check-declare): said > =E2=80=98h/history=E2=80=99 was defined in ../hyperdrive.el/hyperdrive-hi= story.el: > function not found > ../hyperdrive.el/hyperdrive-lib.el:1332:Warning (check-declare): said > =E2=80=98h/dir-handler=E2=80=99 was defined in ../hyperdrive.el/hyperdriv= e-dir.el: > function not found > > Would someone else kindly attempt to reproduce the issue? I just rebuilt from master ce8e292bca84f29cea540e3e23e88ec7a5d1674e with the following settings ./configure --with-x-toolkit=3Dno --with-xpm=3Difavailable --with-jpeg=3Difavailable --with-gif=3Difavailable --with-tiff=3Difavailable --with-gnutls=3Difavailable && make src/emacs -Q --batch --eval '(check-declare-file "~/.local/src/hyperdrive.e= l/hyperdrive-lib.el")' returns the following: uncompressing textsec-check.el.gz... uncompressing textsec-check.el.gz...done ../hyperdrive.el/hyperdrive-lib.el:535:Warning (check-declare): said =E2=80= =98h/history=E2=80=99 was defined in ../hyperdrive.el/hyperdrive-history.el: function not found ../hyperdrive.el/hyperdrive-lib.el:44:Warning (check-declare): said =E2=80= =98h/mode=E2=80=99 was defined in ../hyperdrive.el/hyperdrive.el: function not found ../hyperdrive.el/hyperdrive-lib.el:1333:Warning (check-declare): said =E2= =80=98h/blob-mo de=E2=80=99 was defined in ../hyperdrive.el/hyperdrive.el: function not fou= nd ../hyperdrive.el/hyperdrive-lib.el:1383:Warning (check-declare): said =E2= =80=98h/dir-han dler=E2=80=99 was defined in ../hyperdrive.el/hyperdrive-dir.el: function n= ot found Can anyone else reproduce this error? Thank you! Joseph