* wl-summary.el (wl-summary-buffer-message-redisplay-func): Removed.
[elisp/wanderlust.git] / wl / wl-summary.el
index c1b1c87..a610f4a 100644 (file)
@@ -66,8 +66,6 @@
 (defvar wl-summary-mode-map nil)
 (defvar wl-current-summary-buffer nil)
 
-;; (defvar wl-summary-buffer-msgdb       nil) obsolete.
-;; (defvar wl-summary-buffer-folder-name nil) obsolete.
 (defvar wl-summary-buffer-elmo-folder nil)
 
 (defmacro wl-summary-buffer-folder-name ()
@@ -91,7 +89,6 @@
 (defvar wl-summary-buffer-mime-charset  nil)
 (defvar wl-summary-buffer-weekday-name-lang  nil)
 (defvar wl-summary-buffer-thread-indent-set-alist  nil)
-(defvar wl-summary-buffer-message-redisplay-func nil)
 (defvar wl-summary-buffer-view 'thread)
 (defvar wl-summary-buffer-message-modified nil)
 (defvar wl-summary-buffer-mark-modified nil)
 (defvar wl-summary-buffer-prev-refile-destination nil)
 (defvar wl-summary-buffer-prev-copy-destination nil)
 (defvar wl-summary-buffer-saved-message nil)
-(defvar wl-summary-buffer-prev-folder-func nil)
-(defvar wl-summary-buffer-next-folder-func nil)
-(defvar wl-summary-buffer-exit-func nil)
+(defvar wl-summary-buffer-prev-folder-function nil)
+(defvar wl-summary-buffer-next-folder-function nil)
+(defvar wl-summary-buffer-exit-function nil)
+(defvar wl-summary-buffer-number-list nil)
+(defvar wl-summary-buffer-msgdb nil)
+(defvar wl-summary-buffer-folder-name nil)
+
 (defvar wl-thread-indent-level-internal nil)
 (defvar wl-thread-have-younger-brother-str-internal nil)
 (defvar wl-thread-youngest-child-str-internal nil)
 (defvar wl-summary-delayed-update nil)
 (defvar wl-summary-search-buf-folder-name nil)
 
-(defvar wl-summary-get-petname-func 'wl-address-get-petname-1)
+(defvar wl-summary-get-petname-function 'wl-address-get-petname-1)
 
-(defvar wl-summary-message-regexp "^ *\\([0-9]+\\)")
+(defvar wl-summary-message-regexp "^ *\\([0-9-]+\\)")
 
 (defvar wl-summary-shell-command-last "")
 
 (make-variable-buffer-local 'wl-thread-vertical-str-internal)
 (make-variable-buffer-local 'wl-thread-horizontal-str-internal)
 (make-variable-buffer-local 'wl-thread-space-str-internal)
-(make-variable-buffer-local 'wl-summary-buffer-prev-folder-func)
-(make-variable-buffer-local 'wl-summary-buffer-next-folder-func)
-(make-variable-buffer-local 'wl-summary-buffer-exit-func)
+(make-variable-buffer-local 'wl-summary-buffer-prev-folder-function)
+(make-variable-buffer-local 'wl-summary-buffer-next-folder-function)
+(make-variable-buffer-local 'wl-summary-buffer-exit-function)
+(make-variable-buffer-local 'wl-summary-buffer-number-list)
+(make-variable-buffer-local 'wl-summary-buffer-msgdb)
+(make-variable-buffer-local 'wl-summary-buffer-folder-name)
 
 ;; internal functions (dummy)
 (unless (fboundp 'wl-summary-append-message-func-internal)
                                 (eword-decode-string
                                  (if wl-use-petname
                                      (or
-                                      (funcall wl-summary-get-petname-func to)
+                                      (funcall wl-summary-get-petname-function to)
                                       (car
                                        (std11-extract-address-components to))
                                       to)
                         entity "newsgroups"))
               (setq retval (concat "Ng:" ng)))))
       (if wl-use-petname
-         (setq retval (or (funcall wl-summary-get-petname-func from)
+         (setq retval (or (funcall wl-summary-get-petname-function from)
                           (car (std11-extract-address-components from))
                           from))
        (setq retval from)))
 
 (defun wl-summary-simple-from (string)
   (if wl-use-petname
-      (or (funcall wl-summary-get-petname-func string)
+      (or (funcall wl-summary-get-petname-function string)
          (car (std11-extract-address-components string))
          string)
     string))
@@ -846,6 +850,7 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'."
     (setq wl-thread-entity-hashtb (elmo-make-hash (* (length overview) 2)))
     (setq wl-thread-entity-list nil)
     (setq wl-thread-entities nil)
+    (setq wl-summary-buffer-number-list nil)
     (setq wl-summary-buffer-target-mark-list nil)
     (setq wl-summary-buffer-refile-list nil)
     (setq wl-summary-buffer-delete-list nil)
@@ -875,10 +880,12 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'."
        (setq wl-summary-delayed-update (cdr wl-summary-delayed-update))))
     (message "Constructing summary structure...done")
     (set-buffer cur-buf)
-    (when (eq wl-summary-buffer-view 'thread)
-      (message "Inserting thread...")
-      (wl-thread-insert-top)
-      (message "Inserting thread...done"))
+    (if (eq wl-summary-buffer-view 'thread)
+       (progn
+         (message "Inserting thread...")
+         (wl-thread-insert-top)
+         (message "Inserting thread...done"))
+      (wl-summary-make-number-list))
     (when wl-use-scoring
       (setq wl-summary-scored nil)
       (wl-summary-score-headers nil msgdb
@@ -1004,8 +1011,8 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'."
        summary-win
        message-buf message-win
        folder-buf folder-win)
-    (if wl-summary-buffer-exit-func
-       (funcall wl-summary-buffer-exit-func)
+    (if wl-summary-buffer-exit-function
+       (funcall wl-summary-buffer-exit-function)
       (wl-summary-cleanup-temp-marks sticky)
       (unwind-protect
          ;; save summary status
@@ -1064,6 +1071,7 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'."
                                             (wl-summary-buffer-msgdb))) 2)))
   (setq wl-thread-entity-list nil)
   (setq wl-thread-entities nil)
+  (setq wl-summary-buffer-number-list nil)
   (setq wl-summary-buffer-target-mark-list nil)
   (setq wl-summary-buffer-refile-list nil)
   (setq wl-summary-buffer-copy-list nil)
@@ -1350,7 +1358,7 @@ If ARG is non-nil, checking is omitted."
        (goto-char (point-min))
        (while (not (eobp))
          (beginning-of-line)
-         (when (looking-at "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)")
+         (when (looking-at "^ *\\([0-9-]+\\)[^0-9]\\([^0-9]\\)")
            (setq mark (wl-match-buffer 2))
            (setq msg (string-to-int (wl-match-buffer 1)))
            (if (or (and (null prefetch-marks)
@@ -1404,7 +1412,7 @@ If ARG is non-nil, checking is omitted."
   (save-excursion
     (save-match-data
       (beginning-of-line)
-      (when (looking-at "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)")
+      (when (looking-at "^ *\\([0-9-]+\\)[^0-9]\\([^0-9]\\)")
        (goto-char (match-beginning 2))
        (let ((inhibit-read-only t)
              (buffer-read-only nil)
@@ -1598,7 +1606,7 @@ If ARG is non-nil, checking is omitted."
        (elmo-folder-mark-as-read folder (wl-summary-collect-unread mark-alist))
        (save-excursion
          (goto-char (point-min))
-         (while (re-search-forward "^ *\\([0-9]+\\)[^0-9]\\([^0-9 ]\\)" nil t)
+         (while (re-search-forward "^ *\\([0-9-]+\\)[^0-9]\\([^0-9 ]\\)" nil t)
            (setq msg (string-to-int (wl-match-buffer 1)))
            (setq mark (wl-match-buffer 2))
            (when (and (not (string= mark wl-summary-important-mark))
@@ -1649,7 +1657,7 @@ If ARG is non-nil, checking is omitted."
           mark number unread new-mark)
 ;;;   (re-search-backward "^ *[0-9]+..[0-9]+/[0-9]+" nil t) ; set cursor line
       (beginning-of-line)
-      (when (looking-at "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)")
+      (when (looking-at "^ *\\([0-9-]+\\)[^0-9]\\([^0-9]\\)")
        (progn
          (setq mark (wl-match-buffer 2))
          (cond
@@ -1694,7 +1702,7 @@ If ARG is non-nil, checking is omitted."
     (message "Resuming cache status...")
     (save-excursion
       (goto-char (point-min))
-      (while (re-search-forward "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)" nil t)
+      (while (re-search-forward "^ *\\([0-9-]+\\)[^0-9]\\([^0-9]\\)" nil t)
        (setq msg (string-to-int
                   (wl-match-buffer 1)))
        (setq mark (wl-match-buffer 2))
@@ -1816,7 +1824,8 @@ If ARG is non-nil, checking is omitted."
              (progn
                (delete-region (match-beginning 0) (match-end 0))
                (delete-char 1) ; delete '\n'
-               )))
+               (setq wl-summary-buffer-number-list
+                     (delq (car msgs) wl-summary-buffer-number-list)))))
        (when (and deleting-info
                   (> len elmo-display-progress-threshold))
          (setq i (1+ i))
@@ -2132,6 +2141,8 @@ If ARG is non-nil, checking is omitted."
              (wl-thread-update-indent-string-thread
               (elmo-uniq-list update-top-list)))
            (message "Updating thread...done"))
+         (unless (eq wl-summary-buffer-view 'thread)
+           (wl-summary-make-number-list))
          (wl-summary-set-message-modified)
          (wl-summary-set-mark-modified)
          (when (and sync-all (eq wl-summary-buffer-view 'thread))
@@ -2194,6 +2205,7 @@ If ARG is non-nil, checking is omitted."
                                wl-summary-partial-highlight-above-lines
                                wl-summary-highlight-partial-threshold)))
              (wl-highlight-summary (point) (point-max))))))
+    (setq wl-summary-buffer-msgdb (elmo-folder-msgdb folder))
     (wl-delete-all-overlays)
     (set-buffer-modified-p nil)
     (if mes (message "%s" mes))))
@@ -2205,7 +2217,7 @@ If ARG is non-nil, checking is omitted."
          (buffer-read-only nil)
          msg-num
          cur-mark)
-      (when (looking-at "^ *\\([0-9]+\\)\\([^0-9]\\)")
+      (when (looking-at "^ *\\([0-9-]+\\)\\([^0-9]\\)")
        (setq msg-num  (string-to-int (wl-match-buffer 1)))
        (setq cur-mark (wl-match-buffer 2))
        (when (member cur-mark (list " "
@@ -2272,7 +2284,7 @@ If ARG is non-nil, checking is omitted."
 (defun wl-summary-message-number ()
   (save-excursion
     (beginning-of-line)
-    (if (looking-at "^ *\\([0-9]+\\)")
+    (if (looking-at "^ *\\([0-9-]+\\)")
        (string-to-int (wl-match-buffer 1))
       nil)))
 
@@ -2449,7 +2461,10 @@ If ARG, without confirm."
                   wl-summary-buffer-number-regexp
                   wl-summary-buffer-message-modified
                   wl-summary-buffer-mark-modified
-                  wl-summary-buffer-thread-modified)
+                  wl-summary-buffer-thread-modified
+                  wl-summary-buffer-number-list
+                  wl-summary-buffer-msgdb
+                  wl-summary-buffer-folder-name)
                 (and (eq wl-summary-buffer-view 'thread)
                      '(wl-thread-entity-hashtb
                        wl-thread-entities
@@ -2500,6 +2515,12 @@ If ARG, without confirm."
     (or (get-buffer (wl-summary-sticky-buffer-name name))
        (get-buffer-create wl-summary-buffer-name))))
 
+(defun wl-summary-make-number-list ()
+  (setq wl-summary-buffer-number-list
+       (mapcar
+        (lambda (x) (elmo-msgdb-overview-entity-get-number x))
+        (elmo-msgdb-get-overview (wl-summary-buffer-msgdb)))))
+
 (defun wl-summary-goto-folder-subr (&optional name scan-type other-window
                                              sticky interactive scoring)
   "Display target folder on summary."
@@ -2546,15 +2567,20 @@ If ARG, without confirm."
          (let ((case-fold-search nil)
                (inhibit-read-only t)
                (buffer-read-only nil))
+           ;; Select folder
+           (elmo-folder-open folder)
+           ;; For compatibility
+           (setq wl-summary-buffer-msgdb (elmo-folder-msgdb folder))
+           (setq wl-summary-buffer-folder-name (elmo-folder-name-internal
+                                                folder))
            (erase-buffer)
-           ;; resume summary cache
+           ;; Resume summary view
            (if wl-summary-cache-use
                (let* ((dir (elmo-folder-msgdb-path folder))
                       (cache (expand-file-name wl-summary-cache-file dir))
                       (view (expand-file-name wl-summary-view-file dir)))
                  (when (file-exists-p cache)
-                   (as-binary-input-file
-                    (insert-file-contents cache))
+                   (insert-file-contents-as-binary cache)
                    (elmo-set-buffer-multibyte
                     default-enable-multibyte-characters)
                    (decode-mime-charset-region
@@ -2564,9 +2590,13 @@ If ARG, without confirm."
                    (setq wl-summary-buffer-view
                          (wl-summary-load-file-object view)))
                  (if (eq wl-summary-buffer-view 'thread)
-                     (wl-thread-resume-entity folder))))
-           ;; Select folder
-           (elmo-folder-open folder)
+                     (wl-thread-resume-entity folder)
+                   (wl-summary-make-number-list)))
+             (setq wl-summary-buffer-view
+                   (wl-summary-load-file-object
+                    (expand-file-name wl-summary-view-file
+                                      (elmo-folder-msgdb-path folder))))
+             (wl-summary-rescan))
            (wl-summary-count-unread
             (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
            (wl-summary-update-modeline)))
@@ -2601,10 +2631,9 @@ If ARG, without confirm."
          (set-buffer-modified-p nil)
          (goto-char (point-min))
          (if (wl-summary-cursor-down t)
-             (let ((unreadp (wl-thread-next-mark-p
-                             (wl-thread-entity-get-mark
-                              (wl-summary-message-number))
-                             wl-summary-move-order)))
+             (let ((unreadp (wl-summary-next-message 
+                             (wl-summary-message-number)
+                             'down nil)))
                (cond ((and wl-auto-select-first unreadp)
                       (setq retval 'disp-msg))
                      ((not unreadp)
@@ -2629,9 +2658,6 @@ If ARG, without confirm."
                                    wl-summary-highlight-partial-threshold)))
                    (wl-highlight-summary (point) (point-max)))
                (wl-highlight-summary (point-min) (point-max))))
-         (if (null wl-summary-buffer-msgdb) ;; one more try.
-             (setq wl-summary-buffer-msgdb
-                   (elmo-msgdb-load (elmo-string fld))))
          (if (eq retval 'disp-msg)
              (wl-summary-redisplay))
          (if mes (message "%s" mes))
@@ -2724,7 +2750,7 @@ If ARG, without confirm."
 
 (defun wl-summary-default-subject-filter (subject)
   (let ((case-fold-search t))
-    (setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\):" ""))
+    (setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\)[:>]" ""))
     (setq subject (elmo-replace-in-string subject "[ \t]" ""))
     (elmo-replace-in-string subject "^\\[.*\\]" "")))
 
@@ -3133,7 +3159,8 @@ If optional argument NUMBER is specified, mark message specified by NUMBER."
                            (not (null (cdr dst-msgs)))
                            nil ; no-delete
                            nil ; same-number
-                           unread-marks))
+                           unread-marks
+                           t))
            (error nil))
          (if result                    ; succeeded.
              (progn
@@ -3154,16 +3181,18 @@ If optional argument NUMBER is specified, mark message specified by NUMBER."
          (setq result nil)
          (condition-case nil
              (setq result (elmo-folder-move-messages
-                           (wl-summary-buffer-folder-name)
+                           wl-summary-buffer-elmo-folder
                            (cdr (car dst-msgs))
-                           (car (car dst-msgs))
+                           (wl-folder-get-elmo-folder
+                            (car (car dst-msgs)))
                            (wl-summary-buffer-msgdb)
                            copy-len
                            copy-executed
                            (not (null (cdr dst-msgs)))
                            t ; t is no-delete (copy)
                            nil ; same number
-                           unread-marks))
+                           unread-marks
+                           t))
            (error nil))
          (if result                    ; succeeded.
              (progn
@@ -3197,7 +3226,7 @@ If optional argument NUMBER is specified, mark message specified by NUMBER."
   (let ((fld (completing-read
              (format "Folder name %s(%s): " (or purpose "")
                      default)
-             (or wl-folder-completion-func
+             (or wl-folder-completion-function
                  (if (memq 'read-folder wl-use-folder-petname)
                      (wl-folder-get-entity-with-petname)
                    wl-folder-entity-hashtb))
@@ -4267,7 +4296,7 @@ If ARG, exit virtual folder."
       (setq wl-summary-buffer-number-column
            (or
             (if (and update
-                     (setq end (if (re-search-forward "^ *[0-9]+[^0-9]" nil t)
+                     (setq end (if (re-search-forward "^ *[0-9-]+[^0-9]" nil t)
                                    (point))))
                 (- end (progn (beginning-of-line) (point)) 1))
             (wl-get-assoc-list-value wl-summary-number-column-alist
@@ -4282,107 +4311,69 @@ If ARG, exit virtual folder."
        (wl-match-string 1 wday-str)
       (elmo-date-get-week year month mday))))
 
-(defmacro wl-summary-cursor-move-regex ()
-  (` (let ((mark-alist
-           (if (elmo-folder-plugged-p wl-summary-buffer-elmo-folder)
-               (cond ((eq wl-summary-move-order 'new)
-                      (list
-                       (list
-                        wl-summary-new-mark)
-                       (list
-                        wl-summary-unread-uncached-mark
-                        wl-summary-unread-cached-mark
-                        wl-summary-important-mark)))
-                     ((eq wl-summary-move-order 'unread)
-                      (list
-                      (list
-                       wl-summary-unread-uncached-mark
-                       wl-summary-unread-cached-mark
-                       wl-summary-new-mark)
-                      (list
-                       wl-summary-important-mark)))
-                     (t
-                      (list
-                      (list
-                       wl-summary-unread-uncached-mark
-                       wl-summary-unread-cached-mark
-                       wl-summary-new-mark
-                       wl-summary-important-mark))))
-             (cond ((eq wl-summary-move-order 'unread)
-                    (list
-                    (list
-                     wl-summary-unread-cached-mark)
-                    (list
-                     wl-summary-important-mark)))
-                   (t
-                    (list
-                    (list
-                     wl-summary-unread-cached-mark
-                     wl-summary-important-mark)))))))
-       (mapcar
-       (function
-        (lambda (mark-list)
-          (concat wl-summary-message-regexp
-                  ".\\("
-                  (mapconcat 'regexp-quote
-                             mark-list
-                             "\\|")
-                  "\\)\\|"
-                  wl-summary-message-regexp "\\*")))
-       mark-alist))))
-
-;;
-;; Goto unread or important
-;;
-(defun wl-summary-cursor-up (&optional hereto)
-  (interactive "P")
-  (if (and (not wl-summary-buffer-target-mark-list)
-          (eq wl-summary-buffer-view 'thread))
-      (progn
-       (if (eobp)
-           (forward-line -1))
-       (wl-thread-jump-to-prev-unread hereto))
-    (if hereto
-       (end-of-line)
-      (beginning-of-line))
-    (let ((case-fold-search nil)
-         regex-list)
-      (setq regex-list (wl-summary-cursor-move-regex))
-      (catch 'done
-       (while regex-list
-         (when (re-search-backward
-                (car regex-list)
-                nil t nil)
-           (beginning-of-line)
-           (throw 'done t))
-         (setq regex-list (cdr regex-list)))
-       (beginning-of-line)
-       (throw 'done nil)))))
-
+(defvar wl-summary-move-spec-alist
+  (` ((new . ((t . nil)
+             (p . (, wl-summary-new-mark))
+             (p . (, (wl-regexp-opt
+                      (list wl-summary-unread-uncached-mark
+                            wl-summary-unread-cached-mark))))
+             (p . (, (regexp-quote wl-summary-important-mark)))))
+      (unread . ((t . nil)
+                (p . (, (wl-regexp-opt
+                         (list wl-summary-new-mark
+                               wl-summary-unread-uncached-mark
+                               wl-summary-unread-cached-mark))))
+                (p . (, (regexp-quote wl-summary-important-mark))))))))
+
+(defsubst wl-summary-next-message (num direction hereto)
+  (let ((cur-spec (cdr (assq wl-summary-move-order 
+                            wl-summary-move-spec-alist)))
+       (nums (memq num (if (eq direction 'up)
+                           (reverse wl-summary-buffer-number-list)
+                         wl-summary-buffer-number-list)))
+       marked-list nums2)
+    (unless hereto (setq nums (cdr nums)))
+    (setq nums2 nums)
+    (catch 'done
+      (while cur-spec
+       (setq nums nums2)
+       (cond ((eq (car (car cur-spec)) 'p)
+              (if (setq marked-list (elmo-folder-list-messages-mark-match
+                                     wl-summary-buffer-elmo-folder
+                                     (cdr (car cur-spec))))
+                  (while nums
+                    (if (memq (car nums) marked-list)
+                        (throw 'done (car nums)))
+                    (setq nums (cdr nums)))))
+             ((eq (car (car cur-spec)) 't)
+              (while nums
+                (if (and wl-summary-buffer-target-mark-list
+                         (memq (car nums)
+                               wl-summary-buffer-target-mark-list))
+                    (throw 'done (car nums)))
+                (setq nums (cdr nums)))))
+       (setq cur-spec (cdr cur-spec))))))
+
+(defsubst wl-summary-cursor-move (direction hereto)
+  (when (and (eq direction 'up)
+            (eobp))
+    (forward-line -1)
+    (setq hereto t))
+  (let (num)
+    (when (setq num (wl-summary-next-message (wl-summary-message-number)
+                                            direction hereto))
+      (wl-thread-jump-to-msg num)
+      t)))
 ;;
 ;; Goto unread or important
 ;; returns t if next message exists in this folder.
 (defun wl-summary-cursor-down (&optional hereto)
   (interactive "P")
-  (if (and (null wl-summary-buffer-target-mark-list)
-          (eq wl-summary-buffer-view 'thread))
-      (wl-thread-jump-to-next-unread hereto)
-    (if hereto
-       (beginning-of-line)
-      (end-of-line))
-    (let ((case-fold-search nil)
-         regex-list)
-      (setq regex-list (wl-summary-cursor-move-regex))
-      (catch 'done
-       (while regex-list
-         (when (re-search-forward
-                (car regex-list)
-                nil t nil)
-           (beginning-of-line)
-           (throw 'done t))
-         (setq regex-list (cdr regex-list)))
-       (beginning-of-line)
-       (throw 'done nil)))))
+  (wl-summary-cursor-move 'down hereto))
+
+(defun wl-summary-cursor-up (&optional hereto)
+  (interactive "P")
+  (wl-summary-cursor-move 'up hereto))
 
 (defun wl-summary-save-view-cache ()
   (save-excursion
@@ -5014,8 +5005,8 @@ Use function list is `wl-summary-write-current-folder-functions'."
          (if wl-summary-buffer-disp-msg
              (wl-summary-redisplay)))
       (if (or interactive (interactive-p))
-         (if wl-summary-buffer-prev-folder-func
-             (funcall wl-summary-buffer-prev-folder-func)
+         (if wl-summary-buffer-prev-folder-function
+             (funcall wl-summary-buffer-prev-folder-function)
            (when wl-auto-select-next
              (setq next-entity (wl-summary-get-prev-folder))
              (if next-entity
@@ -5053,8 +5044,8 @@ Use function list is `wl-summary-write-current-folder-functions'."
        (if wl-summary-buffer-disp-msg
            (wl-summary-redisplay))
       (if (or interactive (interactive-p))
-         (if wl-summary-buffer-next-folder-func
-             (funcall wl-summary-buffer-next-folder-func)
+         (if wl-summary-buffer-next-folder-function
+             (funcall wl-summary-buffer-next-folder-function)
            (when wl-auto-select-next
              (setq next-entity (wl-summary-get-next-folder))
              (if next-entity
@@ -5075,8 +5066,8 @@ Use function list is `wl-summary-write-current-folder-functions'."
          (wl-summary-redisplay))
     (if (or interactive
            (interactive-p))
-       (if wl-summary-buffer-prev-folder-func
-           (funcall wl-summary-buffer-prev-folder-func)
+       (if wl-summary-buffer-prev-folder-function
+           (funcall wl-summary-buffer-prev-folder-function)
          (let (next-entity finfo)
            (when wl-auto-select-next
              (progn
@@ -5133,8 +5124,8 @@ Use function list is `wl-summary-write-current-folder-functions'."
          (wl-summary-redisplay))
     (if (or interactive
            (interactive-p))
-       (if wl-summary-buffer-next-folder-func
-           (funcall wl-summary-buffer-next-folder-func)
+       (if wl-summary-buffer-next-folder-function
+           (funcall wl-summary-buffer-next-folder-function)
          (let (next-entity finfo)
            (when wl-auto-select-next
              (setq next-entity (wl-summary-get-next-unread-folder)))
@@ -5447,7 +5438,7 @@ Use function list is `wl-summary-write-current-folder-functions'."
            (let ((buffer (generate-new-buffer " *print*")))
              (copy-to-buffer buffer (point-min) (point-max))
              (set-buffer buffer)
-             (funcall wl-print-buffer-func)
+             (funcall wl-print-buffer-function)
              (kill-buffer buffer)))
        (message "")))))
 
@@ -5494,7 +5485,7 @@ Use function list is `wl-summary-write-current-folder-functions'."
                         (list "/pagenumberstring load"
                               (concat "(" wl-ps-date ")"))))
                    (run-hooks 'wl-ps-print-hook)
-                   (funcall wl-ps-print-buffer-func filename))
+                   (funcall wl-ps-print-buffer-function filename))
                (kill-buffer buffer)))))
       (message ""))))
 
@@ -5628,22 +5619,13 @@ Use function list is `wl-summary-write-current-folder-functions'."
 ;;     (message "Dropping...done"))))
 
 (defun wl-summary-default-get-next-msg (msg)
-  (let (next)
-    (if (and (not wl-summary-buffer-target-mark-list)
-            (eq wl-summary-buffer-view 'thread)
-            (if (eq wl-summary-move-direction-downward nil)
-                (setq next (wl-thread-get-prev-unread msg))
-              (setq next (wl-thread-get-next-unread msg))))
-       next
-      (save-excursion
-       (wl-summary-jump-to-msg msg)
-       (let (wl-summary-buffer-disp-msg)
-         (if (eq wl-summary-move-direction-downward nil)
-             (unless (wl-summary-cursor-up)
-               (wl-summary-prev))
-           (unless (wl-summary-cursor-down)
-             (wl-summary-next)))
-         (wl-summary-message-number))))))
+  (or (wl-summary-next-message msg
+                              (if wl-summary-move-direction-downward 'down
+                                'up)
+                              nil)
+      (cadr (memq msg (if wl-summary-move-direction-downward
+                         wl-summary-buffer-number-list
+                       (reverse wl-summary-buffer-number-list))))))
 
 (defun wl-summary-save-current-message ()
   "Save current message for `wl-summary-yank-saved-message'."