From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "João Távora" <joaotavora@gmail.com>
Cc: 67390@debbugs.gnu.org, Adam Porter <adam@alphapapa.net>,
Jonas Bernoulli <jonas@bernoul.li>
Subject: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator
Date: Sun, 26 Nov 2023 12:35:32 -0800 [thread overview]
Message-ID: <871qccqmgi.fsf@ushin.org> (raw)
In-Reply-To: <CALDnm53=F3-vWg0euuq5V5-k35zy0U4Hanyx6=QR6u-ZKoj=ig@mail.gmail.com>
João Távora <joaotavora@gmail.com> writes:
> On Sat, Nov 25, 2023 at 10:43 PM Joseph Turner <joseph@ushin.org> wrote:
>>
>> Jonas Bernoulli <jonas@bernoul.li> writes:
>>
>> > Joseph Turner <joseph@ushin.org> 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!
>
> 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
next prev parent reply other threads:[~2023-11-26 20:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 22:18 bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Jonas Bernoulli via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-23 12:57 ` João Távora
2023-11-24 21:51 ` Jonas Bernoulli via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-25 0:03 ` João Távora
2023-11-25 3:26 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-25 16:01 ` Jonas Bernoulli via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-25 22:42 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-26 13:52 ` João Távora
2023-11-26 20:35 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-11-26 22:02 ` João Távora
2023-11-27 3:48 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-27 12:10 ` Eli Zaretskii
2023-11-29 8:21 ` João Távora
2023-11-29 9:12 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-29 13:56 ` João Távora
2023-11-29 13:30 ` João Távora
2023-11-29 23:27 ` João Távora
2023-11-30 14:16 ` João Távora
2023-11-30 15:23 ` Eli Zaretskii
2023-11-30 15:29 ` João Távora
2023-12-09 18:50 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-03 7:10 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-03 14:50 ` João Távora
2024-02-03 19:43 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-03 22:25 ` João Távora
2024-02-03 23:48 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-21 22:05 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qccqmgi.fsf@ushin.org \
--to=bug-gnu-emacs@gnu.org \
--cc=67390@debbugs.gnu.org \
--cc=adam@alphapapa.net \
--cc=joaotavora@gmail.com \
--cc=jonas@bernoul.li \
--cc=joseph@ushin.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.