variable.
(wl-summary-event-handler): New class.
(elmo-event-handler-flag-changed): Define to update persistent
mark.
(wl-summary-buffer-set-folder): Register event handler to
elmo-folder.
(wl-summary-exit): Unregister event handler.
(wl-summary-goto-folder-subr): Ditto.
(wl-summary-mark-as-read-all): Does not call
`wl-summary-update-persistent-mark' directly.
(wl-summary-mark-as-read-internal): Ditto.
(wl-summary-set-persistent-mark-internal): Ditto.
(wl-summary-set-flags-internal): Ditto.
* elmo.el (elmo-folder): Added handlers slot.
(elmo-event-handler): New class.
(elmo-event-handler-flag-changed): New API.
(elmo-folder-add-handler): New function.
(elmo-folder-remove-handler): Ditto.
(elmo-folder-notify-event): Ditto.
(elmo-folder-set-flag): Call `elmo-folder-notify-event' with event
`flag-changed'.
(elmo-folder-unset-flag): Ditto.
* elmo-pipe.el (elmo-folder-set-flag): Ditto.
(elmo-folder-unset-flag): Ditto.
* elmo-multi.el (elmo-folder-set-flag): Ditto.
(elmo-folder-unset-flag): Ditto.
* elmo-filter.el (elmo-folder-set-flag): Ditto.
(elmo-folder-unset-flag): Ditto.
2004-11-06 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+ * elmo.el (elmo-folder): Added handlers slot.
+ (elmo-event-handler): New class.
+ (elmo-event-handler-flag-changed): New API.
+ (elmo-folder-add-handler): New function.
+ (elmo-folder-remove-handler): Ditto.
+ (elmo-folder-notify-event): Ditto.
+ (elmo-folder-set-flag): Call `elmo-folder-notify-event' with event
+ `flag-changed'.
+ (elmo-folder-unset-flag): Ditto.
+
+ * elmo-pipe.el (elmo-folder-set-flag): Ditto.
+ (elmo-folder-unset-flag): Ditto.
+
+ * elmo-multi.el (elmo-folder-set-flag): Ditto.
+ (elmo-folder-unset-flag): Ditto.
+
+ * elmo-filter.el (elmo-folder-set-flag): Ditto.
+ (elmo-folder-unset-flag): Ditto.
+
* elmo-version.el (elmo-version): Up to 2.11.33.
2004-10-25 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
(elmo-filter-folder-countup-message-flags folder numbers -1)
(elmo-folder-set-flag (elmo-filter-folder-target-internal folder)
numbers flag is-local)
- (elmo-filter-folder-countup-message-flags folder numbers))
+ (elmo-filter-folder-countup-message-flags folder numbers)
+ (elmo-folder-notify-event folder 'flag-changed numbers))
(luna-define-method elmo-folder-unset-flag ((folder elmo-filter-folder)
numbers
(elmo-filter-folder-countup-message-flags folder numbers -1)
(elmo-folder-unset-flag (elmo-filter-folder-target-internal folder)
numbers flag is-local)
- (elmo-filter-folder-countup-message-flags folder numbers))
+ (elmo-filter-folder-countup-message-flags folder numbers)
+ (elmo-folder-notify-event folder 'flag-changed numbers))
(luna-define-method elmo-message-folder ((folder elmo-filter-folder)
number)
flag
&optional is-local)
(dolist (pair (elmo-multi-make-folder-numbers-list folder numbers))
- (elmo-folder-set-flag (car pair) (cdr pair) flag is-local)))
+ (elmo-folder-set-flag (car pair) (cdr pair) flag is-local))
+ (elmo-folder-notify-event folder 'flag-changed numbers))
(luna-define-method elmo-folder-unset-flag ((folder elmo-multi-folder)
numbers
&optional is-local)
(dolist (pair (elmo-multi-make-folder-numbers-list folder numbers))
(ignore-errors
- (elmo-folder-unset-flag (car pair) (cdr pair) flag is-local))))
+ (elmo-folder-unset-flag (car pair) (cdr pair) flag is-local)))
+ (elmo-folder-notify-event folder 'flag-changed numbers))
(luna-define-method elmo-folder-list-flagged ((folder elmo-multi-folder)
flag
flag
&optional is-local)
(elmo-folder-set-flag (elmo-pipe-folder-dst-internal folder)
- numbers flag is-local))
+ numbers flag is-local)
+ (elmo-folder-notify-event folder 'flag-changed numbers))
(luna-define-method elmo-folder-unset-flag ((folder elmo-pipe-folder)
numbers
flag
&optional is-local)
(elmo-folder-unset-flag (elmo-pipe-folder-dst-internal folder)
- numbers flag is-local))
+ numbers flag is-local)
+ (elmo-folder-notify-event folder 'flag-changed numbers))
(luna-define-method elmo-folder-pack-numbers ((folder elmo-pipe-folder))
(elmo-folder-pack-numbers (elmo-pipe-folder-dst-internal folder)))
persistent ; non-nil if persistent.
process-duplicates ; read or hide
biff ; folder for biff
+ handlers ; list of event handler.
))
(luna-define-internal-accessors 'elmo-folder))
(elmo-global-flag-set flag folder number message-id)))
(elmo-msgdb-set-flag (elmo-folder-msgdb folder)
number
- flag))))
+ flag))
+ (elmo-folder-notify-event folder 'flag-changed numbers)))
(defun elmo-message-has-global-flag-p (folder number)
"Return non-nil when the message in the FOLDER with NUMBER has global flag."
(elmo-global-flag-detach flag folder number 'always))
(elmo-msgdb-unset-flag (elmo-folder-msgdb folder)
number
- flag))))
+ flag))
+ (elmo-folder-notify-event folder 'flag-changed numbers)))
(luna-define-method elmo-folder-process-crosspost ((folder elmo-folder))
;; Do nothing.
(elmo-make-directory temp-dir)
temp-dir))
+;; Event notification/observer framework
+(eval-and-compile
+ (luna-define-class elmo-event-handler ()))
+
+(luna-define-generic elmo-event-handler-flag-changed (handler numbers)
+ "Notify flag of the messages with NUMBERS is changed.")
+
+(defun elmo-folder-add-handler (folder handler)
+ (unless (memq handler (elmo-folder-handlers-internal folder))
+ (elmo-folder-set-handlers-internal
+ folder
+ (cons handler (elmo-folder-handlers-internal folder)))))
+
+(defun elmo-folder-remove-handler (folder handler)
+ (elmo-folder-set-handlers-internal
+ folder
+ (delq handler (elmo-folder-handlers-internal folder))))
+
+(defun elmo-folder-notify-event (folder event &rest args)
+ (when (elmo-folder-handlers-internal folder)
+ (let ((message (format "elmo-event-handler-%s" event)))
+ (dolist (handler (elmo-folder-handlers-internal folder))
+ (apply #'luna-send handler message handler args)))))
+
+;;;
(defun elmo-init ()
"Initialize ELMO module."
(elmo-crosspost-message-alist-load)
2004-11-06 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+ * wl-summary.el (wl-summary-buffer-event-handler): New internal
+ variable.
+ (wl-summary-event-handler): New class.
+ (elmo-event-handler-flag-changed): Define to update persistent
+ mark.
+ (wl-summary-buffer-set-folder): Register event handler to
+ elmo-folder.
+ (wl-summary-exit): Unregister event handler.
+ (wl-summary-goto-folder-subr): Ditto.
+ (wl-summary-mark-as-read-all): Does not call
+ `wl-summary-update-persistent-mark' directly.
+ (wl-summary-mark-as-read-internal): Ditto.
+ (wl-summary-set-persistent-mark-internal): Ditto.
+ (wl-summary-set-flags-internal): Ditto.
+
* Version number is increased to 2.11.33.
2004-10-28 TAKAHASHI Kaoru <kaoru@kaisei.org>
(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-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-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-event-handler)
(defvar wl-datevec)
(defvar wl-thr-indent-string)
(wl-summary-lazy-update-mark
(list 'wl-summary-update-mark-window))))
+;; 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)
+ (with-current-buffer (wl-summary-event-handler-buffer-internal handler)
+ (save-excursion
+ (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-status-update ()
(interactive)
(wl-address-init))
(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
(progn
(wl-summary-save-view)
(if (or force-exit (not sticky))
- (elmo-folder-close wl-summary-buffer-elmo-folder)
+ (progn
+ (elmo-folder-close wl-summary-buffer-elmo-folder)
+ (elmo-folder-remove-handler wl-summary-buffer-elmo-folder
+ wl-summary-buffer-event-handler))
(elmo-folder-commit wl-summary-buffer-elmo-folder)
(elmo-folder-check wl-summary-buffer-elmo-folder))
(if wl-use-scoring (wl-score-save)))
folder
(elmo-folder-list-flagged folder 'unread 'in-msgdb)
'unread)
- (save-excursion
- (goto-char (point-min))
- (while (not (eobp))
- (wl-summary-update-persistent-mark)
- (forward-line 1)))
(wl-folder-update-unread (wl-summary-buffer-folder-name) 0)
(setq wl-summary-buffer-unread-count 0)
(setq wl-summary-buffer-new-count 0)
(if other-window
(delete-other-windows))
(set-buffer buf)
+ (when wl-summary-buffer-event-handler
+ (elmo-folder-remove-handler wl-summary-buffer-elmo-folder
+ wl-summary-buffer-event-handler))
(unless (eq major-mode 'wl-summary-mode)
(wl-summary-mode))
(wl-summary-buffer-set-folder folder)
(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 inverse
(elmo-folder-set-flag folder number-list 'unread no-folder-mark)
(elmo-folder-unset-flag folder number-list 'unread 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)))
+ (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)
"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))
(if inverse
(elmo-folder-unset-flag folder number-list flag no-server)
(elmo-folder-set-flag folder number-list flag no-server))
- (dolist (number number-list)
- ;; set mark on buffer
- (when (wl-summary-jump-to-msg number)
- (wl-summary-update-persistent-mark)))
(unless no-modeline-update
;; Update unread numbers.
;; should elmo-flag-mark-as-read return unread numbers?
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)))
(defun wl-summary-set-flags (&optional remove)