From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#50946: Emacs-28: Inadequate coding in hack-elisp-shorthands Date: Sun, 03 Oct 2021 14:45:14 +0300 Message-ID: <83r1d28h85.fsf@gnu.org> References: <831r54einq.fsf@gnu.org> <871r54xnds.fsf@gmail.com> <87ee933bcj.fsf@gmail.com> <83pmsnbnci.fsf@gnu.org> <83k0ivbjbu.fsf@gnu.org> <83czonbhex.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23661"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 50946@debbugs.gnu.org, joaotavora@gmail.com To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 03 13:46:31 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mWzws-0005wG-05 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Oct 2021 13:46:30 +0200 Original-Received: from localhost ([::1]:39284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWzwq-0000jd-4d for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Oct 2021 07:46:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWzwR-0000hs-9U for bug-gnu-emacs@gnu.org; Sun, 03 Oct 2021 07:46:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWzwQ-0001je-Fk for bug-gnu-emacs@gnu.org; Sun, 03 Oct 2021 07:46:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mWzwQ-0004jc-CU for bug-gnu-emacs@gnu.org; Sun, 03 Oct 2021 07:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Oct 2021 11:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50946 X-GNU-PR-Package: emacs Original-Received: via spool by 50946-submit@debbugs.gnu.org id=B50946.163326155018178 (code B ref 50946); Sun, 03 Oct 2021 11:46:02 +0000 Original-Received: (at 50946) by debbugs.gnu.org; 3 Oct 2021 11:45:50 +0000 Original-Received: from localhost ([127.0.0.1]:33029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWzwE-0004j8-3D for submit@debbugs.gnu.org; Sun, 03 Oct 2021 07:45:50 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWzw9-0004ir-QM for 50946@debbugs.gnu.org; Sun, 03 Oct 2021 07:45:49 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:46082) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWzw3-0001Tv-Tw; Sun, 03 Oct 2021 07:45:39 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4725 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWzvt-00010K-HF; Sun, 03 Oct 2021 07:45:39 -0400 In-Reply-To: (message from Alan Mackenzie on Sat, 2 Oct 2021 20:07:26 +0000) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:216255 Archived-At: > Date: Sat, 2 Oct 2021 20:07:26 +0000 > Cc: joaotavora@gmail.com, 50946@debbugs.gnu.org > From: Alan Mackenzie > > > > > > not going back at least 3000 characters > > > > > That is now fixed, right? > > > > No, it's not. In certain edge cases, it will go back fewer than 3000 > > > characters. > > > Does the patch below solve this? > > I think it does, yes. Thanks! Now installed. > > > > > I worry, to a lesser degree, it is not entirely clear whether setting > > > > > the elisp-shorthands variable in the first line of a short file should > > > > > be valid or not. I don't think the current hack-elisp-shorthands is > > > > > careful enough about this. > > > > > Why does it matter? > > Otherwise we could have the scenario where somebody sets elisp-shorthands > in the first line of a file, finds it works, then types more into the > file, saves the buffer, then finds when she visits the file again that it > no longer works. This, I think, would be a Bad Thing. I'm not sure. If the user doesn't obey the rules, the user gets amply punished. > > > Because the first line definition should either be valid or not valid. > > > Currently it works for a sufficiently small file, but not for a normal > > > sized file. This, I think, is a bug. > > > No, I don't think it's a bug, at least not a bug specific to > > shorthands. That's how file-local variables work in general. > > No, not quite. For normal file-local variables, having one set in the > first line works regardless of the length of the file. It wouldn't for > elisp-shorthands, where it would only work for short files. I don't think I follow. can you show an example of a problematic file, so that we are sure we are talking about the same issue? > > > Have you checked that things work if the first byte in your temporary > > > buffer isn't at the start of a character? > > > I don't see why this matters, can you explain? > > It might matter, I simply don't know. I rarely type characters into > Emacs which are longer than a single byte in UTF8. I don't know whether > insert-file-contents does the Right Thing when there's half a character > at point-min, then insert-file-contents inserts the other half of the > character before it. The character read in separate parts will indeed be incorrect, but how does this affect searching for the local-variables section? I don't think it does, because there are only ASCII characters in the header of that section. > I don't know to what extent normal Emacs functions > work when there are invalid "characters" at point-min or point-max. They aren't invalid characters, they are raw 8-bit bytes. Emacs search functions can cope with them without a problem.