+2001-10-02 Daiki Ueno <ueno@unixuser.org>
+
+ * liece-compat.el (replace-in-string): Follow a change in XEmacs.
+
+2001-10-02 Daiki Ueno <ueno@unixuser.org>
+
+ * liece-vars.el (liece-buffer-min-size): Rename from
+ `liece-buffer-default-size'.
+
+ * liece-commands.el (liece-command-kill): Use `liece-time-elapsed'
+ instead of `liece-time-add'.
+
+ * liece.el (liece-check-buffers-if-interval-expired): Swap the
+ arguments supplied to `liece-time-difference'.
+ (liece-check-buffers): Use `liece-buffer-min-size' instead of
+ `liece-buffer-default-size'.
+
+ * liece-misc.el (liece-time-difference): Define as function.
+ (liece-time-elapsed): Rename from `liece-time-add'.
+ (liece-generate-hex-timestamp): Define as function.
+
+2001-10-02 Katsuhiro Hermit Endo <hermit@koka-in.org>
+
+ * liece-misc.el (liece-time-difference): Use `abs' for
+ `liece-check-buffers-if-interval-expired'.
+
2001-09-16 Katsuhiro Hermit Endo <hermit@koka-in.org>
* liece-vars.el (liece-server-alist): Update default value.
(car ignore))))
;; did not find, add to ignored ones
(let ((expire-time (if (> timeout 0)
- (liece-time-add (current-time)
- (* timeout 60)))))
+ (liece-time-elapsed (current-time)
+ (* timeout 60)))))
(and silent (> timeout 0)
(setcar (cdr (cdr expire-time)) -1))
(setq liece-kill-nickname
(setq liece-read-passwd 'ange-ftp-read-passwd))))
(funcall liece-read-passwd prompt))
-;; from XEmacs's subr.el
+;; XEmacs.
(defun-maybe replace-in-string (str regexp newtext &optional literal)
"Replace all matches in STR for REGEXP with NEWTEXT string,
and returns the new string.
Optional LITERAL non-nil means do a literal replacement.
-Otherwise treat \\ in NEWTEXT string as special:
- \\& means substitute original matched text,
- \\N means substitute match for \(...\) number N,
- \\\\ means insert one \\."
- (let ((rtn-str "")
- (start 0)
- (special)
- match prev-start)
- (while (setq match (string-match regexp str start))
- (setq prev-start start
- start (match-end 0)
- rtn-str
- (concat
- rtn-str
- (substring str prev-start match)
- (cond (literal newtext)
- (t (mapconcat
- (lambda (c)
- (if special
- (progn
- (setq special nil)
- (cond ((eq c ?\\) "\\")
- ((eq c ?&)
- (substring str
- (match-beginning 0)
- (match-end 0)))
- ((and (>= c ?0) (<= c ?9))
- (if (> c (+ ?0 (length
- (match-data))))
- ;; Invalid match num
- (error "Invalid match num: %c" c)
- (setq c (- c ?0))
- (substring str
- (match-beginning c)
- (match-end c))))
- (t (char-to-string c))))
- (if (eq c ?\\) (progn (setq special t) nil)
- (char-to-string c))))
- newtext ""))))))
- (concat rtn-str (substring str start))))
-
+Otherwise treat `\\' in NEWTEXT as special:
+ `\\&' in NEWTEXT means substitute original matched text.
+ `\\N' means substitute what matched the Nth `\\(...\\)'.
+ If Nth parens didn't match, substitute nothing.
+ `\\\\' means insert one `\\'.
+ `\\u' means upcase the next character.
+ `\\l' means downcase the next character.
+ `\\U' means begin upcasing all following characters.
+ `\\L' means begin downcasing all following characters.
+ `\\E' means terminate the effect of any `\\U' or `\\L'."
+ (if (> (length str) 50)
+ (with-temp-buffer
+ (insert str)
+ (goto-char 1)
+ (while (re-search-forward regexp nil t)
+ (replace-match newtext t literal))
+ (buffer-string))
+ (let ((start 0) newstr)
+ (while (string-match regexp str start)
+ (setq newstr (replace-match newtext t literal str)
+ start (+ (match-end 0) (- (length newstr) (length str)))
+ str newstr))
+ str)))
+
(provide 'liece-compat)
;;; liece-compat.el ends here
(setq who (cdr who)))))))
found))
-(defmacro liece-time-difference (t0 t1)
- "Difference in seconds between T0 and T1.
-Both T0 and T1 are in the encoded time format."
- `(+ (* (- (car ,t1) (car ,t0)) 65536)
- (- (cadr ,t1)) (cadr ,t0)))
-
-(defmacro liece-time-add (t0 t1)
- "Add T0 seconds to time T1.
-t0 is in `three integer lists'-format returned by `current-time' function."
- `(list (+ (car ,t0) (/ (+ (cadr ,t0) ,t1) 65536))
- (% (+ (cadr ,t0) ,t1) 65536)
- 0))
-
+;;; stolen (and renamed) from time-date.el.
+(defun liece-time-difference (t0 t1)
+ "Subtract two internal times."
+ (let ((borrow (< (cadr t1) (cadr t2))))
+ (list (- (car t1) (car t2) (if borrow 1 0))
+ (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
+
+(defun liece-time-elapsed (time seconds)
+ "Add SECONDS to TIME."
+ (list (+ (car time) (/ (+ (cadr time) seconds) 65536))
+ (% (+ (cadr time) seconds) 65536)
+ (nth 2 time)))
+
+;;; stolen (and renamed) from time-date.el.
(defun liece-seconds-to-time (seconds)
"Convert SECONDS (a floating point number) to an Emacs time structure."
(list (floor seconds 65536)
(floor (mod seconds 65536))
(floor (* (- seconds (ffloor seconds)) 1000000))))
-(defmacro liece-generate-hex-timestamp (&optional time)
+(defun liece-generate-hex-timestamp (&optional time)
"Generate timestamp string as hexadecimal.
If optional argument TIME is nil, calculate timestamp using current time."
- `(let ((time (or ,time (current-time))))
- (format "%04x%04x" (car time) (cadr time))))
+ (or time
+ (setq time (current-time)))
+ (format "%04x%04x" (car time) (cadr time)))
(defmacro liece-hex-timestamp-valid (timestamp limit)
"Is TIMESTAMP valid within LIMIT?"
:group 'liece-vars)
(defcustom liece-buffer-max-size 4242424
- "Maximum size (in bytes) of any liece buffer."
+ "Maximum size of buffers, the number of characters."
:type 'integer
:group 'liece-vars)
-(defcustom liece-buffer-default-size 4042424
- "Size to shrink buffer if it grows too big."
+(defcustom liece-buffer-min-size (- liece-buffer-max-size 200000)
+ "Minimum size of buffers, the number of characters."
:type 'integer
:group 'liece-vars)
(define-obsolete-variable-alias 'liece-buffer-maxsize
'liece-buffer-max-size)
(define-obsolete-variable-alias 'liece-buffer-defsize
- 'liece-buffer-default-size)
+ 'liece-buffer-min-size)
(define-obsolete-variable-alias 'liece-checkbuffer-interval
'liece-buffer-check-interval))
(delete-region (point-min)
(progn
(goto-char (- (buffer-size)
- liece-buffer-default-size))
+ liece-buffer-min-size))
(beginning-of-line -1)
(point)))
(garbage-collect)
Only used from `liece-before-insert-functions'."
(and (> liece-buffer-check-interval 0)
(or (null liece-buffer-last-check-time)
- (> (liece-time-difference liece-buffer-last-check-time
- (current-time))
+ (> (liece-time-difference (current-time)
+ liece-buffer-last-check-time)
liece-buffer-check-interval))
(liece-check-buffers)))