2002-01-18 TSUCHIYA Masatoshi <tsuchiya@namazu.org>
authorShengHuo ZHU <zsh@cs.rochester.edu>
Fri, 18 Jan 2002 17:40:43 +0000 (17:40 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Fri, 18 Jan 2002 17:40:43 +0000 (17:40 +0000)
* gnus-art.el (gnus-request-article-this-buffer): Call
`nneething-get-file-name' to extract the file name from the
message id.

* nneething.el (nneething-encode-file-name): New function.
(nneething-decode-file-name): Ditto.
(nneething-get-file-name): Ditto.
(nneething-make-head): Encode the file name and encapsulate it
into the field of the message id.

lisp/ChangeLog
lisp/gnus-art.el
lisp/nneething.el

index 013988e..546808a 100644 (file)
@@ -1,3 +1,15 @@
+2002-01-18  TSUCHIYA Masatoshi  <tsuchiya@namazu.org>
+
+       * gnus-art.el (gnus-request-article-this-buffer): Call
+       `nneething-get-file-name' to extract the file name from the
+       message id.
+
+       * nneething.el (nneething-encode-file-name): New function.
+       (nneething-decode-file-name): Ditto.
+       (nneething-get-file-name): Ditto.
+       (nneething-make-head): Encode the file name and encapsulate it
+       into the field of the message id.
+
 2002-01-18  Simon Josefsson  <jas@extundo.com>
 
        * nnml.el (nnml-request-update-info): Don't erase flags that isn't
 2001-06-03  Dale Hagglund  <rdh@best.com>
 
        * gnus-mlspl.el (gnus-group-split-fancy): Fix generation of split
-       restrict clauses.
+       restrict clauses.
 
 2001-06-07 16:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
index 0ae3e52..cdd2a07 100644 (file)
@@ -4750,6 +4750,9 @@ If given a prefix, show the hidden text instead."
     (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
     (gnus-request-group gnus-newsgroup-name t)))
 
+(eval-when-compile
+  (autoload 'nneething-get-file-name "nneething"))
+
 (defun gnus-request-article-this-buffer (article group)
   "Get an article and insert it into this buffer."
   (let (do-update-line sparse-header)
@@ -4799,12 +4802,10 @@ If given a prefix, show the hidden text instead."
                               gnus-newsgroup-name)))
                  (when (and (eq (car method) 'nneething)
                             (vectorp header))
-                   (let ((dir (expand-file-name
-                               (mail-header-subject header)
-                               (file-name-as-directory
-                                (or (cadr (assq 'nneething-address method))
-                                    (nth 1 method))))))
-                     (when (file-directory-p dir)
+                   (let ((dir (nneething-get-file-name
+                               (mail-header-id header))))
+                     (when (and (stringp dir)
+                                (file-directory-p dir))
                        (setq article 'nneething)
                        (gnus-group-enter-directory dir))))))))
 
index 8ce10ed..9c30970 100644 (file)
@@ -284,6 +284,35 @@ included.")
     (insert-buffer-substring nneething-work-buffer)
     (goto-char (point-max))))
 
+(defun nneething-encode-file-name (file &optional coding-system)
+  "Encode the name of the FILE in CODING-SYSTEM."
+  (let ((pos 0) buf)
+    (setq file (mm-encode-coding-string
+               file (or coding-system nnmail-pathname-coding-system)))
+    (while (string-match "[^-a-zA-Z_:/.]" file pos)
+      (setq buf (cons (format "%%%02x" (aref file (match-beginning 0)))
+                     (cons (substring file pos (match-beginning 0)) buf))
+           pos (match-end 0)))
+    (apply (function concat)
+          (nreverse (cons (substring file pos) buf)))))
+
+(defun nneething-decode-file-name (file &optional coding-system)
+  "Decode the name of the FILE is encoded in CODING-SYSTEM."
+  (let ((pos 0) buf)
+    (while (string-match "%\\([0-9a-fA-F][0-9a-fA-F]\\)" file pos)
+      (setq buf (cons (string (string-to-number (match-string 1 file) 16))
+                     (cons (substring file pos (match-beginning 0)) buf))
+           pos (match-end 0)))
+    (decode-coding-string
+     (apply (function concat)
+           (nreverse (cons (substring file pos) buf)))
+     (or coding-system nnmail-pathname-coding-system))))
+
+(defun nneething-get-file-name (id)
+  "Extract the file name from the message ID string."
+  (when (string-match "\\`<nneething\\-[0-9]+\\-\\([^@]+\\)@.*>\\'" id)
+    (nneething-decode-file-name (match-string 1 id))))
+
 (defun nneething-make-head (file &optional buffer extra-msg
                                 mime-type mime-charset mime-encoding)
   "Create a head by looking at the file attributes of FILE."
@@ -292,6 +321,7 @@ included.")
      "Subject: " (file-name-nondirectory file) (or extra-msg "") "\n"
      "Message-ID: <nneething-"
      (int-to-string (incf nneething-message-id-number))
+     "-" (nneething-encode-file-name file)
      "@" (system-name) ">\n"
      (if (equal '(0 0) (nth 5 atts)) ""
        (concat "Date: " (current-time-string (nth 5 atts)) "\n"))