* gnus-group.el (gnus-group-name-encode): New function.
[elisp/gnus.git-] / lisp / gnus-group.el
index e4e7bd7..fccd242 100644 (file)
@@ -1042,8 +1042,7 @@ The following commands are available:
       result)))
 
 (defun gnus-group-name-decode (string charset)
-  (if (and string charset (featurep 'mule)
-          (not (mm-multibyte-string-p string)))
+  (if (and string charset (featurep 'mule))
       (decode-coding-string string charset)
     string))
 
@@ -1051,6 +1050,39 @@ The following commands are available:
   (let ((charset (gnus-group-name-charset nil string)))
     (gnus-group-name-decode string charset)))
 
+(defun gnus-group-name-encode (string charset)
+  (if (and string charset (featurep 'mule))
+      (encode-coding-string string charset)
+    string))
+
+(defun gnus-group-encoded-name (string)
+  (let ((charset (gnus-group-name-charset nil string)))
+    (gnus-group-name-encode string charset)))
+
+(defun gnus-group-completing-read-group-name
+  (prompt table &optional predicate require-match initial-contents history)
+  (if (vectorp table)
+      (let ((decoded-table (make-vector (length table) 0)))
+       (mapatoms
+        (lambda (atom)
+          (set (intern (gnus-group-decoded-name (symbol-name atom))
+                       decoded-table)
+               (symbol-value atom)))
+        table)
+       (setq table decoded-table))
+    (setq table (mapcar
+                (lambda (entry)
+                  (cons (gnus-group-decoded-name
+                         (car entry))
+                        (cdr entry)))
+                table)))
+  (gnus-group-encoded-name
+   (completing-read
+    prompt table predicate
+    require-match
+    initial-contents
+    history)))
+
 (defun gnus-group-list-groups (&optional level unread lowest)
   "List newsgroups with level LEVEL or lower that have unread articles.
 Default is all subscribed groups.
@@ -1857,7 +1889,8 @@ be permanent."
 (defun gnus-fetch-group (group)
   "Start Gnus if necessary and enter GROUP.
 Returns whether the fetching was successful or not."
-  (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
+  (interactive (list (gnus-group-completing-read-group-name
+                     "Group name: " gnus-active-hashtb)))
   (unless (get-buffer gnus-group-buffer)
     (gnus-no-server))
   (gnus-group-read-group nil nil group))
@@ -1936,7 +1969,7 @@ Return the name of the group if selection was successful."
 (defun gnus-group-jump-to-group (group)
   "Jump to newsgroup GROUP."
   (interactive
-   (list (completing-read
+   (list (gnus-group-completing-read-group-name
          "Group: " gnus-active-hashtb nil
          (gnus-read-active-file-p)
          gnus-group-jump-to-group-prompt
@@ -2198,6 +2231,9 @@ doing the deletion."
          (gnus-group-goto-group group)
          (gnus-group-kill-group 1 t)
          (gnus-sethash group nil gnus-active-hashtb)
+         (when gnus-cache-active-hashtb
+           (gnus-sethash group nil gnus-cache-active-hashtb)
+           (setq gnus-cache-active-altered t))
          t))
     (gnus-group-position-point)))
 
@@ -3118,7 +3154,7 @@ If given numerical prefix, toggle the N next groups."
 Killed newsgroups are subscribed.  If SILENT, don't try to update the
 group line."
   (interactive
-   (list (completing-read
+   (list (gnus-group-completing-read-group-name
          "Group: " gnus-active-hashtb nil
          (gnus-read-active-file-p)
          nil
@@ -4051,7 +4087,9 @@ This command may read the active file."
              (while (<= n (cdr gnus-newsgroup-active))
                (unless (eq n article)
                  (push n gnus-newsgroup-unselected))
-               (setq n (1+ n))))))
+               (setq n (1+ n)))
+             (setq gnus-newsgroup-unselected
+                   (nreverse gnus-newsgroup-unselected)))))
       (gnus-activate-group group)
       (gnus-group-make-articles-read group
                                     (list article))