(defvar dragdrop-drop-functions)
(defvar scrollbar-height)
(defvar mail-reply-buffer)
-(defvar elmo-global-flag-list)
+(defvar elmo-global-flags)
(defvar wl-summary-buffer-name "Summary")
(defvar wl-summary-mode-map nil)
(defvar wl-summary-buffer-line-format nil)
(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-header-mode 'partial)
+(defvar wl-summary-buffer-event-handler nil)
(defvar wl-thread-indent-level-internal nil)
(defvar wl-thread-have-younger-brother-str-internal nil)
(make-variable-buffer-local 'wl-summary-buffer-line-format)
(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-header-mode)
+(make-variable-buffer-local 'wl-summary-buffer-event-handler)
(defvar wl-datevec)
(defvar wl-thr-indent-string)
(if wl-summary-mode-map
()
- (setq wl-summary-mode-map (make-sparse-keymap))
+ (setq wl-summary-mode-map (make-keymap))
+ (suppress-keymap wl-summary-mode-map)
+ (substitute-key-definition 'kill-buffer
+ 'wl-summary-mimic-kill-buffer
+ wl-summary-mode-map
+ global-map)
+ ;; basic commands
(define-key wl-summary-mode-map " " 'wl-summary-read)
(define-key wl-summary-mode-map "." 'wl-summary-redisplay)
(define-key wl-summary-mode-map "<" 'wl-summary-display-top)
(define-key wl-summary-mode-map ">" 'wl-summary-display-bottom)
(define-key wl-summary-mode-map "\177" 'wl-summary-prev-page)
(define-key wl-summary-mode-map [backspace] 'wl-summary-prev-page)
- (define-key wl-summary-mode-map "\r" 'wl-summary-next-line-content)
- (define-key wl-summary-mode-map "\C-m" 'wl-summary-next-line-content)
+ (define-key wl-summary-mode-map "\r" 'wl-summary-enter-handler)
+ (define-key wl-summary-mode-map "\C-m" 'wl-summary-enter-handler)
(define-key wl-summary-mode-map "/" 'wl-thread-open-close)
(define-key wl-summary-mode-map "[" 'wl-thread-open-all)
(define-key wl-summary-mode-map "]" 'wl-thread-close-all)
(define-key wl-summary-mode-map "f" 'wl-summary-forward)
(define-key wl-summary-mode-map "$" 'wl-summary-mark-as-important)
(define-key wl-summary-mode-map "F" 'wl-summary-set-flags)
+ (define-key wl-summary-mode-map "\M-k" 'wl-summary-toggle-persistent-mark)
(define-key wl-summary-mode-map "&" 'wl-summary-mark-as-answered)
(define-key wl-summary-mode-map "@" 'wl-summary-edit-addresses)
(define-key wl-summary-mode-map "\C-c\C-a" 'wl-addrmgr)
(define-key wl-summary-mode-map "\C-c\C-p" 'wl-summary-previous-buffer)
(define-key wl-summary-mode-map "\C-c\C-n" 'wl-summary-next-buffer)
- (define-key wl-summary-mode-map "H" 'wl-summary-redisplay-all-header)
- (define-key wl-summary-mode-map "M" 'wl-summary-redisplay-no-mime)
+ (define-key wl-summary-mode-map "H" 'wl-summary-toggle-all-header)
+ (define-key wl-summary-mode-map "M" 'wl-summary-toggle-mime)
(define-key wl-summary-mode-map "B" 'wl-summary-burst)
(define-key wl-summary-mode-map "Z" 'wl-status-update)
(define-key wl-summary-mode-map "#" 'wl-summary-print-message)
"Menu used in Summary mode."
wl-summary-mode-menu-spec))
+(defun wl-summary-mimic-kill-buffer (buffer)
+ "Kill the current (Summary) buffer with query."
+ (interactive "bKill buffer: ")
+ (if (or (not buffer)
+ (string-equal buffer "")
+ (string-equal buffer (buffer-name)))
+ (wl-summary-exit 'force-exit)
+ (kill-buffer buffer)))
+
(defsubst wl-summary-message-visible-p (number)
"Return non-nil if the message with NUMBER is visible."
(or (eq wl-summary-buffer-view 'sequence)
(end (condition-case nil
(window-end win t) ; old emacsen doesn't support 2nd arg.
(error (window-end win))))
- number flags
- wl-summary-highlight)
+ number flags)
(save-excursion
(goto-char beg)
(while (and (< (point) end) (not (eobp)))
(when (null (get-text-property (point) 'face))
- (setq number (wl-summary-message-number)
- flags (elmo-message-flags wl-summary-buffer-elmo-folder
- number))
- (setq wl-summary-highlight nil)
- (wl-summary-update-persistent-mark number flags)
- (setq wl-summary-highlight t)
+ (setq number (wl-summary-message-number))
+ (when number
+ (setq flags (elmo-message-flags wl-summary-buffer-elmo-folder
+ number)))
+ (let (wl-summary-highlight)
+ (wl-summary-update-persistent-mark number flags))
(wl-highlight-summary-current-line number flags))
(forward-line 1)))))
(set-buffer-modified-p nil)))
(defun wl-summary-window-scroll-functions ()
- (cond ((and wl-summary-lazy-highlight
+ (cond ((and wl-summary-highlight
+ wl-summary-lazy-highlight
wl-summary-lazy-update-mark)
(list 'wl-summary-update-mark-and-highlight-window))
- (wl-summary-lazy-highlight
+ ((and wl-summary-highlight
+ wl-summary-lazy-highlight)
(list 'wl-highlight-summary-window))
(wl-summary-lazy-update-mark
(list 'wl-summary-update-mark-window))))
+(defun wl-summary-after-resize-function (frame)
+ "Called from `window-size-change-functions'."
+ (save-excursion
+ (save-selected-window
+ (select-frame frame)
+ (walk-windows
+ (lambda (window)
+ (set-buffer (window-buffer window))
+ (when (eq major-mode 'wl-summary-mode)
+ (run-hook-with-args 'wl-summary-buffer-window-scroll-functions
+ window)))
+ 'nomini frame))))
+
+;; Handler of event from elmo-folder
+(eval-and-compile
+ (luna-define-class wl-summary-event-handler (elmo-event-handler)
+ (buffer))
+ (luna-define-internal-accessors 'wl-summary-event-handler))
+
+(luna-define-method elmo-event-handler-flag-changed ((handler
+ wl-summary-event-handler)
+ numbers)
+ (save-excursion
+ (set-buffer (wl-summary-event-handler-buffer-internal handler))
+ (dolist (number numbers)
+ (when (and (wl-summary-message-visible-p number)
+ (wl-summary-jump-to-msg number))
+ (wl-summary-update-persistent-mark number)))))
+
+(defun wl-summary-buffer-detach ()
+ (when (and (eq major-mode 'wl-summary-mode)
+ wl-summary-buffer-elmo-folder
+ wl-summary-buffer-event-handler)
+ (elmo-folder-remove-handler wl-summary-buffer-elmo-folder
+ wl-summary-buffer-event-handler)))
+
(defun wl-status-update ()
(interactive)
(wl-address-init))
(wl-summary-redisplay)))
(defun wl-summary-count-unread ()
- (let ((lst (elmo-folder-count-flags wl-summary-buffer-elmo-folder)))
- (if (eq major-mode 'wl-summary-mode)
- (setq wl-summary-buffer-new-count (car lst)
- wl-summary-buffer-unread-count (nth 1 lst)
- wl-summary-buffer-answered-count (nth 2 lst)))
- lst))
+ (let ((flag-count (elmo-folder-count-flags wl-summary-buffer-elmo-folder)))
+ (setq wl-summary-buffer-new-count
+ (or (cdr (assq 'new flag-count)) 0)
+ wl-summary-buffer-unread-count
+ (or (cdr (assq 'unread flag-count)) 0)
+ wl-summary-buffer-answered-count
+ (or (cdr (assq 'answered flag-count)) 0))
+ flag-count))
(defun wl-summary-message-string (&optional use-cache)
"Return full body string of current message.
wl-summary-buffer-persistent-mark-column persistent)))
(defun wl-summary-buffer-set-folder (folder)
+ (wl-summary-buffer-detach)
(if (stringp folder)
(setq folder (wl-folder-get-elmo-folder folder)))
(setq wl-summary-buffer-elmo-folder folder)
(setq wl-summary-buffer-persistent
(wl-folder-persistent-p (elmo-folder-name-internal folder)))
(elmo-folder-set-persistent-internal folder wl-summary-buffer-persistent)
+ (elmo-folder-add-handler folder
+ (setq wl-summary-buffer-event-handler
+ (luna-make-entity
+ 'wl-summary-event-handler
+ :buffer (current-buffer))))
;; process duplicates.
(elmo-folder-set-process-duplicates-internal
folder (cdr (elmo-string-matched-assoc
;;;(setq default-directory (or wl-tmp-dir (expand-file-name "~/")))
(setq buffer-read-only t)
(setq truncate-lines t)
+ (when (boundp 'show-trailing-whitespace)
+ (setq show-trailing-whitespace nil))
;;;(make-local-variable 'tab-width)
;;;(setq tab-width 1)
(buffer-disable-undo (current-buffer))
(let ((hook (if wl-on-xemacs 'pre-idle-hook 'window-scroll-functions)))
(make-local-hook hook)
(dolist (function wl-summary-buffer-window-scroll-functions)
- (add-hook hook function nil t))))
+ (add-hook hook function nil t)))
+ (add-hook 'window-size-change-functions
+ #'wl-summary-after-resize-function))
+ (dolist (hook '(change-major-mode-hook kill-buffer-hook))
+ (make-local-hook hook)
+ (add-hook hook #'wl-summary-buffer-detach nil t))
;; This hook may contain the function `wl-setup-summary' for reasons
;; of system internal to accord facilities for the Emacs variants.
(run-hooks 'wl-summary-mode-hook))
(defun wl-summary-overview-entity-compare-by-from (x y)
"Compare entity X and Y by from."
(string<
- (wl-address-header-extract-address
- (or (elmo-message-entity-field x 'from t)
- wl-summary-no-from-message))
- (wl-address-header-extract-address
- (or (elmo-message-entity-field y 'from t)
- wl-summary-no-from-message))))
+ (or (elmo-message-entity-field x 'from t)
+ wl-summary-no-from-message)
+ (or (elmo-message-entity-field y 'from t)
+ wl-summary-no-from-message)))
(defun wl-summary-overview-entity-compare-by-subject (x y)
"Compare entity X and Y by subject."
(string< (or (car list-info-x) "")
(or (car list-info-y) "")))))
-(defun wl-summary-sort-by-date ()
- (interactive)
- (wl-summary-rescan "date"))
-(defun wl-summary-sort-by-number ()
- (interactive)
- (wl-summary-rescan "number"))
-(defun wl-summary-sort-by-subject ()
- (interactive)
- (wl-summary-rescan "subject"))
-(defun wl-summary-sort-by-from ()
- (interactive)
- (wl-summary-rescan "from"))
-(defun wl-summary-sort-by-list-info ()
- (interactive)
- (wl-summary-rescan "list-info"))
+(defun wl-summary-sort-by-date (reverse)
+ "Sort summary lines into the order by message date; argument means descending order."
+ (interactive "P")
+ (wl-summary-rescan "date" reverse))
+(defun wl-summary-sort-by-number (reverse)
+ "Sort summary lines into the order by message number; argument means descending order."
+ (interactive "P")
+ (wl-summary-rescan "number" reverse))
+(defun wl-summary-sort-by-subject (reverse)
+ "Sort summary lines into the order by subject; argument means descending order."
+ (interactive "P")
+ (wl-summary-rescan "subject" reverse))
+(defun wl-summary-sort-by-from (reverse)
+ "Sort summary lines into the order by from; argument means descending order."
+ (interactive "P")
+ (wl-summary-rescan "from" reverse))
+(defun wl-summary-sort-by-list-info (reverse)
+ "Sort summary lines into the order by mailing list info; argument means descending order."
+ (interactive "P")
+ (wl-summary-rescan "list-info" reverse))
+(defun wl-summary-sort-by-size (reverse)
+ "Sort summary lines into the order by message size; argument means descending order."
+ (interactive "P")
+ (wl-summary-rescan "size" reverse))
-(defun wl-summary-rescan (&optional sort-by disable-killed disable-thread)
+(defun wl-summary-rescan (&optional sort-by reverse disable-killed disable-thread)
"Rescan current folder without updating."
(interactive)
(let ((elmo-mime-charset wl-summary-buffer-mime-charset)
- i percent num
- gc-message entity
- curp
+ gc-message ; for XEmacs
(inhibit-read-only t)
(buffer-read-only nil)
(numbers (elmo-folder-list-messages wl-summary-buffer-elmo-folder
(and disable-thread wl-summary-search-parent-by-subject-regexp))
(wl-summary-divide-thread-when-subject-changed
(and disable-thread wl-summary-divide-thread-when-subject-changed))
+ (predicate (and sort-by
+ (intern (format "wl-summary-overview-entity-compare-by-%s"
+ sort-by))))
+ (sort-label (if reverse "Reverse sorting" "Sorting"))
+ (i 0)
+ num
expunged)
(erase-buffer)
(message "Re-scanning...")
- (setq i 0)
(when sort-by
- (message "Sorting by %s..." sort-by)
+ (message "%s by %s..." sort-label sort-by)
(setq numbers
(sort numbers
(lambda (x y)
(funcall
- (intern (format "wl-summary-overview-entity-compare-by-%s"
- sort-by))
+ predicate
(elmo-message-entity wl-summary-buffer-elmo-folder x)
(elmo-message-entity wl-summary-buffer-elmo-folder y)))))
- (message "Sorting by %s...done" sort-by))
+ (if reverse (setq numbers (nreverse numbers)))
+ (message "%s by %s...done" sort-label sort-by))
(setq num (length numbers))
(setq wl-thread-entity-hashtb (elmo-make-hash (* num 2))
wl-thread-entity-list nil
wl-summary-delayed-update nil)
(elmo-kill-buffer wl-summary-search-buf-name)
(while numbers
- (setq entity (elmo-message-entity wl-summary-buffer-elmo-folder
- (car numbers)))
- (wl-summary-insert-message entity
+ (wl-summary-insert-message (elmo-message-entity
+ wl-summary-buffer-elmo-folder
+ (car numbers))
wl-summary-buffer-elmo-folder
nil)
(setq numbers (cdr numbers))
(defun wl-summary-thread-modified-p ()
wl-summary-buffer-thread-modified)
-(defun wl-summary-cleanup-temp-marks (&optional sticky)
+(defun wl-summary-exec-with-confirmation (&optional message)
(when wl-summary-buffer-temp-mark-list
- (if (y-or-n-p (format "Execute remaining marks in %s before cleanup? "
- (wl-summary-buffer-folder-name)))
+ (if (y-or-n-p (or message
+ (format "Execute marks in %s? "
+ (wl-summary-buffer-folder-name))))
(progn
(wl-summary-exec)
(if wl-summary-buffer-temp-mark-list
(error "Some execution was failed")))
;; temp-mark-list is remained.
- (message "")))
- (wl-summary-delete-all-temp-marks 'no-msg)
- (setq wl-summary-scored nil))
+ (message ""))))
+
+(defun wl-summary-cleanup-temp-marks ()
+ (when wl-summary-buffer-temp-mark-list
+ (wl-summary-exec-with-confirmation
+ (format "Execute marks in %s? (answer \"n\" to discard them) "
+ (wl-summary-buffer-folder-name)))
+ (wl-summary-delete-all-temp-marks 'no-msg)
+ (setq wl-summary-scored nil)))
;; a subroutine for wl-summary-exit/wl-save-status
;; Note that folder is not commited here.
(if wl-summary-buffer-exit-function
(funcall wl-summary-buffer-exit-function)
(if (or force-exit (not sticky))
- (wl-summary-cleanup-temp-marks sticky))
+ (wl-summary-cleanup-temp-marks))
(unwind-protect
;; save summary status
(progn
nil
wl-use-scoring)))
(wl-summary-rescan nil
+ nil
(string-match "noscore" range)
(string-match "thread" range))
(and msg (wl-summary-jump-to-msg msg))))
(wl-summary-prefetch-region-no-mark (point-min) (point-max)
wl-summary-incorporate-marks))
+(defun wl-summary-force-prefetch ()
+ "All uncached messages are cached."
+ (interactive)
+ (unless (elmo-folder-local-p wl-summary-buffer-elmo-folder)
+ (let ((targets (elmo-folder-list-flagged wl-summary-buffer-elmo-folder
+ 'uncached 'in-msgdb))
+ (count 0)
+ wl-prefetch-confirm
+ wl-prefetch-threshold
+ (elmo-inhibit-display-retrieval-progress t)
+ length msg)
+ (save-excursion
+ (goto-char (point-min))
+ (setq length (length targets))
+ (dolist (target targets)
+ (when (if (not (wl-thread-entity-parent-invisible-p
+ (wl-thread-get-entity target)))
+ (progn
+ (wl-summary-jump-to-msg target)
+ (wl-summary-prefetch-msg
+ (wl-summary-message-number)))
+ (wl-summary-prefetch-msg target))
+ (message "Retrieving... %d/%d" (incf count) length)))
+ (message "Retrieved %d/%d message(s)" count length)))))
+
(defun wl-summary-prefetch-msg (number &optional arg)
"Prefetch message and return non-nil value. If skipped, return nil."
;; prefetching procedure.
(wl-summary-update-modeline)
(wl-folder-update-unread
(wl-summary-buffer-folder-name)
- (+ wl-summary-buffer-unread-count
- wl-summary-buffer-new-count))))
+ wl-summary-buffer-unread-count)))
t)
nil)))))
(defun wl-summary-delete-all-target-marks ()
(wl-summary-delete-marks-on-buffer wl-summary-buffer-target-mark-list))
-(defun wl-summary-mark-as-read-region (beg end)
- (interactive "r")
+(defun wl-summary-number-list-from-region (beg end)
(save-excursion
(save-restriction
(wl-summary-narrow-to-region beg end)
(goto-char (point-min))
- (if (eq wl-summary-buffer-view 'thread)
- (let (number-list)
+ (let (number-list)
+ (if (eq wl-summary-buffer-view 'thread)
(while (not (eobp))
(let* ((number (wl-summary-message-number))
(entity (wl-thread-get-entity number)))
- (if (wl-thread-entity-get-opened entity)
- (setq number-list (append number-list (list number)))
- (setq number-list
- (append number-list
- (wl-thread-get-children-msgs number))))
+ (setq number-list
+ (nconc number-list
+ (if (wl-thread-entity-get-opened entity)
+ (list number)
+ (wl-thread-get-children-msgs number))))
(forward-line 1)))
- (wl-summary-mark-as-read number-list))
- (let (number-list)
(while (not (eobp))
(setq number-list
- (append number-list (list (wl-summary-message-number))))
- (forward-line 1))
- (wl-summary-mark-as-read number-list))))))
+ (nconc number-list (list (wl-summary-message-number))))
+ (forward-line 1)))
+ number-list))))
-(defun wl-summary-mark-as-unread-region (beg end)
+(defun wl-summary-mark-as-read-region (beg end)
(interactive "r")
- (save-excursion
- (save-restriction
- (wl-summary-narrow-to-region beg end)
- (goto-char (point-min))
- (if (eq wl-summary-buffer-view 'thread)
- (let (number-list)
- (while (not (eobp))
- (let* ((number (wl-summary-message-number))
- (entity (wl-thread-get-entity number)))
- (if (wl-thread-entity-get-opened entity)
- (setq number-list (append number-list (list number)))
- (setq number-list
- (append number-list
- (wl-thread-get-children-msgs number))))
- (forward-line 1)))
- (wl-summary-mark-as-unread number-list))
- (let (number-list)
- (while (not (eobp))
- (setq number-list
- (append number-list (list (wl-summary-message-number))))
- (forward-line 1))
- (wl-summary-mark-as-unread number-list))))))
+ (let ((number-list (wl-summary-number-list-from-region beg end)))
+ (if (null number-list)
+ (message "No message.")
+ (wl-summary-mark-as-read number-list))))
-(defun wl-summary-set-flags-region (beg end)
+(defun wl-summary-mark-as-unread-region (beg end)
(interactive "r")
- (save-excursion
- (save-restriction
- (wl-summary-narrow-to-region beg end)
- (goto-char (point-min))
- (let (flags)
- (if (eq wl-summary-buffer-view 'thread)
- (while (not (eobp))
- (let* ((number (wl-summary-message-number))
- (entity (wl-thread-get-entity number))
- children)
- (if (wl-thread-entity-get-opened entity)
- ;; opened...mark line.
- ;; Crossposts are not processed
- (setq flags (wl-summary-set-flags-internal
- number
- flags))
- ;; closed
- (setq flags (wl-summary-set-flags-internal
- (wl-thread-get-children-msgs number)
- flags)))
- (forward-line 1)))
- (while (not (eobp))
- (setq flags (wl-summary-set-flags-internal
- (wl-summary-message-number) flags))
- (forward-line 1))))))
- (wl-summary-count-unread)
- (wl-summary-update-modeline))
+ (let ((number-list (wl-summary-number-list-from-region beg end)))
+ (if (null number-list)
+ (message "No message.")
+ (wl-summary-mark-as-unread number-list))))
-(defun wl-summary-mark-as-answered-region (beg end)
- (interactive "r")
- (save-excursion
- (save-restriction
- (wl-summary-narrow-to-region beg end)
- (goto-char (point-min))
- (let ((inverse (elmo-message-flagged-p wl-summary-buffer-elmo-folder
- (wl-summary-message-number)
- 'answered)))
- (if (eq wl-summary-buffer-view 'thread)
- (while (not (eobp))
- (let* ((number (wl-summary-message-number))
- (entity (wl-thread-get-entity number))
- children)
- (if (wl-thread-entity-get-opened entity)
- ;; opened...mark line.
- ;; Crossposts are not processed
- (wl-summary-mark-as-answered-internal inverse)
- ;; closed
- (wl-summary-mark-as-answered-internal
- inverse
- (wl-thread-get-children-msgs number)))
- (forward-line 1)))
- (while (not (eobp))
- (wl-summary-mark-as-answered-internal inverse)
- (forward-line 1))))))
- (wl-summary-count-unread)
- (wl-summary-update-modeline))
+(defun wl-summary-set-flags-region (beg end &optional remove)
+ (interactive "r\nP")
+ (let ((number-list (wl-summary-number-list-from-region beg end)))
+ (if (null number-list)
+ (message "No message.")
+ (wl-summary-set-flags-internal number-list nil nil remove)
+ (wl-summary-count-unread)
+ (wl-summary-update-modeline))))
-(defun wl-summary-mark-as-important-region (beg end)
- (interactive "r")
- (save-excursion
- (save-restriction
- (wl-summary-narrow-to-region beg end)
- (goto-char (point-min))
- (let ((inverse (elmo-message-flagged-p wl-summary-buffer-elmo-folder
- (wl-summary-message-number)
- 'important)))
- (if (eq wl-summary-buffer-view 'thread)
- (while (not (eobp))
- (let* ((number (wl-summary-message-number))
- (entity (wl-thread-get-entity number))
- children)
- (if (wl-thread-entity-get-opened entity)
- ;; opened...mark line.
- ;; Crossposts are not processed
- (wl-summary-mark-as-important-internal inverse)
- ;; closed
- (wl-summary-mark-as-important-internal
- inverse
- (wl-thread-get-children-msgs number)))
- (forward-line 1)))
- (while (not (eobp))
- (wl-summary-mark-as-important-internal inverse)
- (forward-line 1))))))
- (wl-summary-count-unread)
- (wl-summary-update-modeline))
+(defun wl-summary-mark-as-answered-region (beg end &optional remove)
+ (interactive "r\nP")
+ (let ((number-list (wl-summary-number-list-from-region beg end))
+ (remove (or remove
+ (elmo-message-flagged-p wl-summary-buffer-elmo-folder
+ (save-excursion
+ (goto-char beg)
+ (wl-summary-message-number))
+ 'answered))))
+ (if (null number-list)
+ (message "No message.")
+ (wl-summary-set-persistent-mark-internal remove 'answered
+ number-list
+ nil nil (interactive-p))
+ (wl-summary-count-unread)
+ (wl-summary-update-modeline))))
+
+(defun wl-summary-mark-as-important-region (beg end &optional remove)
+ (interactive "r\nP")
+ (let ((number-list (wl-summary-number-list-from-region beg end))
+ (remove (or remove
+ (elmo-message-flagged-p wl-summary-buffer-elmo-folder
+ (save-excursion
+ (goto-char beg)
+ (wl-summary-message-number))
+ 'important))))
+ (if (null number-list)
+ (message "No message.")
+ (wl-summary-set-persistent-mark-internal remove 'important number-list
+ nil nil (interactive-p))
+ (wl-summary-count-unread)
+ (wl-summary-update-modeline))))
(defun wl-summary-mark-as-read-all ()
(interactive)
(let ((folder wl-summary-buffer-elmo-folder)
(cur-buf (current-buffer)))
(message "Setting all msgs as read...")
- (elmo-folder-set-flag
+ (elmo-folder-unset-flag
folder
(elmo-folder-list-flagged folder 'unread 'in-msgdb)
- 'read)
- (save-excursion
- (goto-char (point-min))
- (while (not (eobp))
- (wl-summary-update-persistent-mark)
- (forward-line 1)))
+ 'unread)
(wl-folder-update-unread (wl-summary-buffer-folder-name) 0)
(setq wl-summary-buffer-unread-count 0)
(setq wl-summary-buffer-new-count 0)
(apply 'wl-summary-insert-thread args)
(apply 'wl-summary-insert-sequential args)))
-(defun wl-summary-sort ()
- (interactive)
+(defun wl-summary-sort (reverse)
+ "Sort summary lines into the selected order; argument means descending order."
+ (interactive "P")
(wl-summary-rescan
(completing-read
- (format "Sort by (%s): " (symbol-name wl-summary-default-sort-spec))
+ (format "%s by (%s): "
+ (if reverse "Reverse sort" "Sort")
+ (symbol-name wl-summary-default-sort-spec))
(mapcar (lambda (spec)
(list (symbol-name spec)))
wl-summary-sort-specs)
- nil t nil nil (symbol-name wl-summary-default-sort-spec))))
+ nil t nil nil (symbol-name wl-summary-default-sort-spec))
+ reverse))
+
+(defun wl-summary-get-available-flags (&optional include-specials)
+ (let ((flags (elmo-uniq-list
+ (append elmo-global-flags
+ (copy-sequence elmo-preserved-flags))
+ #'delq)))
+ (if include-specials
+ flags
+ (delq 'new (delq 'cached flags)))))
(defun wl-summary-sync-marks ()
"Update persistent marks in summary."
(interactive)
(let ((mes "Updated ")
diff diffs)
- ;; synchronize marks.
- (when (not (eq (elmo-folder-type-internal
- wl-summary-buffer-elmo-folder)
- 'internal))
-
- (message "Updating marks...")
- (dolist (flag elmo-global-flag-list)
- (unless (memq flag '(answered cached new unread))
- (setq diff (elmo-list-diff (elmo-folder-list-flagged
- wl-summary-buffer-elmo-folder
- flag)
- (elmo-folder-list-flagged
- wl-summary-buffer-elmo-folder
- flag 'in-msgdb)))
- (setq diffs (cadr diff)) ; deletes
- (setq mes (concat mes (format "-%d" (length diffs))))
- (while diffs
- (wl-summary-remove-flags-internal (car diffs)
- (list flag) 'no-server)
- (setq diffs (cdr diffs)))
- (setq diffs (car diff)) ; appends
- (setq mes (concat mes (format "/+%d %s," (length diffs) flag)))
- (while diffs
- (wl-summary-add-flags-internal (car diffs)
- (list flag) 'no-server)
- (setq diffs (cdr diffs)))))
-
- (setq diff (elmo-list-diff (elmo-folder-list-flagged
- wl-summary-buffer-elmo-folder
- 'answered)
- (elmo-folder-list-flagged
- wl-summary-buffer-elmo-folder
- 'answered 'in-msgdb)))
- (setq diffs (cadr diff))
- (setq mes (concat mes (format "-%d" (length diffs))))
- (while diffs
- (wl-summary-mark-as-unanswered (car diffs) 'no-modeline)
- (setq diffs (cdr diffs)))
- (setq diffs (car diff)) ; unread-appends
- (setq mes (concat mes (format "/+%d answered," (length diffs))))
- (while diffs
- (wl-summary-mark-as-answered (car diffs) 'no-modeline)
- (setq diffs (cdr diffs)))
-
+ (message "Updating marks...")
+ (dolist (flag (wl-summary-get-available-flags))
(setq diff (elmo-list-diff (elmo-folder-list-flagged
wl-summary-buffer-elmo-folder
- 'unread)
+ flag)
(elmo-folder-list-flagged
wl-summary-buffer-elmo-folder
- 'unread 'in-msgdb)))
+ flag 'in-msgdb)))
(setq diffs (cadr diff))
(setq mes (concat mes (format "-%d" (length diffs))))
- (while diffs
- (wl-summary-mark-as-read (car diffs) 'no-folder 'no-modeline)
- (setq diffs (cdr diffs)))
- (setq diffs (car diff)) ; unread-appends
- (setq mes (concat mes (format "/+%d unread." (length diffs))))
- (while diffs
- (wl-summary-mark-as-unread (car diffs) 'no-folder 'no-modeline)
- (setq diffs (cdr diffs)))
- (if (interactive-p) (message "%s" mes)))))
+ (when diffs
+ (wl-summary-unset-persistent-mark flag diffs 'no-modeline 'no-server))
+ (setq diffs (car diff)
+ mes (concat mes (format "/+%d %s " (length diffs) flag)))
+ (when diffs
+ (wl-summary-set-persistent-mark flag diffs 'no-modeline 'no-server)))
+ (if (interactive-p) (message "%s" mes))))
(defun wl-summary-sync-update (&optional unset-cursor
disable-killed
(elmo-mime-charset wl-summary-buffer-mime-charset)
(inhibit-read-only t)
(buffer-read-only nil)
- gc-message
- overview
- curp num i diff
- append-list delete-list crossed
- update-thread update-top-list
- expunged mes entity)
+ gc-message ; for XEmacs
+ crossed expunged mes)
(unwind-protect
(progn
(unless wl-summary-buffer-elmo-folder
sync-all
no-check))
(if crossed
- (progn
+ (let ((wl-summary-highlight
+ (and wl-summary-highlight
+ (not wl-summary-lazy-highlight)))
+ append-list delete-list
+ update-thread update-top-list
+ num diff entity
+ (i 0))
;; Setup sync-all
(if sync-all (wl-summary-sync-all-init))
(setq diff (elmo-list-diff (elmo-folder-list-messages
(when (and wl-summary-lazy-highlight
wl-summary-lazy-update-mark)
(let (buffer-read-only)
- (put-text-property (point-min) (point-max) 'face nil))
- (run-hooks 'wl-summary-buffer-window-scroll-functions))
+ (put-text-property (point-min) (point-max) 'face nil)))
(setq num (length append-list))
- (setq i 0)
(setq wl-summary-delayed-update nil)
(elmo-kill-buffer wl-summary-search-buf-name)
(dolist (number append-list)
(wl-folder-set-folder-updated
(elmo-folder-name-internal folder)
(list 0
- (let ((lst (wl-summary-count-unread)))
- (+ (car lst) (nth 1 lst)))
+ (or (cdr (assq 'unread (wl-summary-count-unread))) 0)
(elmo-folder-length folder)))
(wl-summary-update-modeline)
;;
(progn
(goto-char (point-max))
(forward-line -1))
- (if (and wl-summary-highlight
- (not wl-summary-lazy-highlight)
- (not (get-text-property (point) 'face)))
- (save-excursion
- (forward-line (- 0
- (or
- wl-summary-partial-highlight-above-lines
- wl-summary-highlight-partial-threshold)))
- (wl-highlight-summary (point) (point-max))))))
+ (when (and wl-summary-highlight
+ (not wl-summary-lazy-highlight)
+ (not (get-text-property (point) 'face)))
+ (save-excursion
+ (forward-line (- 0
+ (or
+ wl-summary-partial-highlight-above-lines
+ wl-summary-highlight-partial-threshold)))
+ (wl-highlight-summary (point) (point-max))))))
(wl-delete-all-overlays)
+ (run-hooks 'wl-summary-buffer-window-scroll-functions)
(set-buffer-modified-p nil)
(if mes (message "%s" mes)))))
(funcall wl-summary-buffer-mode-line-formatter)))
(defun wl-summary-jump-to-msg (&optional number)
- (interactive)
+ (interactive "NJump to Number:")
(let ((num (or number
(string-to-int
(read-from-minibuffer "Jump to Message(No.): ")))))
(setq wl-summary-buffer-view 'thread))
(wl-summary-update-modeline)
(force-mode-line-update)
- (wl-summary-rescan nil nil t)))
+ (wl-summary-rescan nil nil nil t)))
(defun wl-summary-load-file-object (filename)
"Load lisp object from dir."
(setq wl-summary-last-visited-folder (wl-summary-buffer-folder-name))
(run-hooks 'wl-summary-exit-pre-hook)
(if (or force-exit (not (wl-summary-sticky-p)))
- (wl-summary-cleanup-temp-marks (wl-summary-sticky-p)))
+ (wl-summary-cleanup-temp-marks))
(wl-summary-save-view)
(elmo-folder-commit wl-summary-buffer-elmo-folder)
(if (and (wl-summary-sticky-p) force-exit)
(unless (eq major-mode 'wl-summary-mode)
(wl-summary-mode))
(wl-summary-buffer-set-folder folder)
+ (setq wl-summary-buffer-display-mime-mode
+ (if (wl-summary-no-mime-p wl-summary-buffer-elmo-folder)
+ 'as-is
+ 'mime))
(setq wl-summary-buffer-disp-msg nil)
(setq wl-summary-buffer-last-displayed-msg nil)
(setq wl-summary-buffer-current-msg nil)
(when (and wl-summary-buffer-window-scroll-functions
wl-on-xemacs)
(sit-for 0))
+ (when (or (eq t wl-summary-force-prefetch-folder-list)
+ (wl-string-match-member
+ (elmo-folder-name-internal wl-summary-buffer-elmo-folder)
+ wl-summary-force-prefetch-folder-list))
+ (wl-summary-force-prefetch))
(unwind-protect
(run-hooks 'wl-summary-prepared-hook)
(set-buffer-modified-p nil))
(defun wl-summary-default-subject-filter (subject)
(setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\)[:>]" ""))
(setq subject (elmo-replace-in-string subject "[ \t]" ""))
- (elmo-replace-in-string subject "^\\[.*\\]" ""))
+ (elmo-replace-in-string subject "^\\[[^]]*\\]" ""))
(defun wl-summary-subject-equal (subject1 subject2)
(string= (funcall wl-summary-subject-filter-function subject1)
i))
(defun wl-summary-pick (&optional from-list delete-marks)
- (interactive)
+ (interactive "i\nP")
(save-excursion
- (let* ((condition (car (elmo-parse-search-condition
+ (let* ((messages (or from-list
+ (elmo-folder-list-messages
+ wl-summary-buffer-elmo-folder
+ 'visible
+ 'in-msgdb)
+ (error "No messages")))
+ (condition (car (elmo-parse-search-condition
(elmo-read-search-condition
wl-summary-pick-field-default))))
(result (elmo-folder-search wl-summary-buffer-elmo-folder
condition
- from-list))
+ messages))
num)
(if delete-marks
(let ((mlist wl-summary-buffer-target-mark-list))
(setq mark wl-summary-flag-mark)))
(when (memq (car priorities) flags)
(setq mark
- (or (case (car priorities)
- (new
- (if cached
- wl-summary-new-cached-mark
- wl-summary-new-uncached-mark))
- (answered
- (if cached
- wl-summary-answered-cached-mark
- wl-summary-answered-uncached-mark))
- (unread
- (if cached
- wl-summary-unread-cached-mark
- wl-summary-unread-uncached-mark)))))))
+ (let ((var
+ (intern
+ (if cached
+ (format
+ "wl-summary-%s-cached-mark" (car priorities))
+ (format
+ "wl-summary-%s-uncached-mark" (car priorities))))))
+ (if (and (boundp var)
+ (symbol-value var))
+ (symbol-value var)
+ (if cached
+ (downcase (substring (symbol-name (car priorities))
+ 0 1))
+ (upcase (substring (symbol-name (car priorities))
+ 0 1))))))))
(setq priorities (cdr priorities)))
(or mark
(if (or cached (elmo-folder-local-p folder))
nil
- wl-summary-read-uncached-mark))))
+ wl-summary-uncached-mark))))
(defsubst wl-summary-message-mark (folder number &optional flags)
"Return mark of the message."
(or (cadr (memq (current-buffer) buffers))
(car buffers)))))
+(defun wl-summary-check-target-mark ()
+ (when (null wl-summary-buffer-target-mark-list)
+ (error "No marked message")))
+
(defun wl-summary-target-mark-mark-as-read ()
(interactive)
+ (wl-summary-check-target-mark)
(save-excursion
(goto-char (point-min))
(let ((inhibit-read-only t)
(defun wl-summary-target-mark-mark-as-unread ()
(interactive)
+ (wl-summary-check-target-mark)
(save-excursion
(goto-char (point-min))
(let ((inhibit-read-only t)
(dolist (number wl-summary-buffer-target-mark-list)
(wl-summary-unset-mark number)))))
-(defun wl-summary-target-mark-operation (flag)
+(defun wl-summary-target-mark-operation (flag &optional inverse)
+ (wl-summary-check-target-mark)
(save-excursion
- (goto-char (point-min))
(let ((inhibit-read-only t)
(buffer-read-only nil)
wl-summary-buffer-disp-msg)
(funcall
(intern (format "wl-summary-mark-as-%s-internal" flag))
- nil
+ inverse
wl-summary-buffer-target-mark-list)
- (dolist (number wl-summary-buffer-target-mark-list)
- (wl-summary-unset-mark number)))))
+ (wl-summary-delete-all-target-marks))))
-(defun wl-summary-target-mark-mark-as-important ()
- (interactive)
- (wl-summary-target-mark-operation 'important))
+(defun wl-summary-target-mark-mark-as-important (&optional remove)
+ (interactive "P")
+ (wl-summary-target-mark-operation 'important remove))
-(defun wl-summary-target-mark-mark-as-answered ()
- (interactive)
- (wl-summary-target-mark-operation 'answered))
+(defun wl-summary-target-mark-mark-as-answered (&optional remove)
+ (interactive "P")
+ (wl-summary-target-mark-operation 'answered remove))
-(defun wl-summary-target-mark-set-flags ()
- (interactive)
+(defun wl-summary-target-mark-set-flags (&optional remove)
+ (interactive "P")
+ (wl-summary-check-target-mark)
(save-excursion
- (goto-char (point-min))
(let ((inhibit-read-only t)
(buffer-read-only nil)
- wl-summary-buffer-disp-msg
- flags)
- (dolist (number wl-summary-buffer-target-mark-list)
- (wl-summary-unset-mark number)
- (setq flags (wl-summary-set-flags-internal number flags)))
+ wl-summary-buffer-disp-msg)
+ (wl-summary-set-flags-internal wl-summary-buffer-target-mark-list
+ nil nil remove)
+ (wl-summary-delete-all-target-marks)
(wl-summary-count-unread)
(wl-summary-update-modeline))))
(defun wl-summary-target-mark-save ()
(interactive)
+ (wl-summary-check-target-mark)
(let ((wl-save-dir
(wl-read-directory-name "Save to directory: "
wl-temporary-file-directory))
(defun wl-summary-target-mark-pick ()
(interactive)
+ (wl-summary-check-target-mark)
(wl-summary-pick wl-summary-buffer-target-mark-list 'delete))
(defun wl-summary-update-persistent-mark (&optional number flags)
"Synch up persistent mark of current line with msgdb's.
Return non-nil if the mark is updated"
+ (interactive)
(prog1
(when wl-summary-buffer-persistent-mark-column
(save-excursion
(save-excursion
(let ((folder wl-summary-buffer-elmo-folder)
unread-message number
- number-list visible)
+ number-list)
(setq number-list (cond ((numberp number-or-numbers)
(setq unread-message
(elmo-message-flagged-p
(if (null number-list)
(message "No message.")
(if inverse
- (elmo-folder-unset-flag folder number-list 'read no-folder-mark)
- (elmo-folder-set-flag folder number-list 'read no-folder-mark))
- (dolist (number number-list)
- (setq visible (wl-summary-jump-to-msg number))
- (unless inverse
- (when unread-message
- (run-hooks 'wl-summary-unread-message-hook)))
- ;; set mark on buffer
- (when visible
- (wl-summary-update-persistent-mark)))
+ (elmo-folder-set-flag folder number-list 'unread no-folder-mark)
+ (elmo-folder-unset-flag folder number-list 'unread no-folder-mark))
+ (when (and unread-message
+ (not inverse))
+ (dolist (number number-list)
+ (wl-summary-jump-to-msg number)
+ (run-hooks 'wl-summary-unread-message-hook)))
(unless no-modeline-update
;; Update unread numbers.
(wl-summary-count-unread)
(wl-summary-update-modeline)
(wl-folder-update-unread
(wl-summary-buffer-folder-name)
- (+ wl-summary-buffer-unread-count
- wl-summary-buffer-new-count)))))))
+ wl-summary-buffer-unread-count))))))
(defun wl-summary-mark-as-read (&optional number-or-numbers
no-folder-mark
no-folder-mark
no-modeline-update))
-(defsubst wl-summary-mark-as-answered-internal (inverse
- &optional
- number-or-numbers
- no-modeline-update)
+(defsubst wl-summary-set-persistent-mark-internal (inverse
+ flag
+ &optional number-or-numbers
+ no-modeline-update
+ no-server
+ interactive)
+ "Set persistent mark."
(save-excursion
(let ((folder wl-summary-buffer-elmo-folder)
- number number-list visible)
+ number number-list)
(setq number-list (cond ((numberp number-or-numbers)
(list number-or-numbers))
((and (not (null number-or-numbers))
(list number))))
(if (null number-list)
(message "No message.")
- (if inverse
- (elmo-folder-unset-flag folder number-list 'answered)
- (elmo-folder-set-flag folder number-list 'answered))
- (dolist (number number-list)
- (setq visible (wl-summary-jump-to-msg number))
- ;; set mark on buffer
- (when visible
- (wl-summary-update-persistent-mark)))
- (unless no-modeline-update
- ;; Update unread numbers.
- ;; should elmo-flag-mark-as-read return unread numbers?
- (wl-summary-count-unread)
- (wl-summary-update-modeline)
- (wl-folder-update-unread
- (wl-summary-buffer-folder-name)
- (+ wl-summary-buffer-unread-count
- wl-summary-buffer-new-count)))))))
+ ;; XXX Only the first element of the list is checked.
+ (if (elmo-message-flag-available-p folder (car number-list) flag)
+ (progn
+ (if inverse
+ (elmo-folder-unset-flag folder number-list flag no-server)
+ (elmo-folder-set-flag folder number-list flag no-server))
+ (unless no-modeline-update
+ ;; Update unread numbers.
+ ;; should elmo-flag-mark-as-read return unread numbers?
+ (wl-summary-count-unread)
+ (wl-summary-update-modeline)
+ (wl-folder-update-unread
+ (wl-summary-buffer-folder-name)
+ wl-summary-buffer-unread-count)))
+ (if interactive
+ (error "Flag `%s' is not available in this folder" flag)))))))
+
+(defun wl-summary-unset-persistent-mark (&optional flag
+ number-or-numbers
+ no-modeline-update
+ no-server)
+ "Unset persistent mark."
+ (interactive)
+ (when (interactive-p)
+ (let ((completion-ignore-case t))
+ (setq flag (intern (downcase
+ (completing-read
+ "Mark name: "
+ (mapcar (lambda (flag)
+ (list (capitalize (symbol-name flag))))
+ (wl-summary-get-available-flags))
+ nil
+ 'require-match))))))
+ (wl-summary-set-persistent-mark-internal 'inverse
+ flag
+ number-or-numbers
+ no-modeline-update
+ no-server
+ (interactive-p)))
+
+(defun wl-summary-set-persistent-mark (&optional flag
+ number-or-numbers
+ no-modeline-update
+ no-server)
+ "Set persistent mark."
+ (interactive)
+ (when (interactive-p)
+ (let ((completion-ignore-case t))
+ (setq flag (intern (downcase
+ (completing-read
+ "Mark name: "
+ (mapcar (lambda (flag)
+ (list (capitalize (symbol-name flag))))
+ (wl-summary-get-available-flags))
+ nil
+ 'require-match))))))
+ (wl-summary-set-persistent-mark-internal nil
+ flag
+ number-or-numbers
+ no-modeline-update
+ no-server
+ (interactive-p)))
+
+(defun wl-summary-toggle-persistent-mark (&optional force)
+ "Toggle persistent mark."
+ (interactive "P")
+ (let ((completion-ignore-case t)
+ flag)
+ (setq flag (intern (downcase
+ (completing-read
+ "Mark name: "
+ (mapcar (lambda (flag)
+ (list (capitalize (symbol-name flag))))
+ (wl-summary-get-available-flags))
+ nil
+ 'require-match))))
+ (if (and (elmo-message-flagged-p wl-summary-buffer-elmo-folder
+ (wl-summary-message-number)
+ flag)
+ (not force))
+ (wl-summary-unset-persistent-mark flag)
+ (wl-summary-set-persistent-mark flag))))
(defun wl-summary-mark-as-answered (&optional number-or-numbers
no-modeline-update)
(interactive)
- (wl-summary-mark-as-answered-internal
+ (wl-summary-set-persistent-mark-internal
(and (interactive-p)
(elmo-message-flagged-p wl-summary-buffer-elmo-folder
(wl-summary-message-number)
'answered))
+ 'answered
number-or-numbers
- no-modeline-update))
+ no-modeline-update
+ nil
+ (interactive-p)))
(defun wl-summary-mark-as-unanswered (&optional number-or-numbers
no-modeline-update)
- (wl-summary-mark-as-answered-internal 'inverse
- number-or-numbers
- no-modeline-update))
+ (wl-summary-set-persistent-mark-internal
+ 'inverse
+ 'answered
+ number-or-numbers
+ no-modeline-update))
(defun wl-summary-decide-flag (folder number)
(let ((flags (elmo-get-global-flags (elmo-message-flags
"Flags: "
(mapcar (lambda (flag)
(list (capitalize (symbol-name flag))))
- elmo-global-flag-list)
+ elmo-global-flags)
nil nil (mapconcat (lambda (flag)
(capitalize (symbol-name flag)))
flags
",")))))
(dolist (flag new-flags)
- (unless (memq flag elmo-global-flag-list)
- (if (y-or-n-p (format "Flag `%s' does not exist yet. Create?"
+ (unless (memq flag elmo-global-flags)
+ (when (elmo-local-flag-p flag)
+ (error "Cannot treat `%s'." flag))
+ (if (y-or-n-p (format "Flag `%s' is not registered yet. Register?"
(capitalize (symbol-name flag))))
- (setq elmo-global-flag-list (append
- elmo-global-flag-list
- (list flag)))
+ (setq elmo-global-flags (append
+ elmo-global-flags
+ (list flag)))
(error "Stopped"))))
new-flags))
remove-all)
(save-excursion
(let ((folder wl-summary-buffer-elmo-folder)
- number number-list visible)
+ number number-list)
(setq number-list (cond ((numberp number-or-numbers)
(list number-or-numbers))
((and (not (null number-or-numbers))
(if (null number-list)
(message "No message.")
(dolist (number number-list)
- (elmo-message-set-global-flags folder number flags local)
- (setq visible (wl-summary-jump-to-msg number))
- ;; set mark on buffer
- (when visible
- (wl-summary-update-persistent-mark))))
+ (elmo-message-set-global-flags folder number flags local)))
flags)))
-(defsubst wl-summary-add-flags-internal (&optional
- number-or-numbers
- flags
- local)
- (save-excursion
- (let ((folder wl-summary-buffer-elmo-folder)
- set-flags msg number-list visible)
- (setq number-list (cond ((numberp number-or-numbers)
- (list number-or-numbers))
- ((and (not (null number-or-numbers))
- (listp number-or-numbers))
- number-or-numbers)
- ((setq msg (wl-summary-message-number))
- ;; interactive
- (list msg))))
- (if (null number-list)
- (message "No message.")
- (dolist (number number-list)
- (setq set-flags
- (elmo-get-global-flags
- (elmo-message-flags folder number)))
- (setq set-flags (nconc flags set-flags))
- (elmo-message-set-global-flags folder number set-flags local)
- (setq visible (wl-summary-jump-to-msg number))
- ;; set mark on buffer
- (when visible
- (wl-summary-update-persistent-mark)))))))
-
-(defsubst wl-summary-remove-flags-internal (&optional
- number-or-numbers
- flags
- local)
- (save-excursion
- (let ((folder wl-summary-buffer-elmo-folder)
- set-flags msg number-list visible)
- (setq number-list (cond ((numberp number-or-numbers)
- (list number-or-numbers))
- ((and (not (null number-or-numbers))
- (listp number-or-numbers))
- number-or-numbers)
- ((setq msg (wl-summary-message-number))
- ;; interactive
- (list msg))))
- (if (null number-list)
- (message "No message.")
- (dolist (number number-list)
- (setq set-flags (elmo-get-global-flags
- (elmo-message-flags folder number)))
- (dolist (flag flags)
- (setq set-flags (delq flag set-flags)))
- (elmo-message-set-global-flags folder number set-flags local)
- (setq visible (wl-summary-jump-to-msg number))
- ;; set mark on buffer
- (when visible
- (wl-summary-update-persistent-mark)))))))
-
(defun wl-summary-set-flags (&optional remove)
(interactive "P")
- (if (eq 'flag (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
- (error "Cannot process flags in this folder"))
(wl-summary-set-flags-internal nil nil nil remove))
-(defun wl-summary-mark-as-important-internal (inverse
- &optional number-or-numbers)
- (if inverse
- (wl-summary-remove-flags-internal number-or-numbers '(important))
- (wl-summary-add-flags-internal number-or-numbers '(important))))
-
(defun wl-summary-mark-as-important (&optional prompt)
(interactive "P")
- (if (eq 'flag (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
- (error "Cannot process flags in this folder"))
(if prompt
(wl-summary-set-flags-internal)
- (wl-summary-mark-as-important-internal
+ (wl-summary-set-persistent-mark-internal
(and (interactive-p)
(elmo-message-flagged-p wl-summary-buffer-elmo-folder
(wl-summary-message-number)
- 'important)))))
+ 'important))
+ 'important
+ nil nil nil (interactive-p))))
;;; Summary line.
(defvar wl-summary-line-formatter nil)
)))
(run-hooks 'wl-summary-buffer-window-scroll-functions)))
+(defun wl-summary-enter-handler (&optional arg)
+ "A command for `enter' key in the summary.
+Basically, it shows next line of the message.
+If optional argument ARG is specified, behave as followed.
+If ARG is number, jump to the message.
+Otherwise it shows previous line of the message."
+ (interactive "P")
+ (cond ((numberp arg)
+ (unless (wl-thread-jump-to-msg arg)
+ (message "Message (#%d) was not found." arg)))
+ (arg
+ (wl-summary-prev-line-content))
+ (t
+ (wl-summary-next-line-content))))
+
(defun wl-summary-next-line-content ()
"Show next line of the message."
(interactive)
cur-folder cur-number message-last-pos)
(when (buffer-live-p wl-message-buffer)
(save-window-excursion
+ (setq wl-current-summary-buffer (current-buffer))
(wl-message-select-buffer wl-message-buffer)
(setq cur-folder wl-message-buffer-cur-folder)
(setq cur-number wl-message-buffer-cur-number)))
(progn
(set-buffer wl-message-buffer)
t)
- (if (wl-summary-no-mime-p folder)
- (wl-summary-redisplay-no-mime-internal folder number)
- (wl-summary-redisplay-internal folder number))
+ (wl-summary-redisplay-internal folder number)
(when (buffer-live-p wl-message-buffer)
(set-buffer wl-message-buffer))
nil)))
(defun wl-summary-target-mark-forward (&optional arg)
(interactive "P")
- (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
+ (wl-summary-check-target-mark)
+ (let ((mlist (nreverse (copy-sequence wl-summary-buffer-target-mark-list)))
(summary-buf (current-buffer))
(wl-draft-forward t)
start-point
(goto-char start-point)
(save-excursion
(set-buffer summary-buf)
- (wl-summary-delete-all-temp-marks)))
+ (wl-summary-delete-all-target-marks)))
(run-hooks 'wl-mail-setup-hook)))
(defun wl-summary-target-mark-reply-with-citation (&optional arg)
(interactive "P")
- (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
+ (wl-summary-check-target-mark)
+ (let ((mlist (nreverse (copy-sequence wl-summary-buffer-target-mark-list)))
(summary-buf (current-buffer))
change-major-mode-hook
start-point
(goto-char start-point)
(save-excursion
(set-buffer summary-buf)
- (wl-summary-delete-all-temp-marks)))
+ (wl-summary-delete-all-target-marks)))
(wl-draft-reply-position wl-draft-reply-default-position)
(run-hooks 'wl-mail-setup-hook))))
(when number
(save-excursion
(wl-summary-set-message-buffer-or-redisplay))
- (setq mes-buf wl-message-buffer)
(wl-message-select-buffer wl-message-buffer)
- (set-buffer mes-buf)
(condition-case err
(when (setq mes-buf (wl-message-get-original-buffer))
(wl-draft-reply mes-buf arg summary-buf number)
(run-hooks 'wl-mail-setup-hook)))
(error (set-window-configuration winconf)
(signal (car err)(cdr err))))
- (with-current-buffer summary-buf
- (elmo-folder-set-flag folder (list number) 'answered)
- (wl-summary-update-persistent-mark))
+ (with-current-buffer summary-buf (run-hooks 'wl-summary-reply-hook))
t)))
(defun wl-summary-write ()
(number (wl-summary-message-number))
(summary-buf (current-buffer))
(wl-draft-forward t)
- mes-buf
entity subject num)
(if (null number)
(message "No message.")
;; Reload.
(wl-summary-redisplay-internal nil nil 'force-reload)
(wl-summary-redisplay-internal folder number))
- (setq mes-buf wl-message-buffer)
- (wl-message-select-buffer mes-buf)
- ;; get original subject.
- (if summary-buf
- (save-excursion
- (set-buffer summary-buf)
- (setq subject
- (or (elmo-message-entity-field
- (elmo-message-entity folder number) 'subject 'decode)
- ""))))
- (set-buffer mes-buf)
- (wl-draft-forward subject summary-buf)
+ (wl-message-select-buffer wl-message-buffer)
+ (setq subject (with-current-buffer
+ wl-message-buffer-original-buffer
+ (std11-field-body "Subject")))
+ (wl-draft-forward subject summary-buf number)
+ (with-current-buffer summary-buf (run-hooks 'wl-summary-forward-hook))
(unless without-setup-hook
(run-hooks 'wl-mail-setup-hook)))))
(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))
+ (wl-message-buffer-display-type wl-message-buffer)))
+
+(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
+MIME analysis mode.
+
+If ARG is numeric number, decode message as following:
+1: Enable MIME analysis.
+2: Enable MIME analysis only for headers.
+3: Disable MIME analysis."
+ (interactive "P")
+ (let ((mime-mode (wl-summary-buffer-display-mime-mode))
+ (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-analysis-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.
+ (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 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)
+ ")")
+ ""))))
+
(defun wl-summary-redisplay (&optional arg)
+ "Redisplay message."
(interactive "P")
- (if (and (not arg)
- (wl-summary-no-mime-p wl-summary-buffer-elmo-folder))
- (wl-summary-redisplay-no-mime)
- (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))))
-(defsubst wl-summary-redisplay-internal (&optional folder number force-reload)
- (interactive)
+(defun wl-summary-toggle-all-header (&optional arg)
+ "Toggle displaying message with all header."
+ (interactive "P")
+ (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
+ mime-mode header-mode)
(let* ((folder (or folder wl-summary-buffer-elmo-folder))
(num (or number (wl-summary-message-number)))
(wl-mime-charset wl-summary-buffer-mime-charset)
(default-mime-charset wl-summary-buffer-mime-charset)
- no-folder-mark fld-buf fld-win thr-entity)
+ no-folder-mark fld-buf fld-win thr-entity
+ (elmo-message-fetch-confirm (or elmo-message-fetch-confirm
+ (and force-reload
+ elmo-message-fetch-threshold))))
(if (and wl-thread-open-reading-thread
(eq wl-summary-buffer-view 'thread)
(not (wl-thread-entity-get-opened
(setq wl-current-summary-buffer (current-buffer))
(setq no-folder-mark
;; If cache is used, change folder-mark.
- (if (wl-message-redisplay folder num
- 'mime
- (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
(run-hooks 'wl-summary-redisplay-hook))
(message "No message to display."))))
-(defun wl-summary-redisplay-no-mime (&optional ask-coding)
- "Display message without MIME decoding.
-If ASK-CODING is non-nil, coding-system for the message is asked."
- (interactive "P")
- (let ((elmo-mime-display-as-is-coding-system
- (if ask-coding
- (or (read-coding-system "Coding system: ")
- elmo-mime-display-as-is-coding-system)
- elmo-mime-display-as-is-coding-system)))
- (wl-summary-redisplay-no-mime-internal)))
-
-(defun wl-summary-redisplay-no-mime-internal (&optional folder number)
- (let* ((fld (or folder wl-summary-buffer-elmo-folder))
- (num (or number (wl-summary-message-number)))
- wl-break-pages)
- (if num
- (progn
- (setq wl-summary-buffer-disp-msg t)
- (setq wl-summary-buffer-last-displayed-msg
- wl-summary-buffer-current-msg)
- (setq wl-current-summary-buffer (current-buffer))
- (wl-message-redisplay fld num 'as-is
- (string= (elmo-folder-name-internal fld)
- wl-draft-folder))
- (when (elmo-message-use-cache-p fld num)
- (elmo-message-set-cached fld num t))
- (ignore-errors
- (if (elmo-message-flagged-p fld num 'unread)
- (wl-summary-mark-as-read num); no-folder-mark)
- (wl-summary-update-persistent-mark)))
- (setq wl-summary-buffer-current-msg num)
- (when wl-summary-recenter
- (recenter (/ (- (window-height) 2) 2))
- (if (not wl-summary-indent-length-limit)
- (wl-horizontal-recenter)))
- (wl-highlight-summary-displaying)
- (run-hooks 'wl-summary-redisplay-hook))
- (message "No message to display.")
- (wl-ask-folder 'wl-summary-exit
- "No more messages. Type SPC to go to folder mode."))))
-
-(defun wl-summary-redisplay-all-header (&optional folder number)
- (interactive)
- (let* ((fld (or folder wl-summary-buffer-elmo-folder))
- (num (or number (wl-summary-message-number)))
- (wl-mime-charset wl-summary-buffer-mime-charset)
- (default-mime-charset wl-summary-buffer-mime-charset))
- (if num
- (progn
- (setq wl-summary-buffer-disp-msg t)
- (setq wl-summary-buffer-last-displayed-msg
- wl-summary-buffer-current-msg)
- (setq wl-current-summary-buffer (current-buffer))
- (when (elmo-message-use-cache-p fld num)
- (elmo-message-set-cached fld num t))
- (if (wl-message-redisplay fld num 'all-header
- (string= (elmo-folder-name-internal fld)
- wl-draft-folder))
- (wl-summary-mark-as-read num))
- (setq wl-summary-buffer-current-msg num)
- (when wl-summary-recenter
- (recenter (/ (- (window-height) 2) 2))
- (if (not wl-summary-indent-length-limit)
- (wl-horizontal-recenter)))
- (wl-highlight-summary-displaying)
- (run-hooks 'wl-summary-redisplay-hook))
- (message "No message to display."))))
-
(defun wl-summary-jump-to-current-message ()
"Jump into Message buffer."
(interactive)
wl-break-pages)
(save-excursion
(wl-summary-set-message-buffer-or-redisplay)
- ;; (wl-summary-redisplay-internal)
(let* ((buffer (generate-new-buffer " *print*"))
(entity (progn
(set-buffer summary-buffer)
(defun wl-summary-target-mark-print ()
(interactive)
- (if (null wl-summary-buffer-target-mark-list)
- (message "No marked message.")
- (when (y-or-n-p "Print all marked messages. OK? ")
- (while (car wl-summary-buffer-target-mark-list)
- (let ((num (car wl-summary-buffer-target-mark-list)))
- (wl-thread-jump-to-msg num)
- (wl-summary-print-message)
- (wl-summary-unmark))))))
+ (wl-summary-check-target-mark)
+ (when (y-or-n-p "Print all marked messages. OK? ")
+ (while (car wl-summary-buffer-target-mark-list)
+ (let ((num (car wl-summary-buffer-target-mark-list)))
+ (wl-thread-jump-to-msg num)
+ (wl-summary-print-message)
+ (wl-summary-unmark)))))
(defun wl-summary-folder-info-update ()
(wl-folder-set-folder-updated
(elmo-string (wl-summary-buffer-folder-name))
(list 0
- (+ wl-summary-buffer-unread-count
- wl-summary-buffer-new-count)
+ wl-summary-buffer-unread-count
(elmo-folder-length
wl-summary-buffer-elmo-folder))))
(interactive "P")
(elmo-folder-pack-numbers wl-summary-buffer-elmo-folder)
(let (wl-use-scoring)
- (wl-summary-rescan nil nil t)))
+ (wl-summary-rescan nil nil nil t)))
(defun wl-summary-target-mark-uudecode ()
(interactive)
+ (wl-summary-check-target-mark)
(let ((mlist (reverse wl-summary-buffer-target-mark-list))
(summary-buf (current-buffer))
(tmp-buf (get-buffer-create "*WL UUENCODE*"))
filename nil 'no-msg))))
(save-excursion
(set-buffer summary-buf)
- (wl-summary-delete-all-temp-marks))
+ (wl-summary-delete-all-target-marks))
(if (file-exists-p filename)
(message "Saved as %s" filename)))
(kill-buffer tmp-buf)))))
(wl-message-header-narrowing-toggle)
(and wpos (set-window-start mwin wpos)))))))
-(autoload 'elmo-folder-list-global-flag-messages "elmo-flag")
-
(require 'product)
(product-provide (provide 'wl-summary) (require 'wl-version))