* wl-message.el (wl-message-make-display-type): New function.
authorhmurata <hmurata>
Sat, 11 Dec 2004 12:44:40 +0000 (12:44 +0000)
committerhmurata <hmurata>
Sat, 11 Dec 2004 12:44:40 +0000 (12:44 +0000)
(wl-message-display-type-property): Ditto.
(wl-message-mime-analysys-p): Ditto.
(wl-message-display-all-header-p): Ditto.
(wl-message-redisplay): Removed argument `as-is', `all-header' and
added `display-type'.
(wl-message-buffer-display): Likewise.
(wl-message-display-internal): Likewise.
(wl-message-buffer-display-type): Abolish.
(wl-message-buffer-prefetch-subr): Follow the API changed.

* wl-summary.el (wl-summary-buffer-display-header-mode): Renamed
from wl-summary-buffer-display-all-header and changed default value.
(wl-summary-message-display-type): New function.
(wl-summary-buffer-display-mime-mode): Ditto.
(wl-summary-buffer-display-header-mode): Ditto.
(wl-summary-toggle-mime): Rewrite with above functions.
(wl-summary-toggle-all-header): Ditto.
(wl-summary-redisplay): Force redisplay with default mode.
(wl-summary-redisplay-internal): Renamed argument from `mode',
`all-header' to `mime-mode', `header-mode'.
Use `wl-message-make-display-type'.

* wl-vars.el (wl-summary-mode-line-format): Removed `[%m]'.
(wl-message-mode-line-format-spec-alist): Changed definition for `m'.

wl/ChangeLog
wl/wl-message.el
wl/wl-summary.el
wl/wl-vars.el

index 765d268..e59776d 100644 (file)
@@ -1,3 +1,31 @@
+2004-12-11  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * wl-message.el (wl-message-make-display-type): New function.
+       (wl-message-display-type-property): Ditto.
+       (wl-message-mime-analysys-p): Ditto.
+       (wl-message-display-all-header-p): Ditto.
+       (wl-message-redisplay): Removed argument `as-is', `all-header' and
+       added `display-type'.
+       (wl-message-buffer-display): Likewise.
+       (wl-message-display-internal): Likewise.
+       (wl-message-buffer-display-type): Abolish.
+       (wl-message-buffer-prefetch-subr): Follow the API changed.
+
+       * wl-summary.el (wl-summary-buffer-display-header-mode): Renamed
+       from wl-summary-buffer-display-all-header and changed default value.
+       (wl-summary-message-display-type): New function.
+       (wl-summary-buffer-display-mime-mode): Ditto.
+       (wl-summary-buffer-display-header-mode): Ditto.
+       (wl-summary-toggle-mime): Rewrite with above functions.
+       (wl-summary-toggle-all-header): Ditto.
+       (wl-summary-redisplay): Force redisplay with default mode.
+       (wl-summary-redisplay-internal): Renamed argument from `mode',
+       `all-header' to `mime-mode', `header-mode'.
+       Use `wl-message-make-display-type'.
+
+       * wl-vars.el (wl-summary-mode-line-format): Removed `[%m]'.
+       (wl-message-mode-line-format-spec-alist): Changed definition for `m'.
+
 2004-12-11  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * wl-draft.el (wl-draft-send): Allow parent-folder as "".
index d95e20f..8d654c3 100644 (file)
@@ -418,8 +418,31 @@ Returns non-nil if bottom of message."
               (nth 3 entry) (match-string (nth 4 entry))))
            (goto-char end)))))))
 
-(defun wl-message-redisplay (folder number as-is all-header
-                                   &optional force-reload)
+;; display-type object definition.
+(defun wl-message-make-display-type (mime header)
+  (let (symbol)
+    (prog1
+       (setq symbol (intern (format "%s-%s-header" mime header)))
+      (put symbol
+          'wl-message-display-type
+          (list :mime mime :header header)))))
+
+(defun wl-message-display-type-property (display-type prop)
+  (plist-get (get display-type 'wl-message-display-type) prop))
+
+(defun wl-message-mime-analysys-p (display-type &optional header-or-body)
+  (let ((mode (wl-message-display-type-property display-type :mime)))
+    (case header-or-body
+      (header
+       (memq mode '(mime header-only)))
+      (t
+       (eq mode 'mime)))))
+
+(defun wl-message-display-all-header-p (display-type)
+  (eq (wl-message-display-type-property display-type :header) 'all))
+
+
+(defun wl-message-redisplay (folder number display-type &optional force-reload)
   (let* ((default-mime-charset wl-mime-charset)
         (buffer-read-only nil)
         (summary-buf (current-buffer))
@@ -429,7 +452,7 @@ Returns non-nil if bottom of message."
         summary-win delim flags)
     (setq buffer-read-only nil)
     (setq cache-used (wl-message-buffer-display
-                     folder number as-is all-header force-reload))
+                     folder number display-type force-reload))
     (setq wl-message-buffer (car cache-used))
     (setq message-buf wl-message-buffer)
     (wl-message-select-buffer wl-message-buffer)
@@ -486,7 +509,7 @@ Returns non-nil if bottom of message."
       (wl-message-add-buttons-to-header (point-min) (point))
       (wl-message-add-buttons-to-body (point) (point-max)))
     (when (and wl-message-use-header-narrowing
-              (not all-header))
+              (not (wl-message-display-all-header-p display-type)))
       (wl-message-header-narrowing))
     (goto-char (point-min))
     (ignore-errors (run-hooks 'wl-message-redisplay-hook))
@@ -499,13 +522,8 @@ Returns non-nil if bottom of message."
        (select-window summary-win))
     cache-used))
 
-(defun wl-message-buffer-display-type (mode all-header)
-  (let ((type (symbol-name mode)))
-    (when all-header (setq type (concat type "-all-header")))
-    (intern type)))
-
 ;; Use message buffer cache.
-(defun wl-message-buffer-display (folder number mode all-header
+(defun wl-message-buffer-display (folder number display-type
                                         &optional force-reload unread)
   (let* ((msg-id (ignore-errors (elmo-message-field folder number
                                                    'message-id)))
@@ -528,8 +546,7 @@ Returns non-nil if bottom of message."
            (widen)
            (goto-char (point-min))
            (ignore-errors (wl-message-narrow-to-page))
-           (unless (eq wl-message-buffer-cur-display-type
-                       (wl-message-buffer-display-type mode all-header))
+           (unless (eq wl-message-buffer-cur-display-type display-type)
              (setq read t))))
       ;; delete tail and add new to the top.
       (setq hit (wl-message-buffer-cache-add (list fname number msg-id)))
@@ -540,10 +557,9 @@ Returns non-nil if bottom of message."
              (set-buffer hit)
              (setq
               cache-used
-              (wl-message-display-internal folder number mode all-header
+              (wl-message-display-internal folder number display-type
                                            force-reload unread))
-             (setq wl-message-buffer-cur-display-type
-                   (wl-message-buffer-display-type mode all-header)))
+             (setq wl-message-buffer-cur-display-type display-type))
          (quit
           (wl-message-buffer-cache-delete)
           (error "Display message %s/%s is quitted" fname number))
@@ -553,36 +569,35 @@ Returns non-nil if bottom of message."
           nil))) ;; will not be used
     (cons hit cache-used)))
 
-(defun wl-message-display-internal (folder number mode all-header
+(defun wl-message-display-internal (folder number display-type
                                           &optional force-reload unread)
   (let ((default-mime-charset wl-mime-charset)
        (elmo-mime-charset wl-mime-charset))
-    (setq wl-message-buffer-require-all-header all-header)
+    (setq wl-message-buffer-require-all-header
+         (wl-message-display-all-header-p display-type))
     (prog1
-       (if (or (eq mode 'as-is)
-               (eq mode 'header-only))
-           (let ((elmo-mime-display-header-analysis (eq mode 'header-only))
-                 (wl-highlight-x-face-function
-                  (unless (eq mode 'as-is) wl-highlight-x-face-function)))
-             (prog1 (elmo-mime-display-as-is folder number
-                                             (current-buffer)
-                                             (wl-message-get-original-buffer)
-                                             'wl-original-message-mode
-                                             force-reload
-                                             unread
-                                             (wl-message-define-keymap))
-               (let (buffer-read-only)
-                 (wl-highlight-message (point-min) (point-max) t))))
-         (elmo-mime-message-display folder number
-                                    (current-buffer)
-                                    (wl-message-get-original-buffer)
-                                    'wl-original-message-mode
-                                    force-reload
-                                    unread
-                                    (wl-message-define-keymap)))
-      (let (buffer-read-only)
-       (put-text-property (point-min) (point-max)
-                          'wl-message-display-mime-mode mode))
+       (if (wl-message-mime-analysys-p display-type)
+           (elmo-mime-message-display folder number
+                                      (current-buffer)
+                                      (wl-message-get-original-buffer)
+                                      'wl-original-message-mode
+                                      force-reload
+                                      unread
+                                      (wl-message-define-keymap))
+         (let* ((elmo-mime-display-header-analysis
+                 (wl-message-mime-analysys-p display-type 'header))
+                (wl-highlight-x-face-function
+                 (and elmo-mime-display-header-analysis
+                      wl-highlight-x-face-function)))
+           (prog1 (elmo-mime-display-as-is folder number
+                                           (current-buffer)
+                                           (wl-message-get-original-buffer)
+                                           'wl-original-message-mode
+                                           force-reload
+                                           unread
+                                           (wl-message-define-keymap))
+             (let (buffer-read-only)
+               (wl-highlight-message (point-min) (point-max) t)))))
       (run-hooks 'wl-message-display-internal-hook)
       (setq buffer-read-only t))))
 
@@ -698,6 +713,9 @@ Returns non-nil if bottom of message."
                   (key (list (elmo-folder-name-internal folder)
                              number message-id))
                   (hit (wl-message-buffer-cache-hit key))
+                  (display-type (wl-message-make-display-type
+                                 wl-summary-buffer-display-mime-mode
+                                 wl-summary-buffer-display-header-mode))
                   result time1 time2 sec micro)
              (when wl-message-buffer-prefetch-debug
                (message "%d: count %d, hit %s" number count (buffer-name hit)))
@@ -715,7 +733,7 @@ Returns non-nil if bottom of message."
                  (setq time1 (current-time))
                  (message "Prefetching %d..." number))
                (setq result (wl-message-buffer-display
-                             folder number 'mime nil nil 'unread))
+                             folder number display-type nil 'unread))
                (when wl-message-buffer-prefetch-debug
                  (setq time2 (current-time))
                  (setq sec  (- (nth 1 time2)(nth 1 time1)))
index c270925..8fb91af 100644 (file)
 (defvar wl-summary-buffer-mode-line-formatter nil)
 (defvar wl-summary-buffer-mode-line nil)
 (defvar wl-summary-buffer-display-mime-mode 'mime)
-(defvar wl-summary-buffer-display-all-header nil)
+(defvar wl-summary-buffer-display-header-mode 'partial)
 (defvar wl-summary-buffer-event-handler nil)
 
 (defvar wl-thread-indent-level-internal nil)
 (make-variable-buffer-local 'wl-summary-buffer-mode-line-formatter)
 (make-variable-buffer-local 'wl-summary-buffer-mode-line)
 (make-variable-buffer-local 'wl-summary-buffer-display-mime-mode)
-(make-variable-buffer-local 'wl-summary-buffer-display-all-header)
+(make-variable-buffer-local 'wl-summary-buffer-display-header-mode)
 (make-variable-buffer-local 'wl-summary-buffer-event-handler)
 
 (defvar wl-datevec)
@@ -4395,6 +4395,25 @@ Use function list is `wl-summary-write-current-folder-functions'."
            (wl-summary-redisplay)))
     (message "No last message.")))
 
