From 4bba86e6210a74326e843a8fdc8409127105e1fe Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Wed, 15 Jun 2011 22:44:45 +0200 Subject: [PATCH] (open-network-stream): Add the keyword :always-query-capabilities. This is for the case where you want to force a `plain' network connection, but the protocol still requires the capabilitiy command (i.e., SMTP and EHLO). --- lisp/ChangeLog | 5 +++++ lisp/net/network-stream.el | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3ee020f33c5..d2d44793366 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -14,6 +14,11 @@ 2011-06-15 Lars Magne Ingebrigtsen + * net/network-stream.el (open-network-stream): Add the keyword + :always-query-capabilities for the case where you want to force a + `plain' network connection, but the protocol still requires the + capabilitiy command (i.e., SMTP and EHLO). + * subr.el (process-live-p): Rename from `process-alive-p' for consistency with other `-live-p' functions. diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el index 61e4630906d..b17b9ae805c 100644 --- a/lisp/net/network-stream.el +++ b/lisp/net/network-stream.el @@ -109,6 +109,9 @@ values: capability command, and should return the command to switch on STARTTLS if the server supports STARTTLS, and nil otherwise. +:always-query-capabilies says whether to query the server for +capabilities, even if we're doing a `plain' network connection. + :nowait is a boolean that says the connection should be made asynchronously, if possible." (unless (featurep 'make-network-process) @@ -126,8 +129,11 @@ asynchronously, if possible." :nowait (plist-get parameters :nowait)) (let ((work-buffer (or buffer (generate-new-buffer " *stream buffer*"))) - (fun (cond ((eq type 'plain) 'network-stream-open-plain) - ((memq type '(nil network starttls)) + (fun (cond ((and (eq type 'plain) + (not (plist-get parameters + :always-query-capabilities))) + 'network-stream-open-plain) + ((memq type '(nil network starttls plain)) 'network-stream-open-starttls) ((memq type '(tls ssl)) 'network-stream-open-tls) ((eq type 'shell) 'network-stream-open-shell) @@ -182,7 +188,8 @@ asynchronously, if possible." (executable-find "gnutls-cli"))) capabilities success-string starttls-function (setq starttls-command - (funcall starttls-function capabilities))) + (funcall starttls-function capabilities)) + (not (eq (plist-get parameters :type) 'plain))) ;; If using external STARTTLS, drop this connection and start ;; anew with `starttls-open-stream'. (unless (fboundp 'open-gnutls-stream) -- 2.39.2