aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net
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
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')
-rw-r--r--lisp/net/eww.el71
-rw-r--r--lisp/net/network-stream.el4
-rw-r--r--lisp/net/shr.el32
-rw-r--r--lisp/net/tramp.el30
-rw-r--r--lisp/net/zeroconf.el6
5 files changed, 97 insertions, 46 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")
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index 93e1bae5fc2..bf60eee673c 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -139,6 +139,10 @@ a greeting from the server.
139:nowait, if non-nil, says the connection should be made 139:nowait, if non-nil, says the connection should be made
140asynchronously, if possible. 140asynchronously, if possible.
141 141
142:shell-command is a format-spec string that can be used if :type
143is `shell'. It has two specs, %s for host and %p for port
144number. Example: \"ssh gateway nc %s %p\".
145
142:tls-parameters is a list that should be supplied if you're 146:tls-parameters is a list that should be supplied if you're
143opening a TLS connection. The first element is the TLS 147opening a TLS connection. The first element is the TLS
144type (either `gnutls-x509pki' or `gnutls-anon'), and the 148type (either `gnutls-x509pki' or `gnutls-anon'), and the
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index e0bb3dbb2b7..b7c48288494 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -96,8 +96,9 @@ If nil, don't draw horizontal table lines."
96(defcustom shr-width nil 96(defcustom shr-width nil
97 "Frame width to use for rendering. 97 "Frame width to use for rendering.
98May either be an integer specifying a fixed width in characters, 98May either be an integer specifying a fixed width in characters,
99or nil, meaning that the full width of the window should be 99or nil, meaning that the full width of the window should be used.
100used." 100If `shr-use-fonts' is set, the mean character width is used to
101compute the pixel width, which is used instead."
101 :version "25.1" 102 :version "25.1"
102 :type '(choice (integer :tag "Fixed width in characters") 103 :type '(choice (integer :tag "Fixed width in characters")
103 (const :tag "Use the width of the window" nil)) 104 (const :tag "Use the width of the window" nil))
@@ -978,7 +979,7 @@ element is the data blob and the second element is the content-type."
978 (create-image data nil t :ascent 100 979 (create-image data nil t :ascent 100
979 :format content-type)) 980 :format content-type))
980 ((eq content-type 'image/svg+xml) 981 ((eq content-type 'image/svg+xml)
981 (create-image data 'svg t :ascent 100)) 982 (create-image data 'imagemagick t :ascent 100))
982 ((eq size 'full) 983 ((eq size 'full)
983 (ignore-errors 984 (ignore-errors
984 (shr-rescale-image data content-type 985 (shr-rescale-image data content-type
@@ -1011,18 +1012,25 @@ element is the data blob and the second element is the content-type."
1011 image) 1012 image)
1012 (insert (or alt "")))) 1013 (insert (or alt ""))))
1013 1014
1014(defun shr-rescale-image (data content-type width height) 1015(defun shr-rescale-image (data content-type width height
1016 &optional max-width max-height)
1015 "Rescale DATA, if too big, to fit the current buffer. 1017 "Rescale DATA, if too big, to fit the current buffer.
1016WIDTH and HEIGHT are the sizes given in the HTML data, if any." 1018WIDTH and HEIGHT are the sizes given in the HTML data, if any.
1019
1020The size of the displayed image will not exceed
1021MAX-WIDTH/MAX-HEIGHT. If not given, use the current window
1022width/height instead."
1017 (if (or (not (fboundp 'imagemagick-types)) 1023 (if (or (not (fboundp 'imagemagick-types))
1018 (not (get-buffer-window (current-buffer)))) 1024 (not (get-buffer-window (current-buffer))))
1019 (create-image data nil t :ascent 100) 1025 (create-image data nil t :ascent 100)
1020 (let* ((edges (window-inside-pixel-edges 1026 (let* ((edges (window-inside-pixel-edges
1021 (get-buffer-window (current-buffer)))) 1027 (get-buffer-window (current-buffer))))
1022 (max-width (truncate (* shr-max-image-proportion 1028 (max-width (truncate (* shr-max-image-proportion
1023 (- (nth 2 edges) (nth 0 edges))))) 1029 (or max-width
1030 (- (nth 2 edges) (nth 0 edges))))))
1024 (max-height (truncate (* shr-max-image-proportion 1031 (max-height (truncate (* shr-max-image-proportion
1025 (- (nth 3 edges) (nth 1 edges))))) 1032 (or max-height
1033 (- (nth 3 edges) (nth 1 edges))))))
1026 (scaling (image-compute-scaling-factor image-scaling-factor))) 1034 (scaling (image-compute-scaling-factor image-scaling-factor)))
1027 (when (or (and width 1035 (when (or (and width
1028 (> width max-width)) 1036 (> width max-width))
@@ -1059,8 +1067,7 @@ Return a string with image data."
1059 (when (ignore-errors 1067 (when (ignore-errors
1060 (url-cache-extract (url-cache-create-filename (shr-encode-url url))) 1068 (url-cache-extract (url-cache-create-filename (shr-encode-url url)))
1061 t) 1069 t)
1062 (when (or (search-forward "\n\n" nil t) 1070 (when (re-search-forward "\r?\n\r?\n" nil t)
1063 (search-forward "\r\n\r\n" nil t))
1064 (shr-parse-image-data))))) 1071 (shr-parse-image-data)))))
1065 1072
1066(declare-function libxml-parse-xml-region "xml.c" 1073(declare-function libxml-parse-xml-region "xml.c"
@@ -1079,9 +1086,12 @@ Return a string with image data."
1079 obarray))))))) 1086 obarray)))))))
1080 ;; SVG images may contain references to further images that we may 1087 ;; SVG images may contain references to further images that we may
1081 ;; want to block. So special-case these by parsing the XML data 1088 ;; want to block. So special-case these by parsing the XML data
1082 ;; and remove the blocked bits. 1089 ;; and remove anything that looks like a blocked bit.
1083 (when (eq content-type 'image/svg+xml) 1090 (when (and shr-blocked-images
1091 (eq content-type 'image/svg+xml))
1084 (setq data 1092 (setq data
1093 ;; Note that libxml2 doesn't parse everything perfectly,
1094 ;; so glitches may occur during this transformation.
1085 (shr-dom-to-xml 1095 (shr-dom-to-xml
1086 (libxml-parse-xml-region (point) (point-max))))) 1096 (libxml-parse-xml-region (point) (point-max)))))
1087 (list data content-type))) 1097 (list data content-type)))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index fc7fdd30850..48dcd5edd11 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3614,18 +3614,36 @@ connection buffer."
3614 3614
3615;;; Utility functions: 3615;;; Utility functions:
3616 3616
3617(defun tramp-accept-process-output (&optional proc timeout timeout-msecs) 3617(defun tramp-accept-process-output (proc timeout)
3618 "Like `accept-process-output' for Tramp processes. 3618 "Like `accept-process-output' for Tramp processes.
3619This is needed in order to hide `last-coding-system-used', which is set 3619This is needed in order to hide `last-coding-system-used', which is set
3620for process communication also." 3620for process communication also."
3621 ;; FIXME: There are problems, when an asynchronous process runs in
3622 ;; parallel, and also timers are active. See
3623 ;; <http://lists.gnu.org/archive/html/tramp-devel/2017-01/msg00010.html>.
3624 (when (and timer-event-last
3625 (string-prefix-p "*tramp/" (process-name proc))
3626 (let (result)
3627 (maphash
3628 (lambda (key _value)
3629 (and (processp key)
3630 (not (string-prefix-p "*tramp/" (process-name key)))
3631 (tramp-compat-process-live-p key)
3632 (setq result t)))
3633 tramp-cache-data)
3634 result))
3635 (sit-for 0.01 'nodisp))
3621 (with-current-buffer (process-buffer proc) 3636 (with-current-buffer (process-buffer proc)
3622 (let (buffer-read-only last-coding-system-used) 3637 (let (buffer-read-only last-coding-system-used)
3623 ;; Under Windows XP, accept-process-output doesn't return 3638 ;; Under Windows XP, accept-process-output doesn't return
3624 ;; sometimes. So we add an additional timeout. 3639 ;; sometimes. So we add an additional timeout. JUST-THIS-ONE
3625 (with-timeout ((or timeout 1)) 3640 ;; is set due to Bug#12145.
3626 (accept-process-output proc timeout timeout-msecs (and proc t))) 3641 (tramp-message
3627 (tramp-message proc 10 "%s %s\n%s" 3642 proc 10 "%s %s %s\n%s"
3628 proc (process-status proc) (buffer-string))))) 3643 proc (process-status proc)
3644 (with-timeout (timeout)
3645 (accept-process-output proc timeout nil t))
3646 (buffer-string)))))
3629 3647
3630(defun tramp-check-for-regexp (proc regexp) 3648(defun tramp-check-for-regexp (proc regexp)
3631 "Check, whether REGEXP is contained in process buffer of PROC. 3649 "Check, whether REGEXP is contained in process buffer of PROC.
diff --git a/lisp/net/zeroconf.el b/lisp/net/zeroconf.el
index 37816bb8881..393f3a549f9 100644
--- a/lisp/net/zeroconf.el
+++ b/lisp/net/zeroconf.el
@@ -256,7 +256,7 @@ supported keys depend on the service type.")
256 "Returns all discovered Avahi service names as list." 256 "Returns all discovered Avahi service names as list."
257 (let (result) 257 (let (result)
258 (maphash 258 (maphash
259 (lambda (key value) (add-to-list 'result (zeroconf-service-name value))) 259 (lambda (_key value) (add-to-list 'result (zeroconf-service-name value)))
260 zeroconf-services-hash) 260 zeroconf-services-hash)
261 result)) 261 result))
262 262
@@ -264,7 +264,7 @@ supported keys depend on the service type.")
264 "Returns all discovered Avahi service types as list." 264 "Returns all discovered Avahi service types as list."
265 (let (result) 265 (let (result)
266 (maphash 266 (maphash
267 (lambda (key value) (add-to-list 'result (zeroconf-service-type value))) 267 (lambda (_key value) (add-to-list 'result (zeroconf-service-type value)))
268 zeroconf-services-hash) 268 zeroconf-services-hash)
269 result)) 269 result))
270 270
@@ -276,7 +276,7 @@ The service type is one of the returned values of
276format of SERVICE." 276format of SERVICE."
277 (let (result) 277 (let (result)
278 (maphash 278 (maphash
279 (lambda (key value) 279 (lambda (_key value)
280 (when (equal type (zeroconf-service-type value)) 280 (when (equal type (zeroconf-service-type value))
281 (add-to-list 'result value))) 281 (add-to-list 'result value)))
282 zeroconf-services-hash) 282 zeroconf-services-hash)