Function: erc-cmd-JOIN

erc-cmd-JOIN is a byte-compiled function defined in erc.el.gz.

Signature

(erc-cmd-JOIN CHANNEL &optional KEY)

Documentation

Join the channel given in CHANNEL, optionally with KEY.

If CHANNEL is specified as "-invite", join the channel to which you were most recently invited. See also invitation.

Aliases

erc-cmd-J erc-cmd-CHANNEL

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-cmd-JOIN (channel &optional key)
  "Join the channel given in CHANNEL, optionally with KEY.
If CHANNEL is specified as \"-invite\", join the channel to which you
were most recently invited.  See also `invitation'."
  (let (chnl)
    (if (string= (upcase channel) "-INVITE")
        (if erc-invitation
            (setq chnl erc-invitation)
          (erc-display-message nil 'error (current-buffer) 'no-invitation))
      (setq chnl (erc-ensure-channel-name channel)))
    (when chnl
      ;; Prevent double joining of same channel on same server.
      (if-let* ((existing (erc-get-buffer chnl erc-server-process))
                ((with-current-buffer existing
                   (erc-get-channel-user (erc-current-nick)))))
          (switch-to-buffer existing)
        (when-let* ; bind `erc-join-buffer' when /JOIN issued
            ((erc--called-as-input-p)
             (fn (lambda (proc parsed)
                   (when-let* ; `fn' wrapper already removed from hook
                       (((equal (car (erc-response.command-args parsed))
                                channel))
                        (sn (erc-extract-nick (erc-response.sender parsed)))
                        ((erc-nick-equal-p sn (erc-current-nick)))
                        (erc-join-buffer (or erc-interactive-display
                                             erc-join-buffer))
                        (erc--display-context `((erc-interactive-display
                                                 . /JOIN)
                                                ,@erc--display-context)))
                     (run-hook-with-args-until-success
                      'erc-server-JOIN-functions proc parsed)
                     t))))
          (erc-with-server-buffer
            (erc-once-with-server-event "JOIN" fn)))
        (erc-server-join-channel nil chnl key))))
  t)