- ;; The simplest case: wrapper around `make-network-process'.
- (make-network-process :name name :buffer buffer
- :host host :service service)
- (let ((work-buffer (or buffer
- (generate-new-buffer " *stream buffer*")))
- (fun (cond ((eq type 'plain) 'network-stream-open-plain)
- ((memq type '(nil network starttls))
- 'network-stream-open-starttls)
- ((memq type '(tls ssl)) 'network-stream-open-tls)
- ((eq type 'shell) 'network-stream-open-shell)
- (t (error "Invalid connection type %s" type))))
- result)
- (unwind-protect
- (setq result (funcall fun name work-buffer host service parameters))
- (unless buffer
- (and (processp (car result))
- (set-process-buffer (car result) nil))
- (kill-buffer work-buffer)))
+ ;; The simplest case is equivalent to `open-network-stream'.
+ (open-network-stream name buffer host service)
+ ;; For everything else, refer to proto-stream-open-*.
+ (unless (plist-get parameters :end-of-command)
+ (setq parameters (append '(:end-of-command "\r\n") parameters)))
+ (let* ((connection-function
+ (cond
+ ((eq type 'plain) 'proto-stream-open-plain)
+ ((memq type '(nil network starttls))
+ 'proto-stream-open-starttls)
+ ((memq type '(tls ssl)) 'proto-stream-open-tls)
+ ((eq type 'shell) 'proto-stream-open-shell)
+ (t (error "Invalid connection type %s" type))))
+ (result (funcall connection-function
+ name buffer host service parameters)))