+(defun erc-tls (&rest r)
+ "Interactively select TLS connection parameters and run ERC.
+Arguments are the same as for `erc'."
+ (interactive (erc-select-read-args))
+ (let ((erc-server-connect-function 'erc-open-tls-stream))
+ (apply 'erc r)))
+
+(declare-function open-tls-stream "tls" (name buffer host port))
+
+(defun erc-open-tls-stream (name buffer host port)
+ "Open an TLS stream to an IRC server.
+The process will be given the name NAME, its target buffer will be
+BUFFER. HOST and PORT specify the connection target."
+ (when (condition-case nil
+ (require 'tls)
+ (error (message "You don't have tls.el. %s"
+ "Try using `erc-ssl' instead.")
+ nil))
+ (open-tls-stream name buffer host port)))
+
+;;; Displaying error messages
+
+(defun erc-error (&rest args)
+ "Pass ARGS to `format', and display the result as an error message.
+If `debug-on-error' is set to non-nil, then throw a real error with this
+message instead, to make debugging easier."
+ (if debug-on-error
+ (apply #'error args)
+ (apply #'message args)
+ (beep)))
+