From: teranisi Date: Tue, 7 May 2002 03:51:10 +0000 (+0000) Subject: * wl-summary.el (wl-summary-line-open-bracket): Abolished. X-Git-Tag: elmo-mark-root~155 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=527a3bfc7a6e9f06009e56546b5972d042bcd8f2;p=elisp%2Fwanderlust.git * wl-summary.el (wl-summary-line-open-bracket): Abolished. (wl-summary-line-close-bracket): Ditto. (wl-summary-line-children-number): Ditto. (wl-summary-line-thread-indent): Ditto. (wl-summary-line-children-and-from): Ditto. * wl-vars.el (wl-summary-line-format-spec-alist): Redefine '[', ']', 't', 'c', 'F' and added 'C'. * wl-util.el (wl-set-string-width): Accept negative value. (wl-line-parse-format): Added "%number(" and "%)". --- diff --git a/wl/ChangeLog b/wl/ChangeLog index 09dd715..0306acd 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,17 @@ +2002-05-07 Yuuichi Teranishi + + * wl-summary.el (wl-summary-line-open-bracket): Abolished. + (wl-summary-line-close-bracket): Ditto. + (wl-summary-line-children-number): Ditto. + (wl-summary-line-thread-indent): Ditto. + (wl-summary-line-children-and-from): Ditto. + + * wl-vars.el (wl-summary-line-format-spec-alist): Redefine '[', ']', + 't', 'c', 'F' and added 'C'. + + * wl-util.el (wl-set-string-width): Accept negative value. + (wl-line-parse-format): Added "%number(" and "%)". + 2002-05-07 Yoichi NAKAYAMA * wl-summary.el (wl-summary-line-list-count): Change format of the diff --git a/wl/wl-summary.el b/wl/wl-summary.el index 4ba9feb..b7442dd 100644 --- a/wl/wl-summary.el +++ b/wl/wl-summary.el @@ -4039,16 +4039,6 @@ If ARG, exit virtual folder." (format "%02d" (aref wl-datevec 3))) (defun wl-summary-line-minute () (format "%02d" (aref wl-datevec 4))) -(defun wl-summary-line-open-bracket () - (if wl-thr-linked "<" "[")) -(defun wl-summary-line-close-bracket () - (if wl-thr-linked ">" "]")) -(defun wl-summary-line-children-number () - (if wl-thr-children-number - (concat "+" (int-to-string wl-thr-children-number) ":") - "")) -(defun wl-summary-line-thread-indent () - (or wl-thr-indent-string "")) (defun wl-summary-line-size () (let ((size (elmo-msgdb-overview-entity-get-size wl-message-entity))) @@ -4094,11 +4084,6 @@ If ARG, exit virtual folder." (elmo-msgdb-overview-entity-get-from wl-message-entity)))) -(defun wl-summary-line-children-and-from () - (concat - (wl-summary-line-children-number) " " - (wl-summary-line-from))) - (defun wl-summary-line-list-count () (let ((folder wl-summary-buffer-folder-name) (sequence) (ml-name) (ml-count) (subject-string)) diff --git a/wl/wl-util.el b/wl/wl-util.el index 36a913b..db27706 100644 --- a/wl/wl-util.el +++ b/wl/wl-util.el @@ -174,35 +174,50 @@ If HACK-ADDRESSES is t, then the strings are considered to be mail addresses, ;;(make-obsolete 'wl-set-hash-val 'elmo-set-hash-val) (defsubst wl-set-string-width (width string) + "Make a new string which have specified WIDTH and content of STRING. +If WIDTH is negative number, padding spaces are added to the head and +otherwise, padding spaces are added to the tail of the string." (static-cond ((and (fboundp 'string-width) (fboundp 'truncate-string-to-width) (not (featurep 'xemacs))) - (if (> (string-width string) width) - (setq string (truncate-string-to-width string width))) - (if (= (string-width string) width) + (if (> (string-width string) (abs width)) + (setq string (truncate-string-to-width string (abs width)))) + (if (= (string-width string) (abs width)) string - (concat string - (format (format "%%%ds" - (- width (string-width string))) - " ")))) + (if (< width 0) + (concat (format (format "%%%ds" + (- (abs width) (string-width string))) + " ") + string) + (concat string + (format (format "%%%ds" + (- (abs width) (string-width string))) + " "))))) (t (elmo-set-work-buf (elmo-set-buffer-multibyte default-enable-multibyte-characters) (insert string) - (if (> (current-column) width) - (if (> (move-to-column width) width) + (if (> (current-column) (abs width)) + (if (> (move-to-column (abs width)) (abs width)) (progn (condition-case nil ; ignore error (backward-char 1) (error)) - (concat (buffer-substring (point-min) (point)) " ")) + (if (< width 0) + (concat " " (buffer-substring (point-min) (point))) + (concat (buffer-substring (point-min) (point)) " "))) (buffer-substring (point-min) (point))) - (if (= (current-column) width) + (if (= (current-column) (abs width)) string - (concat string - (format (format "%%%ds" - (- width (current-column))) - " ")))))))) + (if (< width 0) + (concat (format (format "%%%ds" + (- (abs width) (current-column))) + " ") + string) + (concat string + (format (format "%%%ds" + (- (abs width) (current-column))) + " "))))))))) (defun wl-mode-line-buffer-identification (&optional id) (let ((priorities '(biff plug title))) @@ -916,8 +931,9 @@ is enclosed by at least one regexp grouping construct." newtext))) (defun wl-line-parse-format (format spec-alist) - "Make a formatter from FORMAT and SPEC-ALIST." - (let (f spec specs) + "Make a formatter from FORMAT and SPEC-ALIST. +WIDTH is the width of the result string." + (let (f spec specs stack) (setq f (with-temp-buffer (insert format) @@ -926,20 +942,51 @@ is enclosed by at least one regexp grouping construct." (cond ((looking-at "%") (goto-char (match-end 0))) - ((looking-at "\\([0-9]*\\)\\([^0-9]\\)") - (setq spec - (if (setq spec (assq (string-to-char (match-string 2)) - spec-alist)) - (nth 1 spec) - (match-string 2))) - (unless (string= "" (match-string 1)) - (setq spec (list 'wl-set-string-width - (string-to-number (match-string 1)) - spec))) - (setq specs (cons spec specs)) - (replace-match "s" 'fixed)))) + ((looking-at "\\(-?[0-9]*\\)\\([^0-9]\\)") + (cond + ((string= (match-string 2) "(") + (if (zerop (length (match-string 1))) + (error "No number specification for %( line format")) + (push (list + (match-beginning 0) ; start + (match-end 0) ; start-content + (string-to-number + (match-string 1)) ; width + specs) ; specs + stack) + (setq specs nil)) + ((string= (match-string 2) ")") + (let ((entry (pop stack)) + form) + (unless entry + (error + "No matching %( parenthesis in summary line format")) + (goto-char (car entry)) ; start + (setq form (buffer-substring (nth 1 entry) ; start-content + (- (match-beginning 0) 1))) + (delete-region (car entry) (match-end 0)) + (insert "s") + (setq specs + (append + (nth 3 entry) + (list (list 'wl-set-string-width (nth 2 entry) + (append + (list 'format form) + specs))))))) + (t + (setq spec + (if (setq spec (assq (string-to-char (match-string 2)) + spec-alist)) + (nth 1 spec) + (match-string 2))) + (unless (string= "" (match-string 1)) + (setq spec (list 'wl-set-string-width + (string-to-number (match-string 1)) + spec))) + (replace-match "s" 'fixed) + (setq specs (append specs (list spec)))))))) (buffer-string))) - (append (list 'format f) (nreverse specs)))) + (append (list 'format f) specs))) (defmacro wl-line-formatter-setup (formatter format alist) (` (let (byte-compile-warnings) diff --git a/wl/wl-vars.el b/wl/wl-vars.el index 597b49f..f9a3eba 100644 --- a/wl/wl-vars.el +++ b/wl/wl-vars.el @@ -181,14 +181,26 @@ If you don't have multiple e-mail addresses, you don't have to set this." (?W (wl-summary-line-day-of-week)) (?h (wl-summary-line-hour)) (?m (wl-summary-line-minute)) - (?\[ (wl-summary-line-open-bracket)) - (?\] (wl-summary-line-close-bracket)) - (?t (wl-summary-line-thread-indent)) + (?\[ (if wl-thr-linked "<" "[")) + (?\] (if wl-thr-linked ">" "]")) + (?t (or wl-thr-indent-string "")) (?s (wl-summary-line-subject)) (?S (wl-summary-line-size)) - (?c (wl-summary-line-children-number)) + (?C (if wl-thr-children-number + (concat "[+" (number-to-string wl-thr-children-number) "] ") + (if wl-parent-message-entity + (if wl-thr-linked ">>" ">") + ""))) + (?c (if wl-thr-children-number + (concat "+" (number-to-string wl-thr-children-number) ":") + " ")) + (?F (concat + (if wl-thr-children-number + (concat "+" (number-to-string wl-thr-children-number) ":") + "") + " " + (wl-summary-line-from))) (?f (wl-summary-line-from)) - (?F (wl-summary-line-children-and-from)) (?# (wl-summary-line-list-count))) "An alist of format specifications that can appear in summary lines. Each element is a list of following: @@ -196,7 +208,7 @@ Each element is a list of following: SPEC is a character for format specification. STRING is an expression to get string to insert.") -(defcustom wl-summary-line-format "%M/%D(%W)%h:%m %t%[%17F %] %s" +(defcustom wl-summary-line-format "%M/%D(%W)%h:%m %t%[%17(%c %f%) %] %s" "*A default format string for summary line of Wanderlust. It may include any of the following format specifications which are replaced by the given information: