Function: erc-handle-irc-url

erc-handle-irc-url is an autoloaded and byte-compiled function defined in erc.el.gz.

Signature

(erc-handle-irc-url HOST PORT CHANNEL NICK PASSWORD &optional SCHEME)

Documentation

Use ERC to IRC on HOST:PORT in CHANNEL.

If ERC is already connected to HOST:PORT, simply /join CHANNEL. Otherwise, connect to HOST:PORT as NICK and /join CHANNEL.

Beginning with ERC 5.5, new connections require human intervention. Customize erc-url-connect-function to override this.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
;;;###autoload
(defun erc-handle-irc-url (host port channel nick password &optional scheme)
  "Use ERC to IRC on HOST:PORT in CHANNEL.
If ERC is already connected to HOST:PORT, simply /join CHANNEL.
Otherwise, connect to HOST:PORT as NICK and /join CHANNEL.

Beginning with ERC 5.5, new connections require human intervention.
Customize `erc-url-connect-function' to override this."
  (when (eql port 0) (setq port nil))
  (let* ((net (erc-networks--determine host))
         (erc--display-context `((erc-interactive-display . url)
                                 ,@erc--display-context))
         (server-buffer
          ;; Viable matches may slip through the cracks for unknown
          ;; networks.  Additional passes could likely improve things.
          (car (erc-buffer-filter
                (lambda ()
                  (and (not erc--target)
                       (erc-server-process-alive)
                       ;; Always trust a matched network.
                       (or (and net (eq net (erc-network)))
                           (and (string-equal erc-session-server host)
                                ;; Ports only matter when dialed hosts
                                ;; match and we have sufficient info.
                                (or (not port)
                                    (= (erc-normalize-port erc-session-port)
                                       port)))))))))
         key deferred)
    (unless server-buffer
      (setq deferred t
            server-buffer (apply (or erc-url-connect-function
                                     #'erc--url-default-connect-function)
                                 scheme
                                 :server host
                                 `(,@(and port (list :port port))
                                   ,@(and nick (list :nick nick))
                                   ,@(and password `(:password ,password))))))
    (when channel
      ;; These aren't percent-decoded by default
      (when (string-prefix-p "%" channel)
        (setq channel (url-unhex-string channel)))
      (cl-multiple-value-setq (channel key) (split-string channel "[?]"))
      (if deferred
          ;; Alternatively, we could make this a defmethod, so when
          ;; autojoin is loaded, it can do its own thing.  Also, as
          ;; with `erc-once-with-server-event', it's fine to set local
          ;; hooks here because they're killed when reconnecting.
          (with-current-buffer server-buffer
            (letrec ((f (lambda (&rest _)
                          (remove-hook 'erc-after-connect f t)
                          (erc-cmd-JOIN channel key))))
              (add-hook 'erc-after-connect f nil t)))
        (with-current-buffer server-buffer
          (erc-cmd-JOIN channel key))))))