Subject: Re: bug#19225: eww-render: runs eww-after-render-hook in the (temporary) data buffer

From: Ivan Shmakov <[email-masked]>
Date: Sun, 30 Nov 2014 10:45:46 +0000

tags 19225 + patch
thanks

>>>>> Ivan Shmakov <[email-masked]> writes:
>>>>> Lars Magne Ingebrigtsen <[email-masked]> writes:
>>>>> Ivan Shmakov <[email-masked]> writes:

[…]

 >>> The plist-put calls down that progn are evaluated after
 >>> eww-display-*, and thus after either eww-setup-buffer or some other
 >>> set-buffer.  The eww-use-external-browser-for-content-type case I’m
 >>> unsure about, though.

 >> I've now removed the statement.

 > Following the change for eww-display-* /not/ to change the
 > current buffer ($ git log entry MIMEd), those forms are now also
 > evaluated in the data buffer.

	… As well as a couple of eww-update-header-line-format calls.

	Please consider the patch MIMEd.  This one doesn’t pass the data
	buffer to eww-after-render-hook, and I hope this still could be
	resolved a bit later.

	* eww.el (eww-render): Call eww-update-header-line-format
	unconditionally and in the browsing buffer (was: data buffer);
	change eww-data and eww-history-position for the browsing
	buffer, and run eww-after-render-hook there, too.
	(eww-display-html): Do not call eww-update-header-line-format or
	change eww-data, eww-history-position (now done in eww-render.)

   283	(defun eww-render (status url &optional point buffer encode)
…
   287	  (let* ((headers (eww-parse-headers))
…
   298		 (data-buffer (current-buffer)))
   299	    (unwind-protect
   300		(progn
   301		  (cond
…
   310		   ((string-match-p "\\`image/" (car content-type))
   311		    (eww-display-image buffer)
   312		    (eww-update-header-line-format))
   313		   (t
   314		    (eww-display-raw buffer encode)
   315		    (eww-update-header-line-format)))
   316		  (plist-put eww-data :url url)
   317		  (setq eww-history-position 0)
   318		  (run-hooks 'eww-after-render-hook))
   319	      (kill-buffer data-buffer))))

[…]

-- 
FSF associate member #7257  np. Surrender — Jami Sieber … 3013 B6A0 230E 334A
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -308,14 +315,14 @@ defun eww-render (status url &optional point buffer encode)
 	   ((equal (car content-type) "application/pdf")
 	    (eww-display-pdf))
 	   ((string-match-p "\\`image/" (car content-type))
-	    (eww-display-image buffer)
-	    (eww-update-header-line-format))
+	    (eww-display-image buffer))
 	   (t
-	    (eww-display-raw buffer encode)
-	    (eww-update-header-line-format)))
-	  (plist-put eww-data :url url)
-	  (setq eww-history-position 0)
-	  (run-hooks 'eww-after-render-hook))
+	    (eww-display-raw buffer encode)))
+	  (with-current-buffer buffer
+	    (plist-put eww-data :url url)
+	    (eww-update-header-line-format)
+	    (setq eww-history-position 0)
+	    (run-hooks 'eww-after-render-hook)))
       (kill-buffer data-buffer))))
 
 (defun eww-parse-headers ()
@@ -403,10 +411,7 @@ defun eww-display-html (charset url &optional document point buffer encode)
 	  (while (and (not (eobp))
 		      (get-text-property (point) 'eww-form))
 	    (forward-line 1)))))
-      (plist-put eww-data :url url)
-      (setq eww-history-position 0)
-      (eww-size-text-inputs)
-      (eww-update-header-line-format))))
+      (eww-size-text-inputs))))
 
 (defun eww-handle-link (dom)
   (let* ((rel (dom-attr dom 'rel))