From: ueno Date: Mon, 26 Aug 2002 23:59:07 +0000 (+0000) Subject: Synch up with liece-1_4. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f52851f48c1f8ee106952f91edda4ef22cbf9a7;p=elisp%2Fliece.git Synch up with liece-1_4. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5ccde7a..4db9184 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,37 @@ +2002-08-27 Daiki Ueno + + * liece-commands.el (liece-command-join-channel): User + liece-nick-get-joined-channels. + + * liece-channel.el (liece-channel-set-topic): Define as function. + (liece-channel-add-mode): Ditto. + (liece-channel-remove-mode): Ditto. + (liece-channel-set-mode): Ditto. + (liece-channel-add-ban): Ditto. + (liece-channel-remove-ban): Ditto. + (liece-channel-set-ban): Ditto. + (liece-channel-add-exception): Ditto. + (liece-channel-remove-exception): Ditto. + (liece-channel-set-exception): Ditto. + (liece-channel-add-invite): Ditto. + (liece-channel-remove-invite): Ditto. + (liece-channel-set-invite): Ditto. + * liece-nick.el (liece-nick-mark-as-part): Replace + liece-nick-{mark,unmark}-as-apart. + (liece-nick-get-modes): Define as function. + (liece-nick-add-mode): Ditto. + (liece-nick-remove-mode): Ditto. + (liece-nick-set-mode): Ditto. + * liece-handle.el (liece-handle-mode-message): Follow the changes + of arglists of liece-channel-set-mode and liece-nick-set-mode. + + * liece.el: Fix typo. + * liece-misc.el (liece-current-nickname): Define as function. + (liece-current-channel): Ditto. + (liece-current-channels): Ditto. + (liece-current-chat-partner): Ditto. + (liece-current-chat-partners): Ditto. + 2002-08-26 Daiki Ueno * liece-handle.el (liece-handle-mode-message): Care diff --git a/lisp/liece-channel.el b/lisp/liece-channel.el index b202fc4..8c132a2 100644 --- a/lisp/liece-channel.el +++ b/lisp/liece-channel.el @@ -96,172 +96,189 @@ (defun liece-channel-get-modes (&optional chnl) "Return CHNL or current channels's mode." - (get (intern (or chnl liece-current-channel) liece-obarray) - 'mode)) + (get (intern (or chnl liece-current-channel) liece-obarray) 'mode)) (defun liece-channel-get-bans (&optional chnl) "Return CHNL or current channels's ban list." - (get (intern (or chnl liece-current-channel) liece-obarray) - 'ban)) + (get (intern (or chnl liece-current-channel) liece-obarray) 'ban)) (defun liece-channel-get-invites (&optional chnl) "Return CHNL or current channels's invite list." - (get (intern (or chnl liece-current-channel) liece-obarray) - 'invite)) + (get (intern (or chnl liece-current-channel) liece-obarray) 'invite)) (defun liece-channel-get-exceptions (&optional chnl) "Return CHNL or current channels's exception list." - (get (intern (or chnl liece-current-channel) liece-obarray) - 'exception)) + (get (intern (or chnl liece-current-channel) liece-obarray) 'exception)) -;;; Internal functions -(defun liece-channel-remove (chnl chnls) - "Remove CHNL from CHNLS." +;;; Channel status functions +(defun liece-channel-remove (channel channels) + "Remove CHANNEL from CHANNELS." (remove-if (lambda (item) - (and (stringp item) (liece-channel-equal chnl item))) - chnls)) + (and (stringp item) (liece-channel-equal channel item))) + channels)) -(defun liece-channel-delete (chnl chnls) - "Delete CHNL from CHNLS." +(defun liece-channel-delete (channel channels) + "Delete CHANNEL from CHANNELS." (delete-if (lambda (item) - (and (stringp item) (liece-channel-equal chnl item))) - chnls)) - -(defmacro liece-channel-set-topic (topic &optional chnl) - "Set CHNL or current channels's topic." - `(put (intern (or ,chnl liece-current-channel) liece-obarray) - 'topic ,topic)) - -(defmacro liece-channel-add-mode (mode &optional chnl) - "Add MODE as char to CHNL." - `(let ((modes (liece-string-to-list (or (liece-channel-get-modes ,chnl) - "")))) - (or (memq ,mode modes) - (push ,mode modes)) - (put (intern (or ,chnl liece-current-channel) liece-obarray) - 'mode (mapconcat #'char-to-string modes "")))) - -(defmacro liece-channel-remove-mode (mode &optional chnl) - "Remove MODE as char to CHNL." - `(let ((modes (liece-string-to-list (or (liece-channel-get-modes ,chnl) - "")))) - (delq ,mode modes) - (put (intern (or ,chnl liece-current-channel) liece-obarray) - 'mode (mapconcat #'char-to-string modes "")))) - -(defmacro liece-channel-set-mode (val mode &optional chnl) - "Set character VAL as channel MODE into the CHNL." - `(if val - (liece-channel-add-mode ,mode ,chnl) - (liece-channel-remove-mode ,mode ,chnl))) - -(defmacro liece-channel-add-ban (pattern &optional chnl) - "Add ban PATTERN as char to CHNL." - `(let ((patterns (liece-channel-get-bans ,chnl))) - (or (string-list-member-ignore-case ,pattern patterns) - (push ,pattern patterns)) - (put (intern (or ,chnl liece-current-channel) liece-obarray) - 'ban patterns))) - -(defmacro liece-channel-remove-ban (pattern &optional chnl) - "Remove ban PATTERN as char to CHNL." - `(let ((patterns (remove-if (lambda (elm) (string-equal ,pattern elm)) - (liece-channel-get-bans ,chnl)))) - (put (intern (or ,chnl liece-current-channel) liece-obarray) - 'ban patterns))) - -(defmacro liece-channel-set-ban (chnl pattern val) - "Set ban PATTERN as char to CHNL." - `(if val - (liece-channel-add-ban ,pattern ,chnl) - (liece-channel-remove-ban ,pattern ,chnl))) - -(defmacro liece-channel-add-exception (pattern &optional chnl) - "Add exception PATTERN as char to CHNL." - `(let ((patterns (liece-channel-get-exceptions ,chnl))) - (or (string-list-member-ignore-case ,pattern patterns) - (push ,pattern patterns)) - (put (intern (or ,chnl liece-current-channel) liece-obarray) - 'exception patterns))) - -(defmacro liece-channel-remove-exception (pattern &optional chnl) - "Remove exception PATTERN as char to CHNL." - `(let ((patterns (remove-if (lambda (elm) (string-equal ,pattern elm)) - (liece-channel-get-exceptions ,chnl)))) - (put (intern (or ,chnl liece-current-channel) liece-obarray) - 'exception patterns))) - -(defmacro liece-channel-set-exception (chnl pattern val) - "Set exception PATTERN as char to CHNL." - `(if val - (liece-channel-add-exception ,pattern ,chnl) - (liece-channel-remove-exception ,pattern ,chnl))) - -(defmacro liece-channel-add-invite (pattern &optional chnl) - "Add invite PATTERN as char to CHNL." - `(let ((patterns (liece-channel-get-invites ,chnl))) - (or (string-list-member-ignore-case ,pattern patterns) - (push ,pattern patterns)) - (put (intern (or ,chnl liece-current-channel) liece-obarray) - 'invite patterns))) - -(defmacro liece-channel-remove-invite (pattern &optional chnl) - "Remove invite PATTERN as char to CHNL." - `(let ((patterns (remove-if (lambda (elm) (string-equal ,pattern elm)) - (liece-channel-get-invites ,chnl)))) - (put (intern (or ,chnl liece-current-channel) liece-obarray) - 'invite patterns))) - -(defmacro liece-channel-set-invite (chnl pattern val) - "Set invite PATTERN as char to CHNL." - `(if val - (liece-channel-add-invite ,pattern ,chnl) - (liece-channel-remove-invite ,pattern ,chnl))) + (and (stringp item) (liece-channel-equal channel item))) + channels)) + +(defun liece-channel-set-topic (topic &optional channel) + "Set CHANNEL's topic." + (put (intern (or channel liece-current-channel) liece-obarray) + 'topic topic)) + +(defun liece-channel-add-mode (mode &optional channel) + "Add MODE to CHANNEL. +MODE is a string splitted into characters one by one." + (let ((modes + (liece-string-to-list + (or (liece-channel-get-modes channel) + "")))) + (or (memq mode modes) + (push mode modes)) + (put (intern (or channel liece-current-channel) liece-obarray) + 'mode (mapconcat #'char-to-string modes "")))) + +(defun liece-channel-remove-mode (mode &optional channel) + "Remove MODE from CHANNEL. +MODE is a string splitted into characters one by one." + (let ((modes + (liece-string-to-list + (or (liece-channel-get-modes channel) + "")))) + (delq mode modes) + (put (intern (or channel liece-current-channel) liece-obarray) + 'mode (mapconcat #'char-to-string modes "")))) + +(defun liece-channel-set-mode (channel mode flag) + "Add or remove channel MODE of CHANNEL. +MODE is a string splitted into characters one by one. +If FLAG is non-nil, given modes are added to the channel. +Otherwise they are removed from the channel." + (if flag + (liece-channel-add-mode mode channel) + (liece-channel-remove-mode mode channel))) + +(defun liece-channel-add-ban (pattern &optional channel) + "Add ban PATTERN to CHANNEL." + (let ((patterns (liece-channel-get-bans channel))) + (or (string-list-member-ignore-case pattern patterns) + (push pattern patterns)) + (put (intern (or channel liece-current-channel) liece-obarray) + 'ban patterns))) + +(defun liece-channel-remove-ban (pattern &optional channel) + "Remove ban PATTERN from CHANNEL." + (let ((patterns + (remove-if + (lambda (elm) (string-equal pattern elm)) + (liece-channel-get-bans channel)))) + (put (intern (or channel liece-current-channel) liece-obarray) + 'ban patterns))) + +(defun liece-channel-set-ban (channel pattern flag) + "Add or remove ban PATTERN to CHANNEL. +If FLAG is non-nil, given ban patterns are added to the channel. +Otherwise they are removed from the channel." + (if flag + (liece-channel-add-ban pattern channel) + (liece-channel-remove-ban pattern channel))) + +(defun liece-channel-add-exception (pattern &optional channel) + "Add exception PATTERN to CHANNEL." + (let ((patterns (liece-channel-get-exceptions channel))) + (or (string-list-member-ignore-case pattern patterns) + (push pattern patterns)) + (put (intern (or channel liece-current-channel) liece-obarray) + 'exception patterns))) + +(defun liece-channel-remove-exception (pattern &optional channel) + "Remove exception PATTERN from CHANNEL." + (let ((patterns + (remove-if + (lambda (elm) (string-equal pattern elm)) + (liece-channel-get-exceptions channel)))) + (put (intern (or channel liece-current-channel) liece-obarray) + 'exception patterns))) + +(defun liece-channel-set-exception (channel pattern flag) + "Add or remove exception PATTERN to CHANNEL. +If FLAG is non-nil, given exception patterns are added to the channel. +Otherwise they are removed from the channel." + (if flag + (liece-channel-add-exception pattern channel) + (liece-channel-remove-exception pattern channel))) + +(defun liece-channel-add-invite (pattern &optional channel) + "Add invite PATTERN to CHANNEL." + (let ((patterns (liece-channel-get-invites channel))) + (or (string-list-member-ignore-case pattern patterns) + (push pattern patterns)) + (put (intern (or channel liece-current-channel) liece-obarray) + 'invite patterns))) + +(defun liece-channel-remove-invite (pattern &optional channel) + "Remove invite PATTERN from CHANNEL." + (let ((patterns + (remove-if + (lambda (elm) (string-equal pattern elm)) + (liece-channel-get-invites channel)))) + (put (intern (or channel liece-current-channel) liece-obarray) + 'invite patterns))) + +(defun liece-channel-set-invite (channel pattern flag) + "Add or remove invite PATTERN to CHANNEL. +If FLAG is non-nil, given invite patterns are added to the channel. +Otherwise they are removed from the channel." + (if flag + (liece-channel-add-invite pattern channel) + (liece-channel-remove-invite pattern channel))) -(defun liece-channel-virtual (chnl) +(defun liece-channel-virtual (channel) "Convert channel name into internal representation. -\(For example if CHNL is a string \"#...:*\", it will be converted into +\(For example if CHANNEL is a string \"#...:*\", it will be converted into \"%...\"\)" (let ((mapping liece-channel-conversion-map) match) (while mapping - (if (string-equal-ignore-case (caar mapping) chnl) + (if (string-equal-ignore-case (caar mapping) channel) (setq match (cdar mapping))) (pop mapping)) (if match match (save-match-data (cond - ((and (string-match "^[#+]\\(.*\\):\\(.*\\)$" chnl) - (string= (match-string 2 chnl) - liece-channel-conversion-default-mask)) - (if (eq ?+ (aref chnl 0)) - (concat "-" (match-string 1 chnl)) - (concat "%" (match-string 1 chnl)))) - ((string= "" chnl) chnl) -; ((eq ?! (aref chnl 0)) -; (concat "!" (substring chnl (1+ liece-channel-id-length)))) - (t chnl)))))) - -(defun liece-channel-real (chnl) + ((string-match + (format "^[#+]\\(.*\\):%s$" + (regexp-quote liece-channel-conversion-default-mask)) + channel) + (if (eq ?+ (aref channel 0)) + (concat "-" (match-string 1 channel)) + (concat "%" (match-string 1 channel)))) +;;; ((and (not (equal channel "")) (eq ?! (aref channel 0))) +;;; (concat "!" (substring channel (1+ liece-channel-id-length)))) + (t channel)))))) + +(defun liece-channel-real (channel) "Convert channel name into external representation. -\(For example if CHNL is a string \"%...\", it will be converted into +\(For example if CHANNEL is a string \"%...\", it will be converted into \"#...:*\"\)" (let ((mapping liece-channel-conversion-map) match) (while mapping - (if (string-equal-ignore-case (cdar mapping) chnl) + (if (string-equal-ignore-case (cdar mapping) channel) (setq match (caar mapping))) (pop mapping)) (cond (match match) - ((eq ?% (aref chnl 0)) - (concat "#" (substring chnl 1) ":" + ((eq ?% (aref channel 0)) + (concat "#" (substring channel 1) ":" liece-channel-conversion-default-mask)) - ((eq ?- (aref chnl 0)) - (concat "+" (substring chnl 1) ":" + ((eq ?- (aref channel 0)) + (concat "+" (substring channel 1) ":" liece-channel-conversion-default-mask)) - (t chnl)))) + (t channel)))) ;;;###liece-autoload (defun liece-command-toggle-channel-buffer-mode () diff --git a/lisp/liece-commands.el b/lisp/liece-commands.el index d85c11f..2d18848 100644 --- a/lisp/liece-commands.el +++ b/lisp/liece-commands.el @@ -185,7 +185,7 @@ Optional argument NO-CONS specifies timestamp format is cons cell." (setq nick (pop nicks))) (when nicks (setq join-channel-var - (or (car (get (intern (car nick) liece-obarray) 'chnl)) + (or (car (liece-nick-get-joined-channels (car nick))) join-channel-var))) (if (liece-channel-member join-channel-var liece-current-channels) (progn diff --git a/lisp/liece-handle.el b/lisp/liece-handle.el index 0befca6..0f66ea6 100644 --- a/lisp/liece-handle.el +++ b/lisp/liece-handle.el @@ -299,7 +299,7 @@ ((eq ?I (car mflgs)) (liece-channel-set-invite chnl (car margs) val) (setq margs (cdr margs))) - (chnlp (liece-channel-set-mode val (car mflgs) chnl)) + (chnlp (liece-channel-set-mode chnl (car mflgs) val)) (t (liece-nick-set-mode val (car mflgs) chnl))) (setq mflgs (cdr mflgs)))) (liece-set-channel-indicator) diff --git a/lisp/liece-misc.el b/lisp/liece-misc.el index fcf8d6b..de2de52 100644 --- a/lisp/liece-misc.el +++ b/lisp/liece-misc.el @@ -66,26 +66,26 @@ (defmacro liece-insert-client (buffer msg) `(liece-insert ,buffer (concat liece-client-prefix ,msg))) -(defmacro liece-current-nickname () - "Our current nickname." - 'liece-real-nickname) - -(defmacro liece-current-channel () - "Our current channel." - 'liece-current-channel) - -(defmacro liece-current-channels () - "Our current channels." - 'liece-current-channels) - -(defmacro liece-current-chat-partner () - "Our current chat partner." - 'liece-current-chat-partner) - -(defmacro liece-current-chat-partners () - "Our current chat partners." - 'liece-current-chat-partners) - +(defun liece-current-nickname () + "Return the current nickname." + liece-real-nickname) + +(defun liece-current-channel () + "Return the current channel." + liece-current-channel) + +(defun liece-current-channels () + "Return the current channels." + liece-current-channels) + +(defun liece-current-chat-partner () + "Return the current chat partner." + liece-current-chat-partner) + +(defun liece-current-chat-partners () + "Return the current chat partners." + liece-current-chat-partners) + (defun liece-toggle-command-buffer-mode (&optional mode) "Toggle command buffer MODE." (let ((mode diff --git a/lisp/liece-nick.el b/lisp/liece-nick.el index 86e0c8a..bcee708 100644 --- a/lisp/liece-nick.el +++ b/lisp/liece-nick.el @@ -59,52 +59,57 @@ :type 'function :group 'liece-vars) -;;; @ internal access methods -;;; -(defmacro liece-nick-get-joined-channels (nick) +;;; Nick status functions +(defun liece-nick-get-joined-channels (nick) "Return channels as list NICK is joined." - `(get (intern ,nick liece-obarray) 'chnl)) + (get (intern (or nick liece-real-nickname) liece-obarray) 'join)) -(defmacro liece-nick-get-user-at-host (nick) +(defun liece-nick-get-user-at-host (nick) "Return user-at-host as string NICK is joined." - `(get (intern ,nick liece-obarray) 'user-at-host)) + (get (intern (or nick liece-real-nickname) liece-obarray) 'user-at-host)) -(defmacro liece-nick-set-user-at-host (nick uah) +(defun liece-nick-set-user-at-host (nick user-at-host) "Set user at host as string NICK is joined." - `(put (intern ,nick liece-obarray) 'user-at-host ,uah)) - -(defmacro liece-nick-mark-as-apart (nick) - "Mark NICK is temporary apart." - `(put (intern ,nick liece-obarray) 'part t)) + (put (intern (or nick liece-real-nickname) liece-obarray) + 'user-at-host user-at-host)) -(defmacro liece-nick-unmark-as-apart (nick) +(defun liece-nick-mark-as-part (part &optional nick) "Mark NICK is temporary apart." - `(put (intern ,nick liece-obarray) 'part nil)) + (put (intern (or nick liece-real-nickname) liece-obarray) 'part part)) -(defmacro liece-nick-get-modes (nick) +(defun liece-nick-get-modes (&optional nick) "Return modes as string NICK is joined." - `(get (intern ,nick liece-obarray) 'mode)) - -(defmacro liece-nick-add-mode (mode &optional nick) - "Add MODE as char to NICK." - `(let* ((n (intern ,nick liece-obarray)) - (modes (liece-string-to-list (or (get n 'mode) "")))) - (put n 'mode (mapconcat #'char-to-string - (or (memq ,mode modes) - (cons ,mode modes)) "")))) - -(defmacro liece-nick-remove-mode (mode &optional nick) - "Remove MODE as char to NICK." - `(let* ((n (intern ,nick liece-obarray)) - (modes (liece-string-to-list (or (get n 'mode) "")))) - (delq ,mode modes) - (put n 'mode (mapconcat #'char-to-string modes "")))) - -(defmacro liece-nick-set-mode (val mode &optional nick) - "Set MODE as char to CHNL." - `(if ,val - (liece-nick-add-mode ,mode ,nick) - (liece-nick-remove-mode ,mode ,nick))) + (get (intern (or nick liece-real-nickname) liece-obarray) 'mode)) + +(defun liece-nick-add-mode (mode &optional nick) + "Add MODE as char to NICK. +MODE is a string splitted into characters one by one." + (let ((modes + (liece-string-to-list + (or (liece-nick-get-modes nick) "")))) + (or (memq mode modes) + (push mode modes)) + (put (intern (or nick liece-real-nickname) liece-obarray) + 'mode (mapconcat #'char-to-string "")))) + +(defun liece-nick-remove-mode (mode &optional nick) + "Remove MODE from NICK. +MODE is a string splitted into characters one by one." + (let ((modes + (liece-string-to-list + (or (liece-nick-get-modes nick) "")))) + (delq mode modes) + (put (intern (or nick liece-real-nickname) liece-obarray) + 'mode (mapconcat #'char-to-string modes "")))) + +(defun liece-nick-set-mode (nick mode toggle) + "Add or remove channel MODE of NICK. +MODE is a string splitted into characters one by one. +If FLAG is non-nil, given modes are added to the user. +Otherwise they are removed from the user." + (if toggle + (liece-nick-add-mode mode nick) + (liece-nick-remove-mode mode nick))) (defmacro liece-nick-strip (nick) `(if (and ,nick (memq (aref ,nick 0) '(?@ ?+ ? ))) @@ -231,8 +236,8 @@ (liece-channel-set-operator ,chnl user t)) ((char-equal flag ?+) (liece-channel-set-voice ,chnl user t))) - (or (string-list-member-ignore-case ,chnl (get u 'chnl)) - (put u 'chnl (cons ,chnl (get u 'chnl)))) + (or (string-list-member-ignore-case ,chnl (get u 'join)) + (put u 'join (cons ,chnl (get u 'join)))) (or (string-list-member-ignore-case user (get c 'nick)) (put c 'nick (cons user (get c 'nick)))))) @@ -242,7 +247,7 @@ (c (intern ,chnl liece-obarray))) (liece-channel-set-operator ,chnl ,user nil) (liece-channel-set-voice ,chnl ,user nil) - (put u 'chnl (string-list-remove-ignore-case ,chnl (get u 'chnl))) + (put u 'join (string-list-remove-ignore-case ,chnl (get u 'join))) (put c 'nick (string-list-remove-ignore-case ,user (get c 'nick))))) ;;;###liece-autoload @@ -269,10 +274,10 @@ ;;;###liece-autoload (defun liece-nick-change (old new) (let* ((old (liece-nick-strip old)) (new (liece-nick-strip new)) - (chnls (get (intern old liece-obarray) 'chnl)) nbuf) + (chnls (get (intern old liece-obarray) 'join)) nbuf) (liece-change-nick-of old new) (if new - (put (intern new liece-obarray) 'chnl chnls)) + (put (intern new liece-obarray) 'join chnls)) (unintern old liece-obarray) (dolist (chnl chnls) (if (null new) diff --git a/lisp/liece.el b/lisp/liece.el index e7f1818..e729a98 100644 --- a/lisp/liece.el +++ b/lisp/liece.el @@ -146,7 +146,6 @@ For efficiency this should be prime. See documentation of intern and "\C-c0" liece-switch-to-channel-no-20)) ;;; Keymap macros. -- borrowed from `gnus-util.el'. - (defmacro liece-local-set-keys (&rest plist) "Set the keys in PLIST in the current keymap." `(liece-define-keys-1 (current-local-map) ',plist))