From c6fb37cbbad8f891365fb16b496f30e42a918edc Mon Sep 17 00:00:00 2001 From: ShengHuo ZHU Date: Fri, 14 Sep 2001 15:12:19 +0000 Subject: [PATCH] 2001-09-13 Martin Kretzschmar * gnus-spec.el (gnus-correct-substring): Still stopped one character before we wanted (never included last character). (gnus-tilde-max-form, gnus-tilde-cut-form) Made readable again, add missing "," (once per function) --- lisp/ChangeLog | 7 ++++ lisp/gnus-spec.el | 97 +++++++++++++++++------------------------------ 2 files changed, 42 insertions(+), 62 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4e325f303..f02ceace8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2001-09-13 Martin Kretzschmar + + * gnus-spec.el (gnus-correct-substring): Still stopped one + character before we wanted (never included last character). + (gnus-tilde-max-form, gnus-tilde-cut-form) Made readable again, + add missing "," (once per function) + 2001-09-14 Simon Josefsson * gnus-start.el (gnus-group-mode-hook): Moved from gnus-group diff --git a/lisp/gnus-spec.el b/lisp/gnus-spec.el index fbff185f7..a2a12be6c 100644 --- a/lisp/gnus-spec.el +++ b/lisp/gnus-spec.el @@ -273,94 +273,67 @@ (defun gnus-correct-substring (string start &optional end) (let ((wstart 0) (wend 0) + (wseek 0) (seek 0) - (length (length string))) + (length (length string)) + (string (concat string "\0"))) ;; Find the start position. (while (and (< seek length) - (< wstart start)) - (incf wstart (gnus-char-width (aref string seek))) + (< wseek start)) + (incf wseek (gnus-char-width (aref string seek))) (incf seek)) - (setq wend wstart - wstart seek) + (setq wstart seek) ;; Find the end position. - (while (and (< seek length) + (while (and (<= seek length) (or (not end) - (<= wend end))) - (incf wend (gnus-char-width (aref string seek))) + (<= wseek end))) + (incf wseek (gnus-char-width (aref string seek))) (incf seek)) (setq wend seek) (substring string wstart (1- wend)))) (defun gnus-tilde-max-form (el max-width) "Return a form that limits EL to MAX-WIDTH." - (let ((max (abs max-width))) - (if (symbolp el) - `(if (> (,(if gnus-use-correct-string-widths + (let ((max (abs max-width)) + (length-fun (if gnus-use-correct-string-widths 'gnus-correct-length - 'length) ,el) - ,max) - ,(if (< max-width 0) - `(,(if gnus-use-correct-string-widths - 'gnus-correct-substring - 'substring) - ,el (- (,(if gnus-use-correct-string-widths - 'gnus-correct-length - 'length) - el) ,max)) - `(,(if gnus-use-correct-string-widths + 'length)) + (substring-fun (if gnus-use-correct-string-widths 'gnus-correct-substring - 'substring) - ,el 0 ,max)) + 'substring))) + (if (symbolp el) + `(if (> (,length-fun ,el) ,max) + ,(if (< max-width 0) + `(,substring-fun ,el (- (,length-fun ,el) ,max)) + `(,substring-fun ,el 0 ,max)) ,el) `(let ((val (eval ,el))) - (if (> (,(if gnus-use-correct-string-widths - 'gnus-correct-length - 'length) val) ,max) + (if (> (,length-fun val) ,max) ,(if (< max-width 0) - `(,(if gnus-use-correct-string-widths - 'gnus-correct-substring - 'substring) - val (- (,(if gnus-use-correct-string-widths - 'gnus-correct-length - 'length) val) ,max)) - `(,(if gnus-use-correct-string-widths - 'gnus-correct-substring - 'substring) - val 0 ,max)) + `(,substring-fun val (- (,length-fun val) ,max)) + `(,substring-fun val 0 ,max)) val))))) (defun gnus-tilde-cut-form (el cut-width) "Return a form that cuts CUT-WIDTH off of EL." - (let ((cut (abs cut-width))) - (if (symbolp el) - `(if (> (,(if gnus-use-correct-string-widths + (let ((cut (abs cut-width)) + (length-fun (if gnus-use-correct-string-widths 'gnus-correct-length - 'length) ,el) ,cut) - ,(if (< cut-width 0) - `(,(if gnus-use-correct-string-widths - 'gnus-correct-substring - 'substring) ,el 0 - (- (,(if gnus-use-correct-string-widths - 'gnus-correct-length - 'length) el) ,cut)) - `(,(if gnus-use-correct-string-widths + 'length)) + (substring-fun (if gnus-use-correct-string-widths 'gnus-correct-substring - 'substring) ,el ,cut)) + 'substring))) + (if (symbolp el) + `(if (> (,length-fun ,el) ,cut) + ,(if (< cut-width 0) + `(,substring-fun ,el 0 (- (,length-fun ,el) ,cut)) + `(,substring-fun ,el ,cut)) ,el) `(let ((val (eval ,el))) - (if (> (,(if gnus-use-correct-string-widths - 'gnus-correct-length - 'length) val) ,cut) + (if (> (,length-fun val) ,cut) ,(if (< cut-width 0) - `(,(if gnus-use-correct-string-widths - 'gnus-correct-substring - 'substring) val 0 - (- (,(if gnus-use-correct-string-widths - 'gnus-correct-length - 'length) val) ,cut)) - `(,(if gnus-use-correct-string-widths - 'gnus-correct-substring - 'substring) val ,cut)) + `(,substring-fun val 0 (- (,length-fun val) ,cut)) + `(,substring-fun val ,cut)) val))))) (defun gnus-tilde-ignore-form (el ignore-value) -- 2.34.1