(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 ()
: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) '(?@ ?+ ? )))
(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))))))
(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
;;;###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)