+(defun wl-summary-message-display-type ()
+  (when (and wl-summary-buffer-disp-msg
+            (buffer-live-p wl-message-buffer)
+            wl-summary-buffer-current-msg
+            (wl-summary-message-number)
+            (= (wl-summary-message-number) wl-summary-buffer-current-msg))
+    (with-current-buffer wl-message-buffer
+      wl-message-buffer-cur-display-type)))
+
+(defun wl-summary-buffer-display-mime-mode ()
+  (or (wl-message-display-type-property (wl-summary-message-display-type)
+                                       :mime)
+      wl-summary-buffer-display-mime-mode))
+
+(defun wl-summary-buffer-display-header-mode ()
+  (or (wl-message-display-type-property (wl-summary-message-display-type)
+                                       :header)
+      wl-summary-buffer-display-header-mode))
+
 (defun wl-summary-toggle-mime (&optional arg)
   "Toggle MIME decoding.
 If ARG is non-nil, ask coding-system to display the message in the current
@@ -4405,37 +4424,39 @@ If ARG is numeric number, decode message as following:
 2: Enable MIME analysis only for headers.
 3: Disable MIME analysis."
   (interactive "P")
-  (let ((rest (memq wl-summary-buffer-display-mime-mode
-                   wl-summary-display-mime-mode-list))
+  (let ((mime-mode (wl-summary-buffer-display-mime-mode))
        (elmo-mime-display-as-is-coding-system
         elmo-mime-display-as-is-coding-system))
-    (if (numberp arg)
-       (setq wl-summary-buffer-display-mime-mode
-             (case arg
-               (1 'mime)
-               (2 'header-only)
-               (3 'as-is)))
-      (if arg
-         ;; Specify coding-system (doesn't change the MIME mode).
-         (setq elmo-mime-display-as-is-coding-system
-               (if (and arg (not (eq wl-summary-buffer-display-mime-mode
-                                     'mime)))
-                   (or (read-coding-system "Coding system: ")
-                       elmo-mime-display-as-is-coding-system)
-                 elmo-mime-display-as-is-coding-system))
+    (if (and (consp arg) (> (prefix-numeric-value arg) 4))
+       (progn
+         (setq wl-summary-buffer-display-mime-mode mime-mode)
+         (wl-summary-update-modeline))
+      (cond
+       ((numberp arg)
+       (setq mime-mode (case arg
+                         (1 'mime)
+                         (2 'header-only)
+                         (3 'as-is))))
+       (arg
+       ;; Specify coding-system (doesn't change the MIME mode).
+       (setq elmo-mime-display-as-is-coding-system
+             (if (and arg
+                      (not (wl-message-mime-analysys-p
+                            (wl-summary-message-display-type))))
+                 (or (read-coding-system "Coding system: ")
+                     elmo-mime-display-as-is-coding-system)
+               elmo-mime-display-as-is-coding-system)))
+       (t
        ;; Change the MIME mode.
-       (if (cadr rest)
-           (setq wl-summary-buffer-display-mime-mode (cadr rest))
-         (setq wl-summary-buffer-display-mime-mode
-               (car wl-summary-display-mime-mode-list)))))
-    (wl-summary-redisplay arg)
-    (wl-summary-update-modeline)
+       (setq mime-mode (or (cadr (memq mime-mode
+                                       wl-summary-display-mime-mode-list))
+                           (car wl-summary-display-mime-mode-list)))))
+      (wl-summary-redisplay-internal nil nil arg mime-mode))
     (message "MIME decoding: %s%s"
-            (upcase (symbol-name wl-summary-buffer-display-mime-mode))
-            (if (and arg
-                     (not (numberp arg))
-                     (not (eq wl-summary-buffer-display-mime-mode
-                              'mime)))
+            (upcase (symbol-name mime-mode))
+            (if (and (not (eq mime-mode 'mime))
+                     (not (eq elmo-mime-display-as-is-coding-system
+                              wl-cs-autoconv)))
                 (concat " ("
                         (symbol-name elmo-mime-display-as-is-coding-system)
                         ")")
@@ -4444,20 +4465,24 @@ If ARG is numeric number, decode message as following:
 (defun wl-summary-redisplay (&optional arg)
   "Redisplay message."
   (interactive "P")
-  (wl-summary-redisplay-internal nil nil arg))
+  (apply #'wl-summary-redisplay-internal nil nil arg
+        (unless (and (consp arg) (> (prefix-numeric-value arg) 4))
+          (list wl-summary-buffer-display-mime-mode
+                wl-summary-buffer-display-header-mode))))
 
 (defun wl-summary-toggle-all-header (&optional arg)
   "Toggle displaying message with all header."
   (interactive "P")
-  (setq wl-summary-buffer-display-all-header
-       (not wl-summary-buffer-display-all-header))
-  (wl-summary-redisplay-internal nil nil arg))
+  (let ((header-mode (wl-summary-buffer-display-header-mode)))
+    (if (and (consp arg) (> (prefix-numeric-value arg) 4))
+       (setq wl-summary-buffer-display-header-mode header-mode)
+      (wl-summary-redisplay-internal
+       nil nil arg nil
+       (if (eq header-mode 'all) 'partial 'all)))))
 
 (defun wl-summary-redisplay-internal (&optional folder number force-reload
-                                               mode all-header)
+                                               mime-mode header-mode)
   (let* ((folder (or folder wl-summary-buffer-elmo-folder))
-        (mode (or mode wl-summary-buffer-display-mime-mode))
-        (all-header (or all-header wl-summary-buffer-display-all-header))
         (num (or number (wl-summary-message-number)))
         (wl-mime-charset      wl-summary-buffer-mime-charset)
         (default-mime-charset wl-summary-buffer-mime-charset)
@@ -4485,13 +4510,16 @@ If ARG is numeric number, decode message as following:
          (setq wl-current-summary-buffer (current-buffer))
          (setq no-folder-mark
                ;; If cache is used, change folder-mark.
-               (if (wl-message-redisplay folder num
-                                         mode all-header
-                                         (or
-                                          force-reload
-                                          (string= (elmo-folder-name-internal
-                                                    folder)
-                                                   wl-draft-folder)))
+               (if (wl-message-redisplay
+                    folder num
+                    (wl-message-make-display-type
+                     (or mime-mode
+                         (wl-summary-buffer-display-mime-mode))
+                     (or header-mode
+                         (wl-summary-buffer-display-header-mode)))
+                    (or force-reload
+                        (string= (elmo-folder-name-internal folder)
+                                 wl-draft-folder)))
                    nil
                  ;; plugged, then leave folder-mark.
                  (if (and (not (elmo-folder-local-p
index 609f94f..cb56495 100644 (file)
@@ -211,14 +211,14 @@ Each element is a list of following:
 SPEC is a character for format specification.
 STRING-EXP is an expression to get string to insert.")
 
-(defcustom wl-summary-mode-line-format "Wanderlust: %f {%t}(%n/%u/%a)[%m]"
+(defcustom wl-summary-mode-line-format "Wanderlust: %f {%t}(%n/%u/%a)"
   "*A format string for summary mode-line of Wanderlust.
 It may include any of the following format specifications
 which are replaced by the given information:
 
 %f The folder name.
 %t The thread status of the summary ('T' for thread, 'S' for sequential).
-%m The mime analysis status of the summary ('M' for MIME ON)
+%m The mime analysis status of the summary ('MIME' for MIME ON)
 %n The number of new messages.
 %u The number of unread messages (includes new messages).
 %a The number of all messages."
@@ -1661,8 +1661,9 @@ which appear just before @."
            (wl-folder-get-petname wl-message-buffer-cur-folder)
          wl-message-buffer-cur-folder))
     (?m (upcase (symbol-name
-                (get-text-property (point-min)
-                                   'wl-message-display-mime-mode))))
+                (wl-message-display-type-property
+                 wl-message-buffer-cur-display-type
+                 :mime))))
     (?F wl-message-buffer-flag-indicator)
     (?n wl-message-buffer-cur-number))
   "An alist of format specifications for message buffer's mode-lines.