aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2017-01-24 22:40:57 +0100
committerLars Ingebrigtsen2017-01-24 23:14:31 +0100
commitfd42a19260841a2e3c39fd983c7601a3f517bf4b (patch)
tree216f50520268cc745fbddd9c29965b1d7d609091
parentaea6701839357eb139e29056274996c70f42b860 (diff)
downloademacs-fd42a19260841a2e3c39fd983c7601a3f517bf4b.tar.gz
emacs-fd42a19260841a2e3c39fd983c7601a3f517bf4b.zip
When opening new eww buffers, use buffer names based on the host name
* lisp/net/eww.el (eww-browse-url): When opening in a new window, use a buffer name based on the host name (bug#23738). (eww--dwim-expand-url): Refactored out into its own function for easier reuse.
-rw-r--r--lisp/net/eww.el49
1 files changed, 28 insertions, 21 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index d42180719dc..3e5d4467eac 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -251,6 +251,29 @@ word(s) will be searched for via `eww-search-prefix'."
251 (if uris (format " (default %s)" (car uris)) "") 251 (if uris (format " (default %s)" (car uris)) "")
252 ": "))) 252 ": ")))
253 (list (read-string prompt nil nil uris)))) 253 (list (read-string prompt nil nil uris))))
254 (setq url (eww--dwim-expand-url url))
255 (pop-to-buffer-same-window
256 (if (eq major-mode 'eww-mode)
257 (current-buffer)
258 (get-buffer-create "*eww*")))
259 (eww-setup-buffer)
260 ;; Check whether the domain only uses "Highly Restricted" Unicode
261 ;; IDNA characters. If not, transform to punycode to indicate that
262 ;; there may be funny business going on.
263 (let ((parsed (url-generic-parse-url url)))
264 (unless (puny-highly-restrictive-domain-p (url-host parsed))
265 (setf (url-host parsed) (puny-encode-domain (url-host parsed)))
266 (setq url (url-recreate-url parsed))))
267 (plist-put eww-data :url url)
268 (plist-put eww-data :title "")
269 (eww-update-header-line-format)
270 (let ((inhibit-read-only t))
271 (insert (format "Loading %s..." url))
272 (goto-char (point-min)))
273 (url-retrieve url 'eww-render
274 (list url nil (current-buffer))))
275
276(defun eww--dwim-expand-url (url)
254 (setq url (string-trim url)) 277 (setq url (string-trim url))
255 (cond ((string-match-p "\\`file:/" url)) 278 (cond ((string-match-p "\\`file:/" url))
256 ;; Don't mangle file: URLs at all. 279 ;; Don't mangle file: URLs at all.
@@ -275,26 +298,7 @@ word(s) will be searched for via `eww-search-prefix'."
275 (setq url (concat url "/")))) 298 (setq url (concat url "/"))))
276 (setq url (concat eww-search-prefix 299 (setq url (concat eww-search-prefix
277 (replace-regexp-in-string " " "+" url)))))) 300 (replace-regexp-in-string " " "+" url))))))
278 (pop-to-buffer-same-window 301 url)
279 (if (eq major-mode 'eww-mode)
280 (current-buffer)
281 (get-buffer-create "*eww*")))
282 (eww-setup-buffer)
283 ;; Check whether the domain only uses "Highly Restricted" Unicode
284 ;; IDNA characters. If not, transform to punycode to indicate that
285 ;; there may be funny business going on.
286 (let ((parsed (url-generic-parse-url url)))
287 (unless (puny-highly-restrictive-domain-p (url-host parsed))
288 (setf (url-host parsed) (puny-encode-domain (url-host parsed)))
289 (setq url (url-recreate-url parsed))))
290 (plist-put eww-data :url url)
291 (plist-put eww-data :title "")
292 (eww-update-header-line-format)
293 (let ((inhibit-read-only t))
294 (insert (format "Loading %s..." url))
295 (goto-char (point-min)))
296 (url-retrieve url 'eww-render
297 (list url nil (current-buffer))))
298 302
299;;;###autoload (defalias 'browse-web 'eww) 303;;;###autoload (defalias 'browse-web 'eww)
300 304
@@ -804,7 +808,10 @@ the like."
804;;;###autoload 808;;;###autoload
805(defun eww-browse-url (url &optional new-window) 809(defun eww-browse-url (url &optional new-window)
806 (when new-window 810 (when new-window
807 (pop-to-buffer-same-window (generate-new-buffer "*eww*")) 811 (pop-to-buffer-same-window
812 (generate-new-buffer
813 (format "*eww-%s*" (url-host (url-generic-parse-url
814 (eww--dwim-expand-url url))))))
808 (eww-mode)) 815 (eww-mode))
809 (eww url)) 816 (eww url))
810 817