From 3befb7255a94232b4807d9840806cfeaaf08825c Mon Sep 17 00:00:00 2001 From: ueno Date: Tue, 2 Oct 2001 07:29:41 +0000 Subject: [PATCH] Synch up with liece-1_4. --- lisp/ChangeLog | 26 +++++++++++++++++++ lisp/liece-commands.el | 4 +-- lisp/liece-compat.el | 67 ++++++++++++++++++------------------------------ lisp/liece-misc.el | 34 ++++++++++++------------ lisp/liece-vars.el | 8 +++--- lisp/liece.el | 6 ++--- 6 files changed, 78 insertions(+), 67 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f021246..75e29be 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,29 @@ +2001-10-02 Daiki Ueno + + * liece-compat.el (replace-in-string): Follow a change in XEmacs. + +2001-10-02 Daiki Ueno + + * 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 + + * liece-misc.el (liece-time-difference): Use `abs' for + `liece-check-buffers-if-interval-expired'. + 2001-09-16 Katsuhiro Hermit Endo * liece-vars.el (liece-server-alist): Update default value. diff --git a/lisp/liece-commands.el b/lisp/liece-commands.el index d0070fe..340b9a5 100644 --- a/lisp/liece-commands.el +++ b/lisp/liece-commands.el @@ -339,8 +339,8 @@ If SILENT is non-nil, don't notify current status." (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 diff --git a/lisp/liece-compat.el b/lisp/liece-compat.el index 04771ac..58568b2 100644 --- a/lisp/liece-compat.el +++ b/lisp/liece-compat.el @@ -120,52 +120,35 @@ Otherwise, this function always returns false. (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 diff --git a/lisp/liece-misc.el b/lisp/liece-misc.el index 79f6cea..6018850 100644 --- a/lisp/liece-misc.el +++ b/lisp/liece-misc.el @@ -431,30 +431,32 @@ (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?" diff --git a/lisp/liece-vars.el b/lisp/liece-vars.el index f28d385..4033350 100644 --- a/lisp/liece-vars.el +++ b/lisp/liece-vars.el @@ -823,12 +823,12 @@ Messages from them won't be displayed." :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) @@ -841,7 +841,7 @@ Messages from them won't be displayed." (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)) diff --git a/lisp/liece.el b/lisp/liece.el index 3e0c1d3..c65c7b3 100644 --- a/lisp/liece.el +++ b/lisp/liece.el @@ -853,7 +853,7 @@ If such a buffer is found, shrink it." (delete-region (point-min) (progn (goto-char (- (buffer-size) - liece-buffer-default-size)) + liece-buffer-min-size)) (beginning-of-line -1) (point))) (garbage-collect) @@ -864,8 +864,8 @@ If such a buffer is found, shrink it." 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))) -- 1.7.10.4