GNU bug report logs - #19225
eww-render: runs eww-after-render-hook in the (temporary) data buffer

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Sun, 30 Nov 2014 10:00:04 UTC

Severity: normal

Tags: fixed, patch

Merged with 19227

Found in version 25.0.50

Fixed in version 25.1

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19225 in the body.
You can then email your comments to 19225 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#19225; Package emacs. (Sun, 30 Nov 2014 10:00:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivan Shmakov <ivan <at> siamics.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 30 Nov 2014 10:00:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: submit <at> debbugs.gnu.org
Subject: eww-render: runs eww-after-render-hook in the (temporary) data buffer
Date: Sun, 30 Nov 2014 09:59:10 +0000
[Message part 1 (text/plain, inline)]
Package:  emacs

>>>>> Lars Magne Ingebrigtsen <larsi <at> gnus.org> writes:
>>>>> Ivan Shmakov <ivan <at> siamics.net> 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.

   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
…
   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))))

	What’s even worse is that the call to eww-after-render-hook is
	among them, and thus the code there has no (easy) way of finding
	the EWW buffer proper; consider, e. g.:

(add-hook 'eww-after-render-hook
          (lambda () (message "Called in: %S" (current-buffer))))

Called in: #<buffer  *http my.proxy.example:3128*>

	There’re two obvious ways to deal with the issues with eww-data
	and eww-history-position:

	• they could be wrapped into a (with-current-buffer buffer …)
	  form in eww-render;

	• or they could be moved from there to eww-display-raw, -image,
	  and -pdf; (eww-display-html already has them.)

	The eww-after-render-hook case is a bit trickier, as I’d rather
	prefer having some easy way to access /either/ of the buffers
	from the functions referenced.  For instance, I’d like to have a
	way to capture the HTTP header and provide a command to present
	it to the user when asked.  (I doubt this feature really belongs
	to the EWW “core,” so doing it from the hook looks sensible.)

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A
[Message part 2 (text/plain, inline)]
commit 6fd82d61a2b82e772e8cde0e04516f5c3ca98ed3
Author: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Date:   Sun Nov 23 17:22:41 2014 +0100

    Switch to the *eww* buffer immediately to avoid doing it asynchronously
    
    (eww): Pop to the *eww* buffer immediately after executing the
    `M-x eww' command to avoid having buffers pop up later.
    (eww-display-html): Don't pop the *eww* buffer.
    (eww-display-raw): Ditto.
    (eww-display-image): Ditto.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19225; Package emacs. (Sun, 30 Nov 2014 10:47:02 GMT) Full text and rfc822 format available.

Message #8 received at 19225 <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: 19225 <at> debbugs.gnu.org, control <at> debbugs.gnu.org
Subject: Re: bug#19225: eww-render: runs eww-after-render-hook in the
 (temporary) data buffer 
Date: Sun, 30 Nov 2014 10:45:46 +0000
[Message part 1 (text/plain, inline)]
tags 19225 + patch
thanks

>>>>> Ivan Shmakov <ivan <at> siamics.net> writes:
>>>>> Lars Magne Ingebrigtsen <larsi <at> gnus.org> writes:
>>>>> Ivan Shmakov <ivan <at> siamics.net> 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
[Message part 2 (text/diff, inline)]
--- 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))

Added tag(s) patch. Request was from Ivan Shmakov <ivan <at> siamics.net> to control <at> debbugs.gnu.org. (Sun, 30 Nov 2014 10:47:02 GMT) Full text and rfc822 format available.

Forcibly Merged 19225 19227. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 01 Dec 2014 17:46:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19225; Package emacs. (Mon, 01 Dec 2014 17:57:01 GMT) Full text and rfc822 format available.

Message #15 received at 19225 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: 19225 <at> debbugs.gnu.org
Subject: Re: bug#19225: eww-render: runs eww-after-render-hook in the
 (temporary) data buffer
Date: Mon, 01 Dec 2014 18:56:30 +0100
Ivan Shmakov <ivan <at> siamics.net> writes:

> 	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.

Thanks; applied.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 01 Dec 2014 17:57:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 25.1, send any further explanations to 19225 <at> debbugs.gnu.org and Ivan Shmakov <ivan <at> siamics.net> Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 01 Dec 2014 17:57:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 30 Dec 2014 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.