* elmo-nntp.el (elmo-network-initialize-session): Fixed for Response '400'
[elisp/wanderlust.git] / elmo / elmo-nmz.el
index 5392a62..d603b0d 100644 (file)
@@ -60,6 +60,10 @@ If the value is a list, all elements are used as index paths for namazu."
                               (repeat (directory :tag "Index Path")))))
   :group 'elmo)
 
+(defvar elmo-nmz-use-drive-letter (if (memq system-type
+                                           '(OS/2 emx windows-nt)) t nil)
+  "*If non-nil, do a drive letter conversion (e.g. /a|/ => a:/).")
+
 ;;; "namazu search"
 (eval-and-compile
   (luna-define-class elmo-nmz-folder
@@ -96,7 +100,7 @@ If the value is a list, all elements are used as index paths for namazu."
 
 (defun elmo-nmz-msgdb-create-entity (folder number)
   "Create msgdb entity for the message in the FOLDER with NUMBER."
-  (let ((location (elmo-map-message-location folder number))
+  (let ((location (expand-file-name (elmo-map-message-location folder number)))
        entity uid)
     (setq entity (elmo-msgdb-create-overview-entity-from-file number location))
     (unless (or (> (length (elmo-msgdb-overview-entity-get-to entity)) 0)
@@ -178,7 +182,7 @@ If the value is a list, all elements are used as index paths for namazu."
   (let ((temp-dir (elmo-folder-make-temporary-directory folder))
        (cur-number (if start-number 0)))
     (dolist (number numbers)
-      (elmo-add-name-to-file
+      (elmo-copy-file
        (elmo-message-file-name folder number)
        (expand-file-name
        (int-to-string (if start-number (incf cur-number) number))
@@ -189,29 +193,30 @@ If the value is a list, all elements are used as index paths for namazu."
                                            location strategy
                                            &optional section unseen)
   (when (file-exists-p location)
-    (insert-file-contents-as-binary location)
-    (unless (or (std11-field-body "To")
-               (std11-field-body "Cc")
-               (std11-field-body "Subject"))
-      (let (charset guess uid)
-       (erase-buffer)
-       (set-buffer-multibyte t)
-       (insert-file-contents location)
-       (setq charset (detect-mime-charset-region (point-min)
-                                                 (point-max)))
-       (goto-char (point-min))
-       (setq guess (mime-find-file-type location))
-       (setq uid (nth 2 (file-attributes location)))
-       (insert "From: " (concat (user-full-name uid)
-                                " <"(user-login-name uid) "@"
-                                (system-name) ">") "\n")
-       (insert "Subject: " location "\n")
-       (insert "Content-Type: "
-               (concat (nth 0 guess) "/" (nth 1 guess))
-               "; charset=" (upcase (symbol-name charset))
-               "\nMIME-Version: 1.0\n\n")
-       (encode-mime-charset-region (point-min) (point-max) charset)
-       (set-buffer-multibyte nil)))))
+    (prog1
+       (insert-file-contents-as-binary (expand-file-name location))
+      (unless (or (std11-field-body "To")
+                 (std11-field-body "Cc")
+                 (std11-field-body "Subject"))
+       (let (charset guess uid)
+         (erase-buffer)
+         (set-buffer-multibyte t)
+         (insert-file-contents (expand-file-name location))
+         (setq charset (detect-mime-charset-region (point-min)
+                                                   (point-max)))
+         (goto-char (point-min))
+         (setq guess (mime-find-file-type location))
+         (setq uid (nth 2 (file-attributes location)))
+         (insert "From: " (concat (user-full-name uid)
+                                  " <"(user-login-name uid) "@"
+                                  (system-name) ">") "\n")
+         (insert "Subject: " location "\n")
+         (insert "Content-Type: "
+                 (concat (nth 0 guess) "/" (nth 1 guess))
+                 "; charset=" (upcase (symbol-name charset))
+                 "\nMIME-Version: 1.0\n\n")
+         (encode-mime-charset-region (point-min) (point-max) charset)
+         (set-buffer-multibyte nil))))))
 
 (luna-define-method elmo-map-folder-list-message-locations
   ((folder elmo-nmz-folder))
@@ -233,7 +238,14 @@ If the value is a list, all elements are used as index paths for namazu."
       (goto-char (point-min))
       (while (not (eobp))
        (beginning-of-line)
-       (setq bol (if (looking-at "^file://") (match-end 0)(point)))
+       ;; convert url to file path.
+       (when (looking-at "^file://")
+         (replace-match ""))
+       (when (and elmo-nmz-use-drive-letter
+                  (looking-at "^/\\([A-Za-z]\\)|/"))
+         (replace-match "\\1:/")
+         (beginning-of-line))
+       (setq bol (point))
        (end-of-line)
        (setq locations (cons (buffer-substring bol (point)) locations))
        (forward-line 1))