aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net/eww.el
diff options
context:
space:
mode:
authorAlan Mackenzie2017-02-12 10:59:03 +0000
committerAlan Mackenzie2017-02-12 10:59:03 +0000
commitf4d5b687150810129b7a1d5b006e31ccf82b691b (patch)
tree4229b13800349032697daae3904dc3773e6b7a80 /lisp/net/eww.el
parentd5514332d4a6092673ce1f78fadcae0c57f7be64 (diff)
parent148100d98319499f0ac6f57b8be08cbd14884a5c (diff)
downloademacs-comment-cache.tar.gz
emacs-comment-cache.zip
Merge branch 'master' into comment-cachecomment-cache
Diffstat (limited to 'lisp/net/eww.el')
-rw-r--r--lisp/net/eww.el71
1 files changed, 45 insertions, 26 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index d42180719dc..f7e06341443 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -59,7 +59,7 @@
59 "Directory where files will downloaded." 59 "Directory where files will downloaded."
60 :version "24.4" 60 :version "24.4"
61 :group 'eww 61 :group 'eww
62 :type 'string) 62 :type 'directory)
63 63
64;;;###autoload 64;;;###autoload
65(defcustom eww-suggest-uris 65(defcustom eww-suggest-uris
@@ -81,7 +81,7 @@ duplicate entries (if any) removed."
81 "Directory where bookmark files will be stored." 81 "Directory where bookmark files will be stored."
82 :version "25.1" 82 :version "25.1"
83 :group 'eww 83 :group 'eww
84 :type 'string) 84 :type 'directory)
85 85
86(defcustom eww-desktop-remove-duplicates t 86(defcustom eww-desktop-remove-duplicates t
87 "Whether to remove duplicates from the history when saving desktop data. 87 "Whether to remove duplicates from the history when saving desktop data.
@@ -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
@@ -351,16 +355,25 @@ Currently this means either text/html or application/xhtml+xml."
351 "utf-8")))) 355 "utf-8"))))
352 (data-buffer (current-buffer)) 356 (data-buffer (current-buffer))
353 last-coding-system-used) 357 last-coding-system-used)
354 ;; Save the https peer status.
355 (with-current-buffer buffer 358 (with-current-buffer buffer
356 (plist-put eww-data :peer (plist-get status :peer))) 359 ;; Save the https peer status.
360 (plist-put eww-data :peer (plist-get status :peer))
361 ;; Make buffer listings more informative.
362 (setq list-buffers-directory url))
357 (unwind-protect 363 (unwind-protect
358 (progn 364 (progn
359 (cond 365 (cond
360 ((and eww-use-external-browser-for-content-type 366 ((and eww-use-external-browser-for-content-type
361 (string-match-p eww-use-external-browser-for-content-type 367 (string-match-p eww-use-external-browser-for-content-type
362 (car content-type))) 368 (car content-type)))
363 (eww-browse-with-external-browser url)) 369 (erase-buffer)
370 (insert "<title>Unsupported content type</title>")
371 (insert (format "<h1>Content-type %s is unsupported</h1>"
372 (car content-type)))
373 (insert (format "<a href=%S>Direct link to the document</a>"
374 url))
375 (goto-char (point-min))
376 (eww-display-html charset url nil point buffer encode))
364 ((eww-html-p (car content-type)) 377 ((eww-html-p (car content-type))
365 (eww-display-html charset url nil point buffer encode)) 378 (eww-display-html charset url nil point buffer encode))
366 ((equal (car content-type) "application/pdf") 379 ((equal (car content-type) "application/pdf")
@@ -804,7 +817,10 @@ the like."
804;;;###autoload 817;;;###autoload
805(defun eww-browse-url (url &optional new-window) 818(defun eww-browse-url (url &optional new-window)
806 (when new-window 819 (when new-window
807 (pop-to-buffer-same-window (generate-new-buffer "*eww*")) 820 (pop-to-buffer-same-window
821 (generate-new-buffer
822 (format "*eww-%s*" (url-host (url-generic-parse-url
823 (eww--dwim-expand-url url))))))
808 (eww-mode)) 824 (eww-mode))
809 (eww url)) 825 (eww url))
810 826
@@ -835,6 +851,8 @@ the like."
835 (erase-buffer) 851 (erase-buffer)
836 (insert text) 852 (insert text)
837 (goto-char (plist-get elem :point)) 853 (goto-char (plist-get elem :point))
854 ;; Make buffer listings more informative.
855 (setq list-buffers-directory (plist-get elem :url))
838 (eww-update-header-line-format)))) 856 (eww-update-header-line-format))))
839 857
840(defun eww-next-url () 858(defun eww-next-url ()
@@ -1483,6 +1501,7 @@ Differences in #targets are ignored."
1483(defun eww-download () 1501(defun eww-download ()
1484 "Download URL under point to `eww-download-directory'." 1502 "Download URL under point to `eww-download-directory'."
1485 (interactive) 1503 (interactive)
1504 (access-file eww-download-directory "Download failed")
1486 (let ((url (get-text-property (point) 'shr-url))) 1505 (let ((url (get-text-property (point) 'shr-url)))
1487 (if (not url) 1506 (if (not url)
1488 (message "No URL under point") 1507 (message "No URL under point")