From a67ffa7aa294cc66152ad24d90b528e529adadbd Mon Sep 17 00:00:00 2001 From: ShengHuo ZHU Date: Fri, 18 Jan 2002 17:40:43 +0000 Subject: [PATCH] 2002-01-18 TSUCHIYA Masatoshi * 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 | 14 +++++++++++++- lisp/gnus-art.el | 13 +++++++------ lisp/nneething.el | 30 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 013988e8f..546808ada 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,15 @@ +2002-01-18 TSUCHIYA Masatoshi + + * 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 * nnml.el (nnml-request-update-info): Don't erase flags that isn't @@ -4602,7 +4614,7 @@ 2001-06-03 Dale Hagglund * gnus-mlspl.el (gnus-group-split-fancy): Fix generation of split - restrict clauses. + restrict clauses. 2001-06-07 16:00:00 ShengHuo ZHU diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index 0ae3e5239..cdd2a0729 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -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)))))))) diff --git a/lisp/nneething.el b/lisp/nneething.el index 8ce10edee..9c30970fd 100644 --- a/lisp/nneething.el +++ b/lisp/nneething.el @@ -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 "\\`\\'" 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: \n" (if (equal '(0 0) (nth 5 atts)) "" (concat "Date: " (current-time-string (nth 5 atts)) "\n")) -- 2.34.1