* bug#31808: [PATCH] customize how to display eww buffer.
@ 2018-06-13 7:53 Yuya Minami
2018-06-13 13:40 ` Basil L. Contovounesios
0 siblings, 1 reply; 3+ messages in thread
From: Yuya Minami @ 2018-06-13 7:53 UTC (permalink / raw)
To: 31808; +Cc: Yuya Minami
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#31808: [PATCH] customize how to display eww buffer.
2018-06-13 7:53 bug#31808: [PATCH] customize how to display eww buffer Yuya Minami
@ 2018-06-13 13:40 ` Basil L. Contovounesios
2019-05-13 19:19 ` Lars Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Basil L. Contovounesios @ 2018-06-13 13:40 UTC (permalink / raw)
To: Yuya Minami; +Cc: 31808
Yuya Minami <yuya373@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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#31808: [PATCH] customize how to display eww buffer.
2018-06-13 13:40 ` Basil L. Contovounesios
@ 2019-05-13 19:19 ` Lars Ingebrigtsen
0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-05-13 19:19 UTC (permalink / raw)
To: Basil L. Contovounesios; +Cc: Yuya Minami, 31808
"Basil L. Contovounesios" <contovob@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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-13 19:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-13 7:53 bug#31808: [PATCH] customize how to display eww buffer Yuya Minami
2018-06-13 13:40 ` Basil L. Contovounesios
2019-05-13 19:19 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.