2001-10-06 Simon Josefsson <jas@extundo.com>
authorSimon Josefsson <jas@extundo.com>
Sat, 6 Oct 2001 21:04:47 +0000 (21:04 +0000)
committerSimon Josefsson <jas@extundo.com>
Sat, 6 Oct 2001 21:04:47 +0000 (21:04 +0000)
Support UTF-8 group names better.

* message.el (message-check-news-header-syntax): Encode group
names before comparison.

* gnus-msg.el (gnus-copy-article-buffer): Run all
`gnus-article-decode-hook's except `article-decode-charset'
instead of hardcoding call to one of them.

* gnus-art.el (gnus-article-decode-hook): Add
`article-decode-group-name'.
(article-decode-group-name): New function, use `g-d-n'.

* gnus-group.el (gnus-group-insert-group-line): Decode
gnus-tmp-group using `g-d-n'.

* gnus-util.el (gnus-decode-newsgroups): New function.

lisp/ChangeLog
lisp/gnus-art.el
lisp/gnus-group.el
lisp/gnus-msg.el
lisp/gnus-util.el
lisp/message.el

index 076e72f..643961a 100644 (file)
@@ -1,3 +1,23 @@
+2001-10-06  Simon Josefsson  <jas@extundo.com>
+
+       Support UTF-8 group names better.
+       
+       * message.el (message-check-news-header-syntax): Encode group
+       names before comparison.
+
+       * gnus-msg.el (gnus-copy-article-buffer): Run all
+       `gnus-article-decode-hook's except `article-decode-charset'
+       instead of hardcoding call to one of them.
+
+       * gnus-art.el (gnus-article-decode-hook): Add
+       `article-decode-group-name'.
+       (article-decode-group-name): New function, use `g-d-n'.
+
+       * gnus-group.el (gnus-group-insert-group-line): Decode
+       gnus-tmp-group using `g-d-n'.
+
+       * gnus-util.el (gnus-decode-newsgroups): New function.
+
 2001-10-06  Per Abrahamsen  <abraham@dina.kvl.dk>
 
        * gnus-srvr.el (gnus-browse-foreign-server): Fixed bug non-nil
index b87022c..8b89e95 100644 (file)
@@ -638,7 +638,8 @@ displayed by the first non-nil matching CONTENT face."
                               (face :value default)))))
 
 (defcustom gnus-article-decode-hook
-  '(article-decode-charset article-decode-encoded-words)
+  '(article-decode-charset article-decode-encoded-words
+                          article-decode-group-name)
   "*Hook run to decode charsets in articles."
   :group 'gnus-article-headers
   :type 'hook)
@@ -1754,6 +1755,22 @@ If PROMPT (the prefix), prompt for a coding system to use."
       (article-narrow-to-head)
       (funcall gnus-decode-header-function (point-min) (point-max)))))
 
+(defun article-decode-group-name ()
+  "Decode group names in `Newsgroups:'."
+  (let ((inhibit-point-motion-hooks t)
+       buffer-read-only
+       (method (gnus-find-method-for-group gnus-newsgroup-name)))
+    (when (and (or gnus-group-name-charset-method-alist
+                  gnus-group-name-charset-group-alist)
+              (gnus-buffer-live-p gnus-original-article-buffer)
+              (mail-fetch-field "Newsgroups"))
+      (nnheader-replace-header "Newsgroups"
+                              (gnus-decode-newsgroups
+                               (with-current-buffer
+                                   gnus-original-article-buffer
+                                 (mail-fetch-field "Newsgroups"))
+                               gnus-newsgroup-name method)))))
+
 (defun article-de-quoted-unreadable (&optional force read-charset)
   "Translate a quoted-printable-encoded article.
 If FORCE, decode the article whether it is marked as quoted-printable
index d2f9403..30ccc49 100644 (file)
@@ -1339,7 +1339,9 @@ if it is a string, only list groups matching REGEXP."
      (point)
      (prog1 (1+ (point))
        ;; Insert the text.
-       (eval gnus-group-line-format-spec))
+       (let ((gnus-tmp-group (gnus-group-name-decode
+                             gnus-tmp-group group-name-charset)))
+        (eval gnus-group-line-format-spec)))
      `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
                  gnus-unread ,(if (numberp number)
                                   (string-to-int gnus-tmp-number-of-unread)
index c8402fa..f6d7236 100644 (file)
@@ -579,7 +579,10 @@ header line with the old Message-ID."
                           (or (message-goto-body) (point-max)))
            ;; Insert the original article headers.
            (insert-buffer-substring gnus-original-article-buffer beg end)
-           (article-decode-encoded-words))))
+           ;; Decode charsets.
+           (let ((gnus-article-decode-hook
+                  (delq 'article-decode-charset gnus-article-decode-hook)))
+             (run-hooks 'gnus-article-decode-hook)))))
       gnus-article-copy)))
 
 (defun gnus-post-news (post &optional group header article-buffer yank subject
index c599ba8..a3cb6c7 100644 (file)
                   (search-forward ":" eol t)
                   (point)))))
 
+(defun gnus-decode-newsgroups (newsgroups group &optional method)
+  (let ((method (or method (gnus-find-method-for-group group))))
+    (mapconcat (lambda (group)
+                (gnus-group-name-decode group (gnus-group-name-charset
+                                               method group)))
+              (message-tokenize-header newsgroups ", ")
+              ", ")))
+
 (defun gnus-remove-text-with-property (prop)
   "Delete all text in the current buffer with text property PROP."
   (save-excursion
index 53055bf..dcec026 100644 (file)
@@ -2915,12 +2915,15 @@ to find out how to use this."
                     (if followup-to
                         (concat newsgroups "," followup-to)
                       newsgroups)))
+           (method (if (message-functionp message-post-method)
+                       (funcall message-post-method)
+                     message-post-method))
            (known-groups
-            (mapcar (lambda (n) (gnus-group-real-name n))
-                    (gnus-groups-from-server
-                     (if (message-functionp message-post-method)
-                         (funcall message-post-method)
-                       message-post-method))))
+            (mapcar (lambda (n)
+                      (gnus-group-name-decode 
+                       (gnus-group-real-name n)
+                       (gnus-group-name-charset method n)))
+                    (gnus-groups-from-server method)))
            errors)
        (while groups
         (unless (or (equal (car groups) "poster")