From: Yuya Minami <yuya373@me.com>
To: 31808@debbugs.gnu.org
Cc: Yuya Minami <yuya373@me.com>
Subject: bug#31808: [PATCH] customize how to display eww buffer.
Date: Wed, 13 Jun 2018 16:53:47 +0900 [thread overview]
Message-ID: <20180613075347.20981-1-yuya373@me.com> (raw)
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
next reply other threads:[~2018-06-13 7:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 7:53 Yuya Minami [this message]
2018-06-13 13:40 ` bug#31808: [PATCH] customize how to display eww buffer Basil L. Contovounesios
2019-05-13 19:19 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180613075347.20981-1-yuya373@me.com \
--to=yuya373@me.com \
--cc=31808@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.