;;; Code:
(eval-when-compile (require 'liece-inlines))
+(eval-when-compile (require 'liece-misc))
(eval-when-compile (require 'liece-clfns))
;;; Reader conventions
(defun liece-channel-p (chnl)
- (string-match
- (eval-when-compile
- (concat "^" liece-channel-regexp))
- chnl))
+ (string-match (concat "^" liece-channel-regexp) chnl))
(defun liece-channel-modeless-p (chnl)
- (string-match
- (eval-when-compile
- (concat "^" liece-channel-modeless-regexp))
- chnl))
+ (string-match (concat "^" liece-channel-modeless-regexp) chnl))
-(defalias 'liece-channel-equal 'string-equal-ignore-case)
+(defun liece-channel-equal (c1 c2)
+ (string-equal-ignore-case c1 c2))
(defun liece-channel-member (chnl chnls)
"Return non-nil if CHNL is member of CHNLS."
(setq liece-channel-buffer-mode (not liece-channel-buffer-mode)))
(liece-configure-windows))
-(defmacro liece-channel-buffer-create (chnl)
+(defun liece-channel-buffer-create (chnl)
"Create channel buffer of CHNL."
- `(with-current-buffer
- (liece-get-buffer-create (format liece-channel-buffer-format ,chnl))
+ (with-current-buffer
+ (liece-get-buffer-create (format liece-channel-buffer-format chnl))
(let (buffer-read-only)
(liece-insert-info (current-buffer)
(concat (funcall liece-format-time-function
" Created.\n")))
(unless (eq major-mode 'liece-channel-mode)
(liece-channel-mode))
- (set-alist 'liece-channel-buffer-alist ,chnl (current-buffer))
+ (set-alist 'liece-channel-buffer-alist chnl (current-buffer))
(current-buffer)))
(defun liece-channel-join-internal (item chnls &optional hints)
liece-nick-buffer nbuf))
(liece-channel-change)))
+(defmacro liece-channel-switch-to-last (chnls)
+ `(let ((chnl (liece-channel-last ,chnls)))
+ (if chnl
+ (liece-switch-to-channel chnl))
+ (liece-channel-change)))
+
(defun liece-channel-part-internal (item chnls &optional hints)
(if hints
(mapcar
(defun liece-channel-last (chnls)
(car (last (delq nil (copy-sequence chnls)))))
-(defmacro liece-channel-switch-to-last (chnls)
- `(let ((chnl (liece-channel-last ,chnls)))
- (if chnl
- (liece-switch-to-channel chnl))
- (liece-channel-change)))
-
(defun liece-channel-change ()
(let ((chnls (if (eq liece-command-buffer-mode 'chat)
liece-current-chat-partners
(eval-when-compile
(autoload '_ "liece-intl" nil nil 'macro))
+(defmacro liece-insert-change (buffer msg)
+ `(liece-insert ,buffer (concat liece-change-prefix ,msg)))
+
+(defmacro liece-insert-notice (buffer msg)
+ `(liece-insert ,buffer (concat liece-notice-prefix ,msg)))
+
+(defmacro liece-insert-broadcast (buffer msg)
+ `(liece-insert ,buffer (concat liece-broadcast-prefix ,msg)))
+
+(defmacro liece-insert-wallops (buffer msg)
+ `(liece-insert ,buffer (concat liece-wallops-prefix ,msg)))
+
+(defmacro liece-insert-error (buffer msg)
+ `(liece-insert ,buffer (concat liece-error-prefix ,msg)))
+
+(defmacro liece-insert-info (buffer msg)
+ `(liece-insert ,buffer (concat liece-info-prefix ,msg)))
+
+(defmacro liece-insert-timestamp (buffer msg)
+ `(liece-insert ,buffer (concat liece-timestamp-prefix ,msg)))
+
+(defmacro liece-insert-dcc (buffer msg)
+ `(liece-insert ,buffer (concat liece-dcc-prefix ,msg)))
+
+(defmacro liece-insert-client (buffer msg)
+ `(liece-insert ,buffer (concat liece-client-prefix ,msg)))
+
(defun liece-toggle-command-buffer-mode (&optional mode)
"Toggle command buffer MODE."
(let ((mode
liece-freeze-indicator (if liece-freeze "F" "-"))
(force-mode-line-update)))
-(defmacro liece-frozen (buffer)
- (list 'with-current-buffer buffer 'liece-freeze))
+(defun liece-frozen (buffer)
+ (with-current-buffer buffer liece-freeze))
(defun liece-own-freeze (buffer &optional arg)
(with-current-buffer buffer
liece-own-freeze-indicator (if liece-own-freeze "M" "-"))
(force-mode-line-update)))
-(defmacro liece-own-frozen (buffer)
- (list 'with-current-buffer buffer 'liece-own-freeze))
+(defun liece-own-frozen (buffer)
+ (with-current-buffer buffer liece-own-freeze))
(defun liece-ignore-this-p (nick user-at-host)
;; Remove entries which are expired.
(product-name (product-find 'liece-version))
(format ,@message)))
-(defmacro liece-insert-change (buffer msg)
- `(liece-insert ,buffer (concat liece-change-prefix ,msg)))
-
-(defmacro liece-insert-notice (buffer msg)
- `(liece-insert ,buffer (concat liece-notice-prefix ,msg)))
-
-(defmacro liece-insert-broadcast (buffer msg)
- `(liece-insert ,buffer (concat liece-broadcast-prefix ,msg)))
-
-(defmacro liece-insert-wallops (buffer msg)
- `(liece-insert ,buffer (concat liece-wallops-prefix ,msg)))
-
-(defmacro liece-insert-error (buffer msg)
- `(liece-insert ,buffer (concat liece-error-prefix ,msg)))
-
-(defmacro liece-insert-info (buffer msg)
- `(liece-insert ,buffer (concat liece-info-prefix ,msg)))
-
-(defmacro liece-insert-timestamp (buffer msg)
- `(liece-insert ,buffer (concat liece-timestamp-prefix ,msg)))
-
-(defmacro liece-insert-dcc (buffer msg)
- `(liece-insert ,buffer (concat liece-dcc-prefix ,msg)))
-
-(defmacro liece-insert-client (buffer msg)
- `(liece-insert ,buffer (concat liece-client-prefix ,msg)))
-
-(defmacro liece-own-message (message)
- `(if (eq liece-command-buffer-mode 'channel)
- (liece-own-channel-message ,message)
- (liece-own-channel-message ,message)))
-
(defmacro liece-own-channel-message (message &optional chnl)
`(let* ((chnl (or ,chnl (liece-current-channel)))
(liece-message-target chnl)
(liece-message-direction 'outgoing))
(liece-display-message ,message)))
+(defmacro liece-own-message (message)
+ `(if (eq liece-command-buffer-mode 'channel)
+ (liece-own-channel-message ,message)
+ (liece-own-channel-message ,message)))
+
+(defvar liece-idle-point nil "Timestamp of last idle reset.")
+
+(defmacro liece-reset-idle ()
+ "Reset idle counter and return last idle."
+ '(prog1 (liece-idle) (setq liece-idle-point (current-time))))
+
+(defmacro liece-idle ()
+ "How long has liece been idle."
+ '(if liece-idle-point
+ (liece-time-difference liece-idle-point (current-time))
+ 9999999))
+
+(defmacro liece-ping-if-idle (&optional limit)
+ `(if (<= (liece-idle) (or ,limit 120))
+ nil
+ (liece-command-ping)
+ t))
+
(defmacro liece-convert-received-input (input)
"Convert input before it is processed"
`(let ((conv-list liece-receive-convert-list)
(defmacro liece-insert-time-string ()
'(insert (substring (current-time-string) 11 16) " "))
-(defvar liece-idle-point nil "Timestamp of last idle reset.")
-
-(defmacro liece-reset-idle ()
- "Reset idle counter and return last idle."
- '(prog1 (liece-idle) (setq liece-idle-point (current-time))))
-
-(defmacro liece-idle ()
- "How long has liece been idle."
- '(if liece-idle-point
- (liece-time-difference liece-idle-point (current-time))
- 9999999))
-
-(defmacro liece-ping-if-idle (&optional limit)
- `(if (<= (liece-idle) (or ,limit 120))
- nil
- (liece-command-ping)
- t))
-
(defmacro liece-maybe-poll ()
'(liece-send "PING %s" (system-name)))
(setq time (current-time)))
(format "%04x%04x" (car time) (cadr time)))
-(defmacro liece-hex-timestamp-valid (timestamp limit)
- "Is TIMESTAMP valid within LIMIT?"
- `(let (t1 t2 diff (timestamp ,timestamp))
- (if (not (and (stringp timestamp)
- (string-match
- "^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$" timestamp)))
- nil
- (setq t1 (liece-hex-string-to-integer (substring timestamp 0 4))
- t2 (liece-hex-string-to-integer (substring timestamp 4 8))
- diff (liece-time-difference
- (list t1 t2 0) (current-time)))
- (or (>= ,limit 0)
- (and (< diff ,limit) (> diff (- 0 ,limit)))))))
-
(defmacro liece-hex-char-to-integer (character)
"Convert single hex digit CHARACTER to integer."
`(if (and (>= ,character ?0) (<= ,character ?9))
(setq hex-string (substring hex-string 1)))
hex-num))
+(defmacro liece-hex-timestamp-valid (timestamp limit)
+ "Is TIMESTAMP valid within LIMIT?"
+ `(let (t1 t2 diff (timestamp ,timestamp))
+ (if (not (and (stringp timestamp)
+ (string-match
+ "^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$" timestamp)))
+ nil
+ (setq t1 (liece-hex-string-to-integer (substring timestamp 0 4))
+ t2 (liece-hex-string-to-integer (substring timestamp 4 8))
+ diff (liece-time-difference
+ (list t1 t2 0) (current-time)))
+ (or (>= ,limit 0)
+ (and (< diff ,limit) (> diff (- 0 ,limit)))))))
+
(defmacro liece-remove-properties-region (start end)
(unless (fboundp 'make-extent)
`(save-excursion