aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Pluim2020-04-02 18:41:33 +0200
committerRobert Pluim2020-04-07 14:32:44 +0200
commit6382e1330814ca4df20eeccd8b4ef9ca17b997af (patch)
treeda17e0f14357e46bacb49658b6d8ee13e4354849
parent23b04ef0e7d03cd7c178b544d5fff2bda4c7c504 (diff)
downloademacs-6382e1330814ca4df20eeccd8b4ef9ca17b997af.tar.gz
emacs-6382e1330814ca4df20eeccd8b4ef9ca17b997af.zip
Add :coding support to open-network-stream and open-gnutls-stream
* doc/lispref/processes.texi (Network): Describe :coding keyword support. * doc/misc/emacs-gnutls.texi (Help For Developers): Describe :coding keyword support. * etc/NEWS: Announce change to open-network-stream and open-gnutls-stream. * lisp/net/gnutls.el (open-gnutls-stream): Add support for :coding, pass it down to open-network-stream. * lisp/net/network-stream.el (open-network-stream) (network-stream-open-plain, network-stream-open-starttls): Add support for :coding, pass it down to make-network-process. (network-stream-open-shell): Add support-for :coding, use set-process-coding-system to set it after process creation.
-rw-r--r--doc/lispref/processes.texi6
-rw-r--r--doc/misc/emacs-gnutls.texi2
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/net/gnutls.el8
-rw-r--r--lisp/net/network-stream.el24
5 files changed, 41 insertions, 8 deletions
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 14cd079c563..735e9fd7db4 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -2463,6 +2463,12 @@ that are mainly relevant to encrypted connections:
2463@item :nowait @var{boolean} 2463@item :nowait @var{boolean}
2464If non-@code{nil}, try to make an asynchronous connection. 2464If non-@code{nil}, try to make an asynchronous connection.
2465 2465
2466@item :coding @var{coding}
2467Use this to set the coding systems used by the network process, in
2468preference to binding @code{coding-system-for-read} or
2469@code{coding-system-for-write}. @xref{Network Processes} for
2470details.
2471
2466@item :type @var{type} 2472@item :type @var{type}
2467The type of connection. Options are: 2473The type of connection. Options are:
2468 2474
diff --git a/doc/misc/emacs-gnutls.texi b/doc/misc/emacs-gnutls.texi
index 555a4b1b56e..c3e69178fca 100644
--- a/doc/misc/emacs-gnutls.texi
+++ b/doc/misc/emacs-gnutls.texi
@@ -190,7 +190,7 @@ the connection process.
190 190
191The optional @var{parameters} argument is a list of keywords and 191The optional @var{parameters} argument is a list of keywords and
192values. The only keywords which currently have any effect are 192values. The only keywords which currently have any effect are
193@code{:client-certificate} and @code{:nowait}. 193@code{:client-certificate}, @code{:nowait}, and @code{:coding}.
194 194
195Passing @w{@code{:client certificate t}} triggers looking up of client 195Passing @w{@code{:client certificate t}} triggers looking up of client
196certificates matching @var{host} and @var{service} using the 196certificates matching @var{host} and @var{service} using the
diff --git a/etc/NEWS b/etc/NEWS
index 1af368caa63..ef2697f4853 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -339,6 +339,15 @@ Emacs depended on the previous behavior; if you really want the
339process' coding-system to be nil, use 'set-process-coding-system' 339process' coding-system to be nil, use 'set-process-coding-system'
340after the process has been created, or pass in ":coding '(nil nil)". 340after the process has been created, or pass in ":coding '(nil nil)".
341 341
342+++
343** 'open-network-stream' now accepts a :coding argument.
344This allows specifying the coding systems used by a network process
345for encoding and decoding without having to bind
346coding-system-for-{read,write} or call 'set-process-coding-system'.
347
348+++
349** 'open-gnutls-stream' now also accepts a :coding argument.
350
342 351
343* Changes in Emacs 28.1 on Non-Free Operating Systems 352* Changes in Emacs 28.1 on Non-Free Operating Systems
344 353
diff --git a/lisp/net/gnutls.el b/lisp/net/gnutls.el
index 459156e6d27..cd86b4dea65 100644
--- a/lisp/net/gnutls.el
+++ b/lisp/net/gnutls.el
@@ -169,8 +169,9 @@ Third arg HOST is the name of the host to connect to, or its IP address.
169Fourth arg SERVICE is the name of the service desired, or an integer 169Fourth arg SERVICE is the name of the service desired, or an integer
170specifying a port number to connect to. 170specifying a port number to connect to.
171Fifth arg PARAMETERS is an optional list of keyword/value pairs. 171Fifth arg PARAMETERS is an optional list of keyword/value pairs.
172Only :client-certificate and :nowait keywords are recognized, and 172Only :client-certificate, :nowait, and :coding keywords are
173have the same meaning as for `open-network-stream'. 173recognized, and have the same meaning as for
174`open-network-stream'.
174For historical reasons PARAMETERS can also be a symbol, which is 175For historical reasons PARAMETERS can also be a symbol, which is
175interpreted the same as passing a list containing :nowait and the 176interpreted the same as passing a list containing :nowait and the
176value of that symbol. 177value of that symbol.
@@ -208,7 +209,8 @@ trust and key files, and priority string."
208 (gnutls-boot-parameters 209 (gnutls-boot-parameters
209 :type 'gnutls-x509pki 210 :type 'gnutls-x509pki
210 :keylist keylist 211 :keylist keylist
211 :hostname (puny-encode-domain host))))))) 212 :hostname (puny-encode-domain host))))
213 :coding (plist-get parameters :coding))))
212 (if nowait 214 (if nowait
213 process 215 process
214 (gnutls-negotiate :process process 216 (gnutls-negotiate :process process
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index e99d7a372c0..1d5cf382a84 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -113,6 +113,10 @@ values:
113 `ssl' -- Equivalent to `tls'. 113 `ssl' -- Equivalent to `tls'.
114 `shell' -- A shell connection. 114 `shell' -- A shell connection.
115 115
116:coding is a symbol or a cons used to specify the coding systems
117used to decode and encode the data which the process reads and
118writes. See `make-network-process' for details.
119
116:return-list specifies this function's return value. 120:return-list specifies this function's return value.
117 If omitted or nil, return a process object. A non-nil means to 121 If omitted or nil, return a process object. A non-nil means to
118 return (PROC . PROPS), where PROC is a process object and PROPS 122 return (PROC . PROPS), where PROC is a process object and PROPS
@@ -189,7 +193,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
189 :host (puny-encode-domain host) :service service 193 :host (puny-encode-domain host) :service service
190 :nowait (plist-get parameters :nowait) 194 :nowait (plist-get parameters :nowait)
191 :tls-parameters 195 :tls-parameters
192 (plist-get parameters :tls-parameters)) 196 (plist-get parameters :tls-parameters)
197 :coding (plist-get parameters :coding))
193 (let ((work-buffer (or buffer 198 (let ((work-buffer (or buffer
194 (generate-new-buffer " *stream buffer*"))) 199 (generate-new-buffer " *stream buffer*")))
195 (fun (cond ((and (eq type 'plain) 200 (fun (cond ((and (eq type 'plain)
@@ -249,7 +254,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
249 (stream (make-network-process :name name :buffer buffer 254 (stream (make-network-process :name name :buffer buffer
250 :host (puny-encode-domain host) 255 :host (puny-encode-domain host)
251 :service service 256 :service service
252 :nowait (plist-get parameters :nowait)))) 257 :nowait (plist-get parameters :nowait)
258 :coding (plist-get parameters :coding))))
253 (when (plist-get parameters :warn-unless-encrypted) 259 (when (plist-get parameters :warn-unless-encrypted)
254 (setq stream (nsm-verify-connection stream host service nil t))) 260 (setq stream (nsm-verify-connection stream host service nil t)))
255 (list stream 261 (list stream
@@ -270,7 +276,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
270 ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE) 276 ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE)
271 (stream (make-network-process :name name :buffer buffer 277 (stream (make-network-process :name name :buffer buffer
272 :host (puny-encode-domain host) 278 :host (puny-encode-domain host)
273 :service service)) 279 :service service
280 :coding (plist-get parameters :coding)))
274 (greeting (and (not (plist-get parameters :nogreeting)) 281 (greeting (and (not (plist-get parameters :nogreeting))
275 (network-stream-get-response stream start eoc))) 282 (network-stream-get-response stream start eoc)))
276 (capabilities (network-stream-command stream capability-command 283 (capabilities (network-stream-command stream capability-command
@@ -350,7 +357,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
350 (setq stream 357 (setq stream
351 (make-network-process :name name :buffer buffer 358 (make-network-process :name name :buffer buffer
352 :host (puny-encode-domain host) 359 :host (puny-encode-domain host)
353 :service service)) 360 :service service
361 :coding (plist-get parameters :coding)))
354 (network-stream-get-response stream start eoc))) 362 (network-stream-get-response stream start eoc)))
355 (unless (process-live-p stream) 363 (unless (process-live-p stream)
356 (error "Unable to negotiate a TLS connection with %s/%s" 364 (error "Unable to negotiate a TLS connection with %s/%s"
@@ -453,6 +461,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
453 (let* ((capability-command (plist-get parameters :capability-command)) 461 (let* ((capability-command (plist-get parameters :capability-command))
454 (eoc (plist-get parameters :end-of-command)) 462 (eoc (plist-get parameters :end-of-command))
455 (start (with-current-buffer buffer (point))) 463 (start (with-current-buffer buffer (point)))
464 (coding (plist-get parameters :coding))
456 (stream (let ((process-connection-type nil)) 465 (stream (let ((process-connection-type nil))
457 (start-process name buffer shell-file-name 466 (start-process name buffer shell-file-name
458 shell-command-switch 467 shell-command-switch
@@ -461,6 +470,13 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
461 (format-spec-make 470 (format-spec-make
462 ?s host 471 ?s host
463 ?p service)))))) 472 ?p service))))))
473 (when coding (if (consp coding)
474 (set-process-coding-system stream
475 (car coding)
476 (cdr coding))
477 (set-process-coding-system stream
478 coding
479 coding)))
464 (list stream 480 (list stream
465 (network-stream-get-response stream start eoc) 481 (network-stream-get-response stream start eoc)
466 (network-stream-command stream capability-command 482 (network-stream-command stream capability-command