From: Simon Josefsson Date: Wed, 19 Sep 2001 19:02:41 +0000 (+0000) Subject: 2001-09-18 Simon Josefsson X-Git-Url: http://cgit.sxemacs.org/?a=commitdiff_plain;h=7d0c7a2d6c82e4355dc5eec0da6cbf9b7b49f1c3;p=gnus 2001-09-18 Simon Josefsson * gnus-spec.el (gnus-correct-pad-form): Re-revert. (gnus-parse-simple-format): Re-revert. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 809c191fb..6f1ead5f4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2001-09-18 Simon Josefsson + + * gnus-spec.el (gnus-correct-pad-form): Re-revert. + (gnus-parse-simple-format): Re-revert. + 2001-09-16 Katsuhiro Hermit Endo * gnus-spec.el (gnus-parse-complex-format): Don't fold search diff --git a/lisp/gnus-spec.el b/lisp/gnus-spec.el index f493e9e9a..a15490e87 100644 --- a/lisp/gnus-spec.el +++ b/lisp/gnus-spec.el @@ -345,6 +345,27 @@ (if (equal val ,ignore-value) "" val)))) +(defun gnus-correct-pad-form (el pad-width) + "Return a form that pads EL to PAD-WIDTH accounting for multi-column +characters correctly. This is because `format' may pad to columns or to +characters when given a pad value." + (let ((pad (abs pad-width)) + (side (< 0 pad-width))) + (if (symbolp el) + `(let ((need (- ,pad (gnus-correct-length ,el)))) + (if (> need 0) + (concat ,(when side '(make-string need ?\ )) + ,el + ,(when (not side) '(make-string need ?\ ))) + ,el)) + `(let* ((val (eval ,el)) + (need (- ,pad (gnus-correct-length ,el)))) + (if (> need 0) + (concat ,(when side '(make-string need ?\ )) + ,el + ,(when (not side) '(make-string need ?\ ))) + ,el))))) + (defun gnus-parse-format (format spec-alist &optional insert) ;; This function parses the FORMAT string with the help of the ;; SPEC-ALIST and returns a list that can be eval'ed to return the @@ -511,10 +532,14 @@ (setq elem '("*" ?s)))) (setq elem-type (cadr elem)) ;; Insert the new format elements. - (when pad-width + (when (and pad-width + (not (and (featurep 'xemacs) + gnus-use-correct-string-widths))) (insert (number-to-string pad-width))) ;; Create the form to be evaled. - (if (or max-width cut-width ignore-value) + (if (or max-width cut-width ignore-value + (and (featurep 'xemacs) + gnus-use-correct-string-widths)) (progn (insert ?s) (let ((el (car elem))) @@ -528,6 +553,8 @@ (setq el (gnus-tilde-cut-form el cut-width))) (when max-width (setq el (gnus-tilde-max-form el max-width))) + (when pad-width + (setq el (gnus-correct-pad-form el pad-width))) (push el flist))) (insert elem-type) (push (car elem) flist))))