mirror of https://github.com/nealey/rcirc
Add the notion of a network, to make ZNC less confusing
This commit is contained in:
parent
125b12d3a9
commit
ec9e3fa273
33
rcirc.el
33
rcirc.el
|
@ -437,12 +437,16 @@ Do not connect to a server if it is already connected.
|
||||||
If ARG is non-nil, instead prompt for connection parameters."
|
If ARG is non-nil, instead prompt for connection parameters."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(if arg
|
(if arg
|
||||||
(let* ((server (completing-read "IRC Server: "
|
(let* ((network (completing-read "IRC Network: "
|
||||||
rcirc-server-alist
|
rcirc-server-alist
|
||||||
nil nil
|
nil nil
|
||||||
(caar rcirc-server-alist)
|
(caar rcirc-server-alist)
|
||||||
'rcirc-server-name-history))
|
'rcirc-server-name-history))
|
||||||
(server-plist (cdr (assoc-string server rcirc-server-alist)))
|
(server-plist (cdr (assoc-string network rcirc-server-alist)))
|
||||||
|
(host (read-string "IRC Host: "
|
||||||
|
(or (plist-get server-plist :host)
|
||||||
|
network)
|
||||||
|
'rirc-server-host-history))
|
||||||
(port (read-string "IRC Port: "
|
(port (read-string "IRC Port: "
|
||||||
(number-to-string
|
(number-to-string
|
||||||
(or (plist-get server-plist :port)
|
(or (plist-get server-plist :port)
|
||||||
|
@ -466,13 +470,14 @@ If ARG is non-nil, instead prompt for connection parameters."
|
||||||
" "))
|
" "))
|
||||||
"[, ]+" t))
|
"[, ]+" t))
|
||||||
(encryption (rcirc-prompt-for-encryption server-plist)))
|
(encryption (rcirc-prompt-for-encryption server-plist)))
|
||||||
(rcirc-connect server port nick user-name
|
(rcirc-connect network host port nick user-name
|
||||||
rcirc-default-full-name
|
rcirc-default-full-name
|
||||||
channels password encryption))
|
channels password encryption))
|
||||||
;; connect to servers in `rcirc-server-alist'
|
;; connect to servers in `rcirc-server-alist'
|
||||||
(let (connected-servers)
|
(let (connected-servers)
|
||||||
(dolist (c rcirc-server-alist)
|
(dolist (c rcirc-server-alist)
|
||||||
(let ((server (car c))
|
(let ((network (car c))
|
||||||
|
(host (or (plist-get (cdr c) :host) (car c)))
|
||||||
(nick (or (plist-get (cdr c) :nick) rcirc-default-nick))
|
(nick (or (plist-get (cdr c) :nick) rcirc-default-nick))
|
||||||
(port (or (plist-get (cdr c) :port) rcirc-default-port))
|
(port (or (plist-get (cdr c) :port) rcirc-default-port))
|
||||||
(user-name (or (plist-get (cdr c) :user-name)
|
(user-name (or (plist-get (cdr c) :user-name)
|
||||||
|
@ -483,22 +488,20 @@ If ARG is non-nil, instead prompt for connection parameters."
|
||||||
(password (plist-get (cdr c) :password))
|
(password (plist-get (cdr c) :password))
|
||||||
(encryption (plist-get (cdr c) :encryption))
|
(encryption (plist-get (cdr c) :encryption))
|
||||||
contact)
|
contact)
|
||||||
(when server
|
(when network
|
||||||
(let (connected)
|
(let (connected)
|
||||||
(dolist (p (rcirc-process-list))
|
(dolist (p (rcirc-process-list))
|
||||||
(when (string= server (process-name p))
|
(when (string= network (process-name p))
|
||||||
(setq connected p)))
|
(setq connected p)))
|
||||||
(if (not connected)
|
(if (not connected)
|
||||||
(condition-case e
|
(condition-case e
|
||||||
(rcirc-connect server port nick user-name
|
(rcirc-connect network host port nick user-name
|
||||||
full-name channels password encryption)
|
full-name channels password encryption)
|
||||||
(quit (message "Quit connecting to %s" server)))
|
(quit (message "Quit connecting to %s" network)))
|
||||||
|
;;; XXX: this needs to be fixed.
|
||||||
(with-current-buffer (process-buffer connected)
|
(with-current-buffer (process-buffer connected)
|
||||||
(setq contact (process-contact
|
|
||||||
(get-buffer-process (current-buffer)) :host))
|
|
||||||
(setq connected-servers
|
(setq connected-servers
|
||||||
(cons (if (stringp contact) contact server)
|
(cons network connected-servers))))))))
|
||||||
connected-servers))))))))
|
|
||||||
(when connected-servers
|
(when connected-servers
|
||||||
(message "Already connected to %s"
|
(message "Already connected to %s"
|
||||||
(if (cdr connected-servers)
|
(if (cdr connected-servers)
|
||||||
|
@ -524,7 +527,7 @@ If ARG is non-nil, instead prompt for connection parameters."
|
||||||
(defvar rcirc-process nil)
|
(defvar rcirc-process nil)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun rcirc-connect (server &optional port nick user-name
|
(defun rcirc-connect (network server &optional port nick user-name
|
||||||
full-name startup-channels password encryption)
|
full-name startup-channels password encryption)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(message "Connecting to %s..." server)
|
(message "Connecting to %s..." server)
|
||||||
|
@ -539,7 +542,7 @@ If ARG is non-nil, instead prompt for connection parameters."
|
||||||
(full-name (or full-name rcirc-default-full-name))
|
(full-name (or full-name rcirc-default-full-name))
|
||||||
(startup-channels startup-channels)
|
(startup-channels startup-channels)
|
||||||
(process (open-network-stream
|
(process (open-network-stream
|
||||||
server nil server port-number
|
network nil server port-number
|
||||||
:type (or encryption 'plain))))
|
:type (or encryption 'plain))))
|
||||||
;; set up process
|
;; set up process
|
||||||
(set-process-coding-system process 'raw-text 'raw-text)
|
(set-process-coding-system process 'raw-text 'raw-text)
|
||||||
|
@ -2009,7 +2012,7 @@ activity. Only run if the buffer is not visible and
|
||||||
(t "[]")))
|
(t "[]")))
|
||||||
(run-hooks 'rcirc-update-activity-string-hook)))
|
(run-hooks 'rcirc-update-activity-string-hook)))
|
||||||
|
|
||||||
(defun rcirc-activity-string (buffers)
|
(defun rcirc-activity-string (buffers &optional ignore-faceless)
|
||||||
(mapconcat (lambda (b)
|
(mapconcat (lambda (b)
|
||||||
(let ((s (substring-no-properties (rcirc-short-buffer-name b))))
|
(let ((s (substring-no-properties (rcirc-short-buffer-name b))))
|
||||||
(with-current-buffer b
|
(with-current-buffer b
|
||||||
|
|
Loading…
Reference in New Issue