(defun* liece-handle-mode-message (prefix rest)
(if (liece-handle-check-changes-ignored)
(return-from liece-handle-mode-message))
- (let ((chnl " ") (str "") mflag mflags marg margs val md chnlp)
- (or (and (string-match "\\([^ ]*\\) +:?" rest)
- (setq chnl (match-string 1 rest)
- str (substring rest (match-end 0))
- chnlp (liece-channel-p chnl)
- str (if (= (aref str (1- (length str))) ? )
- (substring str 0 -1) str)
- chnl (liece-channel-virtual chnl)))
- (and (string-match " +:" rest)
- (setq str (substring rest (match-end 0))))
- (return-from liece-handle-mode-message))
-
+ (let (mflgs margs val chnl mode chnlp)
+ (if (string-match "\\([^ ]*\\) *:?" rest)
+ (progn
+ (setq chnl (match-string 1 rest)
+ mode (substring rest (match-end 0)))
+ (if (liece-channel-p chnl)
+ (setq chnl (liece-channel-virtual chnl) chnlp t))
+ (if (string-match " *$" mode)
+ (setq mode (substring mode 0 (match-beginning 0)))))
+ (return-from liece-handle-mode-message))
;; parse modes
- (when (string-match "\\([^ ]*\\) +" str)
- (setq mflag (match-string 1 str)
- marg (substring str (match-end 0))
- mflags (liece-string-to-list mflag))
- (while (string-match "^\\([^ ]*\\) +" marg)
- (setq margs (cons (match-string 1 marg) margs)
- marg (substring marg (match-end 0))))
- (or (string= marg "") (setq margs (cons marg margs)))
- (while (setq md (pop mflags))
- (cond ((eq ?- md) (setq val nil))
- ((eq ?+ md) (setq val t))
- ((eq ?o md) (liece-channel-set-operator chnl (pop margs) val))
- ((eq ?v md) (liece-channel-set-voice chnl (pop margs) val))
- ((eq ?b md) (liece-channel-set-ban chnl (pop margs) val))
- ((eq ?e md) (liece-channel-set-exception chnl (pop margs) val))
- ((eq ?I md) (liece-channel-set-invite chnl (pop margs) val))
- (chnlp (liece-channel-set-mode val md chnl))
- (t (liece-nick-set-mode val md chnl)))))
-
+ (when (string-match "\\([^ ]*\\) *" mode)
+ (setq mflgs (liece-string-to-list (match-string 1 mode))
+ margs (delete "" (split-string
+ (substring mode (match-end 0))
+ "[ ]+")))
+ (while mflgs
+ (cond ((eq ?- (car mflgs)) (setq val nil))
+ ((eq ?+ (car mflgs)) (setq val t))
+ ((eq ?o (car mflgs))
+ (liece-channel-set-operator chnl (car margs) val)
+ (setq margs (cdr margs)))
+ ((eq ?v (car mflgs))
+ (liece-channel-set-voice chnl (car margs) val)
+ (setq margs (cdr margs)))
+ ((eq ?b (car mflgs))
+ (liece-channel-set-ban chnl (car margs) val)
+ (setq margs (cdr margs)))
+ ((eq ?e (car mflgs))
+ (liece-channel-set-exception chnl (car margs) val)
+ (setq margs (cdr margs)))
+ ((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))
+ (t (liece-nick-set-mode val (car mflgs) chnl)))
+ (setq mflgs (cdr mflgs))))
(liece-set-channel-indicator)
(cond
(liece-compress-changes
(regexp-quote liece-change-prefix)
(regexp-quote chnl) (regexp-quote prefix)))
(default (format (_ "%sNew mode for %s set by %s: %s\n")
- liece-change-prefix chnl prefix str)))
+ liece-change-prefix chnl prefix mode)))
(liece-replace (liece-pick-buffer chnl)
- match default text (concat ", " str "\n"))
+ match default text (concat ", " mode "\n"))
(liece-replace (if (and liece-current-channel
(liece-channel-equal
chnl liece-current-channel))
liece-D-buffer
(append liece-D-buffer liece-O-buffer))
- match default text (concat ", " str "\n"))))
+ match default text (concat ", " mode "\n"))))
(t
(liece-insert-change (liece-pick-buffer chnl)
(format (_ "New mode for %s set by %s: %s\n")
- chnl prefix str))
+ chnl prefix mode))
(liece-insert-change (if (and liece-current-channel
(liece-channel-equal
chnl liece-current-channel))
liece-D-buffer
(append liece-D-buffer liece-O-buffer))
(format (_ "New mode for %s set by %s: %s\n")
- chnl prefix str))))))
+ chnl prefix mode))))))
(defun* liece-handle-kick-message (prefix rest)
(if (/= 3 (length (setq rest (liece-split-line rest))))
(defmacro string-join (strlst &optional del)
`(mapconcat #'identity ,strlst ,del))
-(static-if (subr-fboundp 'compare-strings)
- (defmacro string-equal-ignore-case (s1 s2)
- `(eq t (compare-strings ,s1 0 nil ,s2 0 nil 'ignore-case)))
- (defmacro string-equal-ignore-case (s1 s2)
- `(string-equal (upcase ,s1) (upcase ,s2))))
-
-(static-if (fboundp 'member-ignore-case)
- (defalias 'string-list-member-ignore-case
- 'member-ignore-case)
- (defsubst string-list-member-ignore-case (thing list)
- "Returns t if thing is member of list, not funcallable"
- (member-if
- (lambda (item)
- (and (stringp item) (string-equal-ignore-case thing item)))
- list)))
+(defmacro string-equal-ignore-case (s1 s2)
+ `(string-equal (upcase ,s1) (upcase ,s2)))
+
+(defsubst string-list-member-ignore-case (thing list)
+ "Returns t if thing is member of list, not funcallable"
+ (member-if
+ (lambda (item)
+ (and (stringp item) (string-equal-ignore-case thing item)))
+ list))
(defsubst string-list-remove-ignore-case (thing list)
(let ((element (string-list-member-ignore-case thing list)))