From 5cc44cf1274330697cb353b2ad4a5f38e6a524f3 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Sat, 6 Oct 2001 21:04:47 +0000 Subject: [PATCH] 2001-10-06 Simon Josefsson 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 | 20 ++++++++++++++++++++ lisp/gnus-art.el | 19 ++++++++++++++++++- lisp/gnus-group.el | 4 +++- lisp/gnus-msg.el | 5 ++++- lisp/gnus-util.el | 8 ++++++++ lisp/message.el | 13 ++++++++----- 6 files changed, 61 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 076e72fbc..643961a5a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,23 @@ +2001-10-06 Simon Josefsson + + 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 * gnus-srvr.el (gnus-browse-foreign-server): Fixed bug non-nil diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index b87022cc7..8b89e95fa 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -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 diff --git a/lisp/gnus-group.el b/lisp/gnus-group.el index d2f94039b..30ccc493a 100644 --- a/lisp/gnus-group.el +++ b/lisp/gnus-group.el @@ -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) diff --git a/lisp/gnus-msg.el b/lisp/gnus-msg.el index c8402fa0c..f6d723601 100644 --- a/lisp/gnus-msg.el +++ b/lisp/gnus-msg.el @@ -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 diff --git a/lisp/gnus-util.el b/lisp/gnus-util.el index c599ba863..a3cb6c7b7 100644 --- a/lisp/gnus-util.el +++ b/lisp/gnus-util.el @@ -187,6 +187,14 @@ (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 diff --git a/lisp/message.el b/lisp/message.el index 53055bfd8..dcec026c7 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -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") -- 2.34.1