Function: erc-select-read-args

erc-select-read-args is an autoloaded and byte-compiled function defined in erc.el.gz.

Signature

(erc-select-read-args)

Documentation

Prompt for connection parameters and return them in a plist.

By default, collect :server, :port, :nickname, and
:password. With a non-nil prefix argument, also prompt for
:user and :full-name. Also return various environmental
properties needed by entry-point commands, like erc-tls.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
;;;###autoload
(defun erc-select-read-args ()
  "Prompt for connection parameters and return them in a plist.
By default, collect `:server', `:port', `:nickname', and
`:password'.  With a non-nil prefix argument, also prompt for
`:user' and `:full-name'.  Also return various environmental
properties needed by entry-point commands, like `erc-tls'."
  (let* ((input (let ((d (erc-compute-server)))
                  (if erc--prompt-for-server-function
                      (funcall erc--prompt-for-server-function)
                    (read-string (format-prompt "Server or URL" d)
                                 nil 'erc-server-history-list d))))
         ;; For legacy reasons, also accept a URL without a scheme.
         (url (url-generic-parse-url (erc--ensure-url input)))
         (server (url-host url))
         (sp (and (string-suffix-p "s" (url-type url)) erc-default-port-tls))
         (port (or (url-portspec url)
                   (erc-compute-port
                    (let ((d (erc-compute-port sp))) ; may be a string
                      (erc-string-to-port
                       (read-string (format-prompt "Port" d) nil nil d))))))
         ;; Trust the user not to connect twice accidentally.  We
         ;; can't use `erc-already-logged-in' to check for an existing
         ;; connection without modifying it to consider USER and PASS.
         (nick (or (url-user url)
                   (let ((d (erc-compute-nick)))
                     (read-string (format-prompt "Nickname" d)
                                  nil 'erc-nick-history-list d))))
         (user (and current-prefix-arg
                    (let ((d (erc-compute-user (url-user url))))
                      (read-string (format-prompt "User" d)
                                   nil nil d))))
         (full (and current-prefix-arg
                    (let ((d (erc-compute-full-name (url-user url))))
                      (read-string (format-prompt "Full name" d)
                                   nil nil d))))
         (passwd (let* ((p (with-suppressed-warnings ((obsolete erc-password))
                             (or (url-password url) erc-password)))
                        (m (if p
                               (format-prompt "Server password" p)
                             "Server password (optional): ")))
                   (if erc-prompt-for-password (read-passwd m nil p) p)))
         (opener (and (or sp (erc-port-equal port erc-default-port-tls)
                          (and (equal server erc-default-server)
                               (not (string-prefix-p "irc://" input))
                               (erc-port-equal port erc-default-port)
                               (y-or-n-p "Connect using TLS instead? ")
                               (setq port erc-default-port-tls)))
                      #'erc-open-tls-stream))
         env)
    (when erc-interactive-display
      (push `(erc-join-buffer . ,erc-interactive-display) env))
    (when erc--display-context
      (push `(erc--display-context . ,erc--display-context) env))
    (when opener
      (push `(erc-server-connect-function . ,opener) env))
    (when (and passwd (string= "" passwd))
      (setq passwd nil))
    `( :server ,server :port ,port :nick ,nick ,@(and user `(:user ,user))
       ,@(and passwd `(:password ,passwd)) ,@(and full `(:full-name ,full))
       ,@(and env `(--interactive-env-- ,env)))))