From 97910038d37d060ca0231a56d06641a5b4ced647 Mon Sep 17 00:00:00 2001 From: ueno Date: Sun, 17 Sep 2000 18:17:51 +0000 Subject: [PATCH] * liece-vars.el (liece-highlight-mode): Set default to t. * liece.el (liece-open-server): Simplify. (liece-start-server): Canonicalize `liece-server' here. --- lisp/ChangeLog | 7 +++ lisp/liece-vars.el | 2 +- lisp/liece.el | 167 ++++++++++++++++++++++------------------------------ 3 files changed, 78 insertions(+), 98 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8cbb0dd..68c75b7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2000-09-17 Daiki Ueno + + * liece-vars.el (liece-highlight-mode): Set default to t. + + * liece.el (liece-open-server): Simplify. + (liece-start-server): Canonicalize `liece-server' here. + 2000-09-17 Akira Ohashi * liece-menu.el (liece-menu-channel-menu): Move `liece-command-freeze' diff --git a/lisp/liece-vars.el b/lisp/liece-vars.el index 0f15e44..6e8a51f 100644 --- a/lisp/liece-vars.el +++ b/lisp/liece-vars.el @@ -446,7 +446,7 @@ Otherwise you might get killed again if automagic reconnect is too fast." :group 'liece-look) ;; Highlight. -(defcustom liece-highlight-mode nil +(defcustom liece-highlight-mode t "If non nil, IRC buffer is highlighted by specific rule." :type 'boolean :group 'liece-highlight) diff --git a/lisp/liece.el b/lisp/liece.el index 81bbe9e..e798957 100644 --- a/lisp/liece.el +++ b/lisp/liece.el @@ -339,32 +339,27 @@ Return non-nil if stream is opened." "Open network stream to remote irc server. If optional argument CONFIRM is non-nil, ask the host that the server is running on." - (if (liece-server-opened) - ;; Stream is already opened. - nil - ;; Open IRC server. - (when (or confirm (null liece-server)) + (when (or confirm + (null (or liece-server + (setq liece-server (getenv "IRCSERVER"))))) + (setq liece-server (completing-read (_ "IRC server: ") liece-server-alist))) + (unless (listp liece-server) + (let ((entry (assoc liece-server liece-server-alist))) + (if entry + (setq liece-server (cdr entry))) (setq liece-server - (completing-read (_ "IRC server: ") liece-server-alist))) - (and confirm - liece-ask-for-nickname - (setq liece-nickname - (read-string (_ "Enter your nickname: ") liece-nickname))) - ;; If no server name is given, local host is assumed. - (and - (stringp liece-server) - (string-equal liece-server "") - (setq liece-server (system-name))) - (let ((host (liece-server-host))) - (liece-message - (_ "Connecting to IRC server on %s...") host) - (cond - ((liece-open-server liece-server liece-service)) - ((and (stringp liece-status-message-string) - (> (length liece-status-message-string) 0)) - ;; Show valuable message if available. - (error liece-status-message-string)) - (t (error (_ "Cannot open IRC server on %s") host)))))) + (let ((plist (liece-server-parse-string liece-server))) + (unless entry + (set-alist 'liece-server-alist liece-server plist) + (setq liece-save-variables-are-dirty t)) + plist)))) + (when (or (and confirm liece-ask-for-nickname) + (null liece-nickname)) + (setq liece-nickname (read-string (_ "Enter your nickname: ") liece-nickname))) + (let ((host (liece-server-host))) + (liece-message + (_ "Connecting to IRC server on %s...") host) + (liece-open-server liece-server liece-service))) (defun liece-close-server-internal () "Close connection to chat server." @@ -404,9 +399,9 @@ the `liece-server-keyword-map' variable." (lambda (keyword) (list (intern (substring (symbol-name (car keyword)) 1)) (if (cadr keyword) - `(or (plist-get plist ',(car keyword)) + `(or (plist-get ,plist ',(car keyword)) ,(cadr keyword)) - `(plist-get plist ',(car keyword))))) + `(plist-get ,plist ',(car keyword))))) liece-server-keyword-map) ,@body)) @@ -435,76 +430,53 @@ the `liece-server-keyword-map' variable." "Open chat server on HOST. If HOST is nil, use value of environment variable \"IRCSERVER\". If optional argument SERVICE is non-nil, open by the service name." - (let* ((host (or host (getenv "IRCSERVER"))) - (plist - (if (listp host) - host - (or (cdr (string-assoc-ignore-case host liece-server-alist)) - (liece-server-parse-string host)))) - status) - (setq liece-status-message-string "") - (when (stringp plist) ;; Old style server entry... - (setq plist (liece-server-parse-string host))) - (when (and (stringp host) - (null (string-assoc-ignore-case host liece-server-alist))) - (push (cons host plist) liece-server-alist) - (setq liece-save-variables-are-dirty t)) - (liece-server-keyword-bind plist - ;; Execute preconnecting script - (when prescript - (if (fboundp prescript) - (funcall prescript) - (call-process shell-file-name nil nil nil - shell-command-switch prescript)) - (when prescript-delay - (sleep-for prescript-delay))) - (if password - (setq liece-ask-for-password nil - liece-password password)) - (if (and (memq type '(rlogin telnet)) relay) - (setq liece-tcp-relay-host relay)) - (setq liece-tmp-server-name host);; temporary - (liece-message (_ "Connecting to IRC server %s...") host) - (cond - ((null host) - (setq liece-status-message-string - (_ "IRC server is not specified."))) - ((liece-open-server-internal host service type) - (setq liece-after-registration nil) - (liece-maybe-poll) - (setq status (liece-wait-for-response "^:[^ ]+ [4P][5O][1N][ G]")) - (if (null status) - (progn - (setq liece-status-message-string - (format (_ "Connection to %s timed out") host)) - ;; We have to close connection here, since the function - ;; `liece-server-opened' may return incorrect status. - (liece-close-server-internal)) - (setq liece-after-registration t) - (set-process-sentinel liece-server-process 'liece-sentinel) - (set-process-filter liece-server-process 'liece-filter) - (if (or liece-ask-for-password liece-reconnect-with-password) - (let ((passwd-echo ?*) password) - (setq password (read-passwd (_ "Server Password: "))) - (or (string= password "") - (setq liece-password password)))) - (if liece-password - (liece-send "PASS %s" liece-password)) - (setq liece-reconnect-with-password nil) - (liece-send "USER %s * * :%s" - (or (user-real-login-name) "Nobody") - (if (and liece-name (not (string= liece-name ""))) - liece-name - "No Name")) - (or liece-real-nickname - (setq liece-real-nickname liece-nickname)) + (liece-server-keyword-bind host + (when prescript + (if (fboundp prescript) + (funcall prescript) + (call-process shell-file-name nil nil nil + shell-command-switch prescript)) + (when prescript-delay + (sleep-for prescript-delay))) + (if password + (setq liece-ask-for-password nil + liece-password password)) + (if (and (memq type '(rlogin telnet)) relay) + (setq liece-tcp-relay-host relay)) + (setq liece-tmp-server-name host) + (liece-open-server-internal host service type) + (setq liece-after-registration nil) + (liece-maybe-poll) + (if (null (liece-wait-for-response "^:[^ ]+ [4P][5O][1N][ G]")) + (progn + ;; We have to close connection here, since the function + ;; `liece-server-opened' may return incorrect status. + (liece-close-server-internal) + (error (_ "Connection to %s timed out") host)) + (set-process-sentinel liece-server-process 'liece-sentinel) + (set-process-filter liece-server-process 'liece-filter) + (if (or liece-ask-for-password liece-reconnect-with-password) + (let ((passwd-echo ?*) password) + (setq password (read-passwd (_ "Server Password: "))) + (or (string= password "") + (setq liece-password password)))) + (if liece-password + (liece-send "PASS %s" liece-password)) + (setq liece-reconnect-with-password nil) + (liece-send "USER %s * * :%s" + (or (user-real-login-name) "Nobody") + (if (and liece-name (not (string= liece-name ""))) + liece-name + "No Name")) + (liece-send "NICK %s" liece-nickname) + ;; We have to set `liece-real-nickname' here because IRC server doesn't + ;; notify the real nickname to the user. + (or liece-real-nickname (setq liece-real-nickname - (truncate-string liece-real-nickname liece-nick-max-length) - liece-nickname-last liece-real-nickname - liece-nick-accepted 'sent - liece-after-registration t) - (liece-send "NICK %s" liece-real-nickname))))) - status)) + (truncate-string liece-nickname liece-nick-max-length))) + (setq liece-nickname-last liece-real-nickname + liece-nick-accepted 'sent + liece-after-registration t)))) (defun liece-open-server-internal (host &optional service type) "Open connection to chat server on HOST by SERVICE (default is irc). @@ -596,7 +568,8 @@ If already connected, just pop up the windows." (liece-get-buffer-create liece-command-buffer)) (unless (eq major-mode 'liece-command-mode) (liece-command-mode)) - (liece-start-server confirm)) + (unless (liece-server-opened) + (liece-start-server confirm))) (if (not (liece-server-opened)) (liece-command-quit) ;; IRC server is successfully open. -- 1.7.10.4