GNU bug report logs - #31808
[PATCH] customize how to display eww buffer.

Previous Next

Package: emacs;

Reported by: Yuya Minami <yuya373 <at> me.com>

Date: Wed, 13 Jun 2018 07:55:01 UTC

Severity: wishlist

Tags: patch, wontfix

Done: Lars 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 31808 in the body.
You can then email your comments to 31808 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#31808; Package emacs. (Wed, 13 Jun 2018 07:55:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Yuya Minami <yuya373 <at> me.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 13 Jun 2018 07:55:02 GMT) Full text and rfc822 format available.

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

From: Yuya Minami <yuya373 <at> me.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Yuya Minami <yuya373 <at> me.com>
Subject: [PATCH] customize how to display eww buffer.
Date: Wed, 13 Jun 2018 16:53:47 +0900
Currently `eww` function using `pop-to-buffer-same-window` to display
eww buffer.
This changes make customizable how to display eww buffer.
And using `with-current-buffer` to prevent functions that depend on
the current buffer being eww-mode from being executed in other
major-mode buffer.
---
 lisp/net/eww.el | 59 +++++++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 27 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 97fdabd72b..a97d22ae2d 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -153,6 +153,11 @@ eww-form-checkbox-symbol
                  (const "☐")            ; Unicode BALLOT BOX
                  string))
 
+(defcustom eww-display-buffer-function 'pop-to-buffer-same-window
+  "Function used to display eww buffer in `eww'."
+  :group 'eww
+  :type 'function)
+
 (defface eww-form-submit
   '((((type x w32 ns) (class color))	; Like default mode line
      :box (:line-width 2 :style released-button)
@@ -257,33 +262,33 @@ eww
 			  (if uris (format " (default %s)" (car uris)) "")
 			  ": ")))
      (list (read-string prompt nil 'eww-prompt-history uris))))
-  (setq url (eww--dwim-expand-url url))
-  (pop-to-buffer-same-window
-   (if (eq major-mode 'eww-mode)
-       (current-buffer)
-     (get-buffer-create "*eww*")))
-  (eww-setup-buffer)
-  ;; Check whether the domain only uses "Highly Restricted" Unicode
-  ;; IDNA characters.  If not, transform to punycode to indicate that
-  ;; there may be funny business going on.
-  (let ((parsed (url-generic-parse-url url)))
-    (when (url-host parsed)
-      (unless (puny-highly-restrictive-domain-p (url-host parsed))
-        (setf (url-host parsed) (puny-encode-domain (url-host parsed)))))
-    ;; When the URL is on the form "http://a/../../../g", chop off all
-    ;; the leading "/.."s.
-    (when (url-filename parsed)
-      (while (string-match "\\`/[.][.]/" (url-filename parsed))
-        (setf (url-filename parsed) (substring (url-filename parsed) 3))))
-    (setq url (url-recreate-url parsed)))
-  (plist-put eww-data :url url)
-  (plist-put eww-data :title "")
-  (eww-update-header-line-format)
-  (let ((inhibit-read-only t))
-    (insert (format "Loading %s..." url))
-    (goto-char (point-min)))
-  (url-retrieve url 'eww-render
-                (list url nil (current-buffer))))
+  (let ((buffer (if (eq major-mode 'eww-mode)
+                    (current-buffer)
+                  (get-buffer-create "*eww*"))))
+    (funcall eww-display-buffer-function buffer)
+    (with-current-buffer buffer
+      (eww-setup-buffer)
+      ;; Check whether the domain only uses "Highly Restricted" Unicode
+      ;; IDNA characters.  If not, transform to punycode to indicate that
+      ;; there may be funny business going on.
+      (let* ((expanded (eww--dwim-expand-url url))
+             (parsed (url-generic-parse-url expanded)))
+        (when (url-host parsed)
+          (unless (puny-highly-restrictive-domain-p (url-host parsed))
+            (setf (url-host parsed) (puny-encode-domain (url-host parsed)))))
+        ;; When the URL is on the form "http://a/../../../g", chop off all
+        ;; the leading "/.."s.
+        (when (url-filename parsed)
+          (while (string-match "\\`/[.][.]/" (url-filename parsed))
+            (setf (url-filename parsed) (substring (url-filename parsed) 3))))
+        (setq url (url-recreate-url parsed)))
+      (plist-put eww-data :url url)
+      (plist-put eww-data :title "")
+      (eww-update-header-line-format)
+      (let ((inhibit-read-only t))
+        (insert (format "Loading %s..." url))
+        (goto-char (point-min)))
+      (url-retrieve url 'eww-render (list url nil buffer)))))
 
 (defun eww--dwim-expand-url (url)
   (setq url (string-trim url))
-- 
2.17.1






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31808; Package emacs. (Wed, 13 Jun 2018 13:41:02 GMT) Full text and rfc822 format available.

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

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Yuya Minami <yuya373 <at> me.com>
Cc: 31808 <at> debbugs.gnu.org
Subject: Re: bug#31808: [PATCH] customize how to display eww buffer.
Date: Wed, 13 Jun 2018 16:40:20 +0300
Yuya Minami <yuya373 <at> me.com> writes:

> Currently `eww` function using `pop-to-buffer-same-window` to display
> eww buffer.
> This changes make customizable how to display eww buffer.

FWIW, it is already possible to customise this via display-buffer-alist
and display-buffer-overriding-action (though granted, this method is not
as clear as a user option).  The following achieves an effect similar to
that of using pop-to-buffer, for example:

  (add-to-list 'display-buffer-alist
               '("\\`\\*eww\\*" () (inhibit-same-window . t)))

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31808; Package emacs. (Mon, 13 May 2019 19:20:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Yuya Minami <yuya373 <at> me.com>, 31808 <at> debbugs.gnu.org
Subject: Re: bug#31808: [PATCH] customize how to display eww buffer.
Date: Mon, 13 May 2019 15:19:37 -0400
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> FWIW, it is already possible to customise this via display-buffer-alist
> and display-buffer-overriding-action (though granted, this method is not
> as clear as a user option).  The following achieves an effect similar to
> that of using pop-to-buffer, for example:
>
>   (add-to-list 'display-buffer-alist
>                '("\\`\\*eww\\*" () (inhibit-same-window . t)))

Yeah, I think that's the right mechanism to use here instead of adding a
eww-specific variable, so I'm closing this bug report.

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




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 13 May 2019 19:20:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 31808 <at> debbugs.gnu.org and Yuya Minami <yuya373 <at> me.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 13 May 2019 19:20:03 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, 11 Jun 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 314 days ago.

Previous Next


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