From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Sun, 26 Nov 2023 12:35:32 -0800 Message-ID: <871qccqmgi.fsf@ushin.org> References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> Reply-To: Joseph Turner Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37940"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67390@debbugs.gnu.org, Adam Porter , Jonas Bernoulli To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 26 21:39:08 2023 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 1r7LuF-0009hV-DF for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Nov 2023 21:39:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7Lu5-0006WT-In; Sun, 26 Nov 2023 15:38:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7Lu4-0006WC-JV for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2023 15:38:56 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r7Lu4-00072f-Bt for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2023 15:38:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r7LuA-0002X2-6P for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2023 15:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Nov 2023 20:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67390 X-GNU-PR-Package: emacs Original-Received: via spool by 67390-submit@debbugs.gnu.org id=B67390.17010311359719 (code B ref 67390); Sun, 26 Nov 2023 20:39:02 +0000 Original-Received: (at 67390) by debbugs.gnu.org; 26 Nov 2023 20:38:55 +0000 Original-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 Original-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 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. In-reply-to: X-Migadu-Flow: FLOW_OUT X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275083 Archived-At: 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