From f62ab39de3b81cadaa6646c0f07561ad5064cb16 Mon Sep 17 00:00:00 2001 From: hmurata Date: Sat, 12 Aug 2006 11:20:12 +0000 Subject: [PATCH] * elmo-flag.el (elmo-flag-folder-set-minfo): New function. (elmo-folder-initialize): Use it. (elmo-global-flag-replace-referrer): New function. * elmo.el (toplevel): Added autoload setting for `elmo-global-flag-replace-referrer'. (elmo-folder-rename): Rewrite the last change use `elmo-global-flag-replace-referrer'. * elmo-pipe.el (elmo-folder-rename): Call `elmo-global-flag-replace-referrer'. --- elmo/ChangeLog | 14 ++++++++++++++ elmo/elmo-flag.el | 47 ++++++++++++++++++++++++++++++----------------- elmo/elmo-pipe.el | 2 ++ elmo/elmo.el | 20 +++++--------------- 4 files changed, 51 insertions(+), 32 deletions(-) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 45e667d..2fd5cb4 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,17 @@ +2006-08-12 Hiroya Murata + + * elmo-flag.el (elmo-flag-folder-set-minfo): New function. + (elmo-folder-initialize): Use it. + (elmo-global-flag-replace-referrer): New function. + + * elmo.el (toplevel): Added autoload setting for + `elmo-global-flag-replace-referrer'. + (elmo-folder-rename): Rewrite the last change use + `elmo-global-flag-replace-referrer'. + + * elmo-pipe.el (elmo-folder-rename): Call + `elmo-global-flag-replace-referrer'. + 2006-08-09 Hiroya Murata * elmo.el (elmo-folder-rename): Set meta data for global flags diff --git a/elmo/elmo-flag.el b/elmo/elmo-flag.el index 0ee9397..687d422 100644 --- a/elmo/elmo-flag.el +++ b/elmo/elmo-flag.el @@ -92,28 +92,27 @@ (elmo-flag-folder-set-max-number-internal folder (elmo-object-load (expand-file-name "max" msgdb-path)))) - (if (file-exists-p (expand-file-name ".minfo" msgdb-path)) - (elmo-flag-folder-set-minfo-internal - folder - (elmo-object-load (expand-file-name ".minfo" msgdb-path)))) - (elmo-flag-folder-set-minfo-hash-internal + (elmo-flag-folder-set-minfo folder - (elmo-make-hash (length (elmo-flag-folder-minfo-internal folder)))) - (dolist (elem (elmo-flag-folder-minfo-internal folder)) - (elmo-set-hash-val (nth 1 elem) elem - (elmo-flag-folder-minfo-hash-internal folder)) - (elmo-set-hash-val (concat "#" (number-to-string (nth 2 elem))) - elem - (elmo-flag-folder-minfo-hash-internal folder)) - (dolist (pair (car elem)) - (elmo-set-hash-val (concat (number-to-string (cdr pair)) - ":" (car pair)) - elem - (elmo-flag-folder-minfo-hash-internal folder)))) + (and (file-exists-p (expand-file-name ".minfo" msgdb-path)) + (elmo-object-load (expand-file-name ".minfo" msgdb-path)))) (setq elmo-global-flag-folder-alist (cons (cons flag folder) elmo-global-flag-folder-alist)) folder))) +(defun elmo-flag-folder-set-minfo (folder minfo) + (let ((hash (elmo-make-hash (length minfo)))) + (dolist (elem minfo) + (elmo-set-hash-val (nth 1 elem) elem hash) + (elmo-set-hash-val (concat "#" (number-to-string (nth 2 elem))) + elem hash) + (dolist (pair (car elem)) + (elmo-set-hash-val (concat (number-to-string (cdr pair)) + ":" (car pair)) + elem hash))) + (elmo-flag-folder-set-minfo-internal folder minfo) + (elmo-flag-folder-set-minfo-hash-internal folder hash))) + (luna-define-method elmo-folder-expand-msgdb-path ((folder elmo-flag-folder)) (expand-file-name (concat "flag/" (elmo-replace-string-as-filename @@ -424,6 +423,20 @@ the message is not flagged in any folder." (dolist (number numbers) (elmo-global-flag-detach flag folder number delete-if-none))))) +(defun elmo-global-flag-replace-referrer (old-folder new-folder) + (dolist (flag elmo-global-flags) + (let* ((folder (elmo-flag-get-folder flag)) + (minfo (elmo-flag-folder-minfo-internal folder)) + modified) + (dolist (entry minfo) + (let ((pair (assoc old-folder (nth 0 entry)))) + (when pair + (setcar pair new-folder) + (setq modified t)))) + (when modified + (elmo-flag-folder-set-minfo folder minfo) + (elmo-folder-commit folder))))) + (defun elmo-get-global-flags (&optional flags ignore-preserved) "Get global flags. Return value is a subset of optional argument FLAGS. diff --git a/elmo/elmo-pipe.el b/elmo/elmo-pipe.el index fe82b79..4194f9c 100644 --- a/elmo/elmo-pipe.el +++ b/elmo/elmo-pipe.el @@ -325,6 +325,8 @@ (elmo-folder-rename (elmo-pipe-folder-dst-internal folder) (elmo-folder-name-internal (elmo-pipe-folder-dst-internal new-folder))) + (elmo-global-flag-replace-referrer (elmo-folder-name-internal folder) + new-name) (elmo-msgdb-rename-path folder new-folder))) (luna-define-method elmo-folder-synchronize ((folder elmo-pipe-folder) diff --git a/elmo/elmo.el b/elmo/elmo.el index 044c1d6..d23975a 100644 --- a/elmo/elmo.el +++ b/elmo/elmo.el @@ -114,6 +114,7 @@ Otherwise, entire fetching of the message is aborted without confirmation." (autoload 'elmo-global-flag-detach "elmo-flag") (autoload 'elmo-global-flag-detach-messages "elmo-flag") (autoload 'elmo-global-flag-set "elmo-flag") + (autoload 'elmo-global-flag-replace-referrer "elmo-flag") (autoload 'elmo-get-global-flags "elmo-flag") (autoload 'elmo-global-flags-initialize "elmo-flag") (autoload 'elmo-global-mark-migrate "elmo-flag") @@ -795,21 +796,10 @@ Return a cons cell of (NUMBER-CROSSPOSTS . NEW-FLAG-ALIST).") (when (or (file-exists-p (elmo-folder-msgdb-path new-folder)) (elmo-folder-exists-p new-folder)) (error "Already exists folder: %s" new-name)) - (let ((global-flag-entries - (mapcar (lambda (number) - (list number - (elmo-message-field folder number 'message-id) - (elmo-message-flags folder number))) - (elmo-folder-list-flagged folder 'digest 'in-msgdb)))) - (elmo-folder-send folder 'elmo-folder-rename-internal new-folder) - (elmo-msgdb-rename-path folder new-folder) - (dolist (entry global-flag-entries) - (let ((number (nth 0 entry)) - (message-id (nth 1 entry))) - (dolist (flag (nth 2 entry)) - (when (elmo-global-flag-p flag) - (elmo-global-flag-set flag new-folder number message-id) - (elmo-global-flag-detach flag folder number)))))))) + (elmo-folder-send folder 'elmo-folder-rename-internal new-folder) + (elmo-global-flag-replace-referrer (elmo-folder-name-internal folder) + new-name) + (elmo-msgdb-rename-path folder new-folder))) (luna-define-method elmo-folder-delete-messages ((folder elmo-folder) numbers) -- 1.7.10.4