Function: erc-open
erc-open is a byte-compiled function defined in erc.el.gz.
Signature
(erc-open &optional SERVER PORT NICK FULL-NAME CONNECT PASSWD TGT-LIST CHANNEL PROCESS CLIENT-CERTIFICATE USER ID)
Documentation
Connect to SERVER on PORT as NICK with USER and FULL-NAME.
If CONNECT is non-nil, connect to the server. Otherwise assume already connected and just create a separate buffer for the new target given by CHANNEL, meaning these parameters are mutually exclusive. Note that CHANNEL may also be a query; its name has been retained for historical reasons.
Use PASSWD as user password on the server. If TGT-LIST is
non-nil, use it to initialize erc-default-recipients.
CLIENT-CERTIFICATE, if non-nil, should either be a list where the
first element is the file name of the private key corresponding
to a client certificate and the second element is the file name
of the client certificate itself to use when connecting over TLS,
or t, which means that auth-source will be queried for the
private key and the certificate.
When non-nil, ID should be a symbol for identifying the connection.
Returns the buffer for the given server or channel.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-open (&optional server port nick full-name
connect passwd tgt-list channel process
client-certificate user id)
"Connect to SERVER on PORT as NICK with USER and FULL-NAME.
If CONNECT is non-nil, connect to the server. Otherwise assume
already connected and just create a separate buffer for the new
target given by CHANNEL, meaning these parameters are mutually
exclusive. Note that CHANNEL may also be a query; its name has
been retained for historical reasons.
Use PASSWD as user password on the server. If TGT-LIST is
non-nil, use it to initialize `erc-default-recipients'.
CLIENT-CERTIFICATE, if non-nil, should either be a list where the
first element is the file name of the private key corresponding
to a client certificate and the second element is the file name
of the client certificate itself to use when connecting over TLS,
or t, which means that `auth-source' will be queried for the
private key and the certificate.
When non-nil, ID should be a symbol for identifying the connection.
Returns the buffer for the given server or channel."
(let* ((target (and channel (erc--target-from-string channel)))
(buffer (erc-get-buffer-create server port nil target id))
(old-buffer (current-buffer))
(erc--target-priors (and target ; buf from prior session
(buffer-local-value 'erc--target buffer)
(buffer-local-variables buffer)))
(old-recon-count erc-server-reconnect-count)
(old-point nil)
(delayed-modules nil)
(continued-session (and erc--server-reconnecting
(with-suppressed-warnings
((obsolete erc-reuse-buffers))
erc-reuse-buffers))))
(when connect (run-hook-with-args 'erc-before-connect server port nick))
(set-buffer buffer)
(setq old-point (point))
(setq delayed-modules
(erc--merge-local-modes (erc--update-modules)
(or erc--server-reconnecting
erc--target-priors)))
(delay-mode-hooks (erc-mode))
(setq erc-server-reconnect-count old-recon-count)
(when (setq erc-server-connected (not connect))
(setq erc-server-announced-name
(buffer-local-value 'erc-server-announced-name old-buffer)))
;; connection parameters
(setq erc-server-process process)
(setq erc-insert-marker (make-marker))
(setq erc-input-marker (make-marker))
;; go to the end of the buffer and open a new line
;; (the buffer may have existed)
(goto-char (point-max))
(forward-line 0)
(when (or continued-session (get-text-property (point) 'erc-prompt))
(setq continued-session t)
(set-marker erc-input-marker
(or (next-single-property-change (point) 'erc-prompt)
(point-max))))
(unless continued-session
(goto-char (point-max))
(insert "\n"))
(set-marker erc-insert-marker (point))
;; stack of default recipients
(setq erc-default-recipients tgt-list)
(when target
(setq erc--target target
erc-network (erc-network)))
(setq erc-server-current-nick nil)
;; Initialize erc-server-users and erc-channel-users
(if connect
(progn ;; server buffer
(setq erc-server-users
(make-hash-table :test 'equal))
(setq erc-channel-users nil))
(progn ;; target buffer
(setq erc-server-users nil)
(setq erc-channel-users
(make-hash-table :test 'equal))))
(setq erc-channel-topic "")
;; limit on the number of users on the channel (mode +l)
(setq erc-channel-user-limit nil)
(setq erc-channel-key nil)
;; last active buffer, defaults to this one
(erc-set-active-buffer buffer)
;; last invitation channel
(setq erc-invitation nil)
;; Server channel list
(setq erc-channel-list ())
;; login-time 'nick in use' error
(setq erc-bad-nick nil)
;; whether we have logged in
(setq erc-logged-in nil)
;; The local copy of `erc-nick' - the list of nicks to choose
(setq erc-default-nicks (if (consp erc-nick) erc-nick (list erc-nick)))
;; client certificate (only useful if connecting over TLS)
(setq erc-session-client-certificate client-certificate)
(setq erc-networks--id
(if connect
(or (and erc--server-reconnecting
(alist-get 'erc-networks--id erc--server-reconnecting))
(and id (erc-networks--id-create id)))
(buffer-local-value 'erc-networks--id old-buffer)))
;; debug output buffer
(setq erc-dbuf
(when erc-log-p
(get-buffer-create (concat "*ERC-DEBUG: " server "*"))))
(erc-determine-parameters server port nick full-name user passwd)
;; FIXME consolidate this prompt-setup logic with the pass above.
;; set up prompt
(unless continued-session
(goto-char (point-max))
(insert "\n"))
(if continued-session
(progn (goto-char old-point)
(erc--unhide-prompt))
(set-marker erc-insert-marker (point))
(erc-display-prompt)
(goto-char (point-max)))
(save-excursion (run-mode-hooks)
(dolist (mod (car delayed-modules)) (funcall mod +1))
(dolist (var (cdr delayed-modules)) (set var nil)))
;; Saving log file on exit
(run-hook-with-args 'erc-connect-pre-hook buffer)
(if connect
(erc-server-connect erc-session-server
erc-session-port
buffer
erc-session-client-certificate)
(erc-update-mode-line))
;; Now display the buffer in a window as per user wishes.
(unless (eq buffer old-buffer)
(when erc-log-p
;; we can't log to debug buffer, it may not exist yet
(message "erc: old buffer %s, switching to %s"
old-buffer buffer))
(erc-setup-buffer buffer))
buffer))