Subject: bug#77299: eww-auto-rename-buffer 'title interaction with eww-readable-urls

From: Eli Zaretskii <[email-masked]>
Date: Wed, 18 Jun 2025 14:31:10 +0300

> Date: Tue, 17 Jun 2025 09:33:01 -0700
> Cc: [email-masked]
> From: Jim Porter <[email-masked]>
> 
> On 6/12/2025 9:47 AM, Keith Amidon wrote:
> > If you have the time and interest to write the patch based on your 
> > superior knowledge of the code Jim that would be great. I'm motivated to 
> > have this work because I find using eww-readable-urls to make eww much 
> > more useful for my day-to-day usage (thanks for contributing it!) but I 
> > also heavily use org links which need the document title to work well.
> 
> It took a bit longer than I thought to do this, but after a few failed 
> attempts, I think this patch is pretty close (aside from the couple of 
> small FIXMEs in there).
> 
> As a bonus, this implementation is about 4x faster than the old one, 
> since it does all the work in a single pass over the DOM. For large 
> pages, simply computing the readable DOM can take a while; doing it for 
> the Wikipedia page for "Sun" takes a full second. Here are the stats 
> from calling the relevant code before and after (sum of 20 iterations):
> 
>    BEFORE:  20.635833s (15.510534s in 270 GCs)
>    AFTER:    4.320405s (3.041672s in 55 GCs)
> 
> We could probably make this even faster by doing something more 
> efficient than '(length (split-string FOO))', but one thing at a time. 
> That's how the code was before, so I didn't change that bit.

Thanks.

> > My current personal workaround is working but I'd like to get a solution 
> > upstream and stop carrying it. If you come up with something you'd like 
> > help testing I'd be happy to help with that. If you can't get to it for 
> > a while I'll make time to poke at it.
> 
> If the attached changed is too risky for the release branch

It most definitely is.

> I'm open to the idea of doing something like your workaround there,
> maybe only when 'eww-auto-rename-buffer' is set to 'title'. That
> way, people without that setting don't suffer any performance
> penalty.

Please show the patch so I could decide whether such a change is okay
for emacs-30.