3.17 Accessing groups of non-English names

There are some news servers that provide groups of which the names are expressed with their native languages in the world. For instance, in a certain news server there are some newsgroups of which the names are spelled in Chinese, where people are talking in Chinese. You can, of course, subscribe to such news groups using Gnus. Currently Gnus supports non-ASCII group names not only with the nntp back end but also with the nnml back end and the nnrss back end.

Every such group name is encoded by a certain charset in the server side (in an NNTP server its administrator determines the charset, but for groups in the other back ends it is determined by you). Gnus has to display the decoded ones for you in the group buffer and the article buffer, and needs to use the encoded ones when communicating with servers. However, Gnus doesn’t know what charset is used for each non-ASCII group name. The following two variables are just the ones for telling Gnus what charset should be used for each group:

gnus-group-name-charset-method-alist

An alist of select methods and charsets. The default value is nil. The names of groups in the server specified by that select method are all supposed to use the corresponding charset. For example:

(setq gnus-group-name-charset-method-alist
      '(((nntp "news.com.cn") . cn-gb-2312)))

Charsets specified for groups with this variable are preferred to the ones specified for the same groups with the gnus-group-name-charset-group-alist variable (see below).

A select method can be very long, like:

(nntp "gmane"
      (nntp-address "news.gmane.io")
      (nntp-end-of-line "\n")
      (nntp-open-connection-function
       nntp-open-via-rlogin-and-telnet)
      (nntp-via-rlogin-command "ssh")
      (nntp-via-rlogin-command-switches
       ("-C" "-t" "-e" "none"))
      (nntp-via-address …))

In that case, you can truncate it into (nntp "gmane") in this variable. That is, it is enough to contain only the back end name and the server name.

gnus-group-name-charset-group-alist

An alist of regexp of group name and the charset for group names. ((".*" . utf-8)) is the default value if UTF-8 is supported, otherwise the default is nil. For example:

(setq gnus-group-name-charset-group-alist
      '(("\\.com\\.cn:" . cn-gb-2312)
        (".*" . utf-8)))

Note that this variable is ignored if the match is made with gnus-group-name-charset-method-alist.

Those two variables are used also to determine the charset for encoding and decoding non-ASCII group names that are in the back ends other than nntp. It means that it is you who determine it. If you do nothing, the charset used for group names in those back ends will all be utf-8 because of the last element of gnus-group-name-charset-group-alist.

There is one more important variable for non-ASCII group names:

nnmail-pathname-coding-system

The value of this variable should be a coding system or nil. The default is nil in Emacs.

The nnml back end, the nnrss back end, the agent, and the cache use non-ASCII group names in those files and directories. This variable overrides the value of file-name-coding-system which specifies the coding system used when encoding and decoding those file names and directory names.

Emacs uses the value of default-file-name-coding-system if file-name-coding-system is nil or it is bound to the value of nnmail-pathname-coding-system which is nil.

Normally the value of default-file-name-coding-system is initialized according to the locale, so you will need to do nothing if the value is suitable to encode and decode non-ASCII group names.

The value of this variable (or default-file-name-coding-system) does not necessarily need to be the same value that is determined by gnus-group-name-charset-method-alist and gnus-group-name-charset-group-alist.

If default-file-name-coding-system or this variable is initialized by default to iso-latin-1-unix for example, although you want to subscribe to the groups spelled in Chinese, that is the most typical case where you have to customize nnmail-pathname-coding-system. The utf-8-unix coding system is a good candidate for it. Otherwise, you may change the locale in your system so that default-file-name-coding-system or this variable may be initialized to an appropriate value.

Note that when you copy or move articles from a non-ASCII group to another group, the charset used to encode and decode group names should be the same in both groups. Otherwise the Newsgroups header will be displayed incorrectly in the article buffer.