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

From: Jim Porter <[email-masked]>
Date: Wed, 25 Jun 2025 21:36:37 -0700

Since there have been no more comments, I've now merged my main patch to 
the master branch as 2bdcf0250ac.

On 6/19/2025 8:05 PM, Jim Porter wrote:
> On 6/19/2025 5:34 PM, Keith Amidon wrote:
>> However, I do want to briefly discuss the decision to make the emacs 
>> 30 workaround conditional on eww-auto-rename-buffer having the value 
>> 'title. This does minimize the situations in which the additional 
>> rendering is done, which is desirable. However, I think it will push 
>> people who might not have that setting to make it to enable other 
>> functionality that doesn't work properly when the title of the web 
>> page is unknown.
> Hmm, good point. One possibility would be to add a new user option just 
> for Emacs 30 to enable/disable this workaround. Or maybe we should just 
> accept that we need to render the page twice for now. That's less 
> efficient, but more correct.

For the Emacs 30 branch, how about this? It just unconditionally renders 
the full page first, which should be the least error-prone (at the cost 
of some wasted CPU cycles).

However, in this version of the patch, we inhibit loading images when 
temporarily rendering the full page. That way we don't *also* waste 
network bandwidth.

From 99901a46922f2fd6a90626445390baa97d4fb8cb Mon Sep 17 00:00:00 2001
From: Jim Porter <[email-masked]>
Date: Thu, 19 Jun 2025 12:23:24 -0700
Subject: [PATCH] Populate the ':title' in EWW when defaulting to readable mode

Do not merge to master.

* lisp/net/eww.el (eww-display-document): Always render the full
document first to pupoulate ':title' (bug#77299).
---
 lisp/net/eww.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index c3e927b74a6..0bf7fe5f307 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -828,6 +828,12 @@ eww-display-html
   (unless document
     (let ((dom (eww--parse-html-region (point) (point-max) charset)))
       (when (eww-default-readable-p url)
+        ;; HACK: Work around bug#77299.  By displaying the full
+        ;; document first, we can ensure that the `:title' property in
+        ;; `eww-data' gets set properly.  This is inefficient, since
+        ;; it requires rendering the document twice.
+        (let ((shr-inhibit-images t))
+          (eww-display-document (eww-document-base url dom) point buffer))
         (eww-score-readability dom)
         (setq dom (eww-highest-readability dom))
         (with-current-buffer buffer
-- 
2.25.1