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

From: Keith Amidon <[email-masked]>
Date: Wed, 26 Mar 2025 11:04:49 -0700

I'm trying to use eww with:

(setq eww-auto-rename-buffer 'title
       eww-readable-urls '((".*" . t)))

I'm expecting that this will result in buffer names reflecting
the titles of the HTML pages. However, what I actually see is
that all buffers get named "Untitled # EWW", made unique by
uniquify.

This seems like a bug to me.

I believe it arises because the title element of eww-data is set
to the empty string by eww--before-browse and then set to the
actual title when shr-insert-document csiteslalls the eww-tag-title
function via the shr-external-rendering-functions set in
eww-display-document.

I think that in the readable case, the content passed to
shr-insert-document does not include the title element so
it isn't available from rendering that content.

It appears to me that eww-readable preserves the title
in the eww-data plist by resetting it after calling
eww-before-browse. And in fact, if I set eww-readable-urls to
nil and go to a site, the buffer is properly named based on
the title. If I then call eww-readable, it remains named
based on the title.

The default readability based-on eww-readable-urls appears
to happen in eww-display-html, which itself calls
eww-display-document. The full document hasn't been rendered
at this point so there is no existing title to preserve.

I don't think there is a simple fix for this. The fundamental
problem is that eww only gets the title by rendering the
original document and in the case of default readable URLs
it never renders the original document. I thought it might be
possible to hack eww-score-readability to include the title
in the readable version but it appears that it is omitting the
entire head section currently, so it would need fairly
extensive changes to selectively pass through the title
without any other head elements.

Help with this would be appreciated.  Thanks!  --- Keith