From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#35383: 27.0.50; Complete process of decoding Gnus group names Date: Sat, 18 May 2019 13:25:41 -0700 Message-ID: <87ef4v4iii.fsf@ericabrahamsen.net> References: <878sw1995f.fsf@ericabrahamsen.net> <87sgu87ayo.fsf@ericabrahamsen.net> <87woiuf6ya.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="261376"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 35383@debbugs.gnu.org To: Katsumi Yamaoka Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 18 22:26:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hS5uG-0015rG-0m for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 May 2019 22:26:12 +0200 Original-Received: from localhost ([127.0.0.1]:38357 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hS5uE-0002aG-QQ for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 May 2019 16:26:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hS5u7-0002Y6-Ru for bug-gnu-emacs@gnu.org; Sat, 18 May 2019 16:26:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hS5u6-0006zg-Dr for bug-gnu-emacs@gnu.org; Sat, 18 May 2019 16:26:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47721) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hS5u6-0006zX-9A for bug-gnu-emacs@gnu.org; Sat, 18 May 2019 16:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hS5u6-0005rb-4N for bug-gnu-emacs@gnu.org; Sat, 18 May 2019 16:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 May 2019 20:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35383 X-GNU-PR-Package: emacs Original-Received: via spool by 35383-submit@debbugs.gnu.org id=B35383.155821115222520 (code B ref 35383); Sat, 18 May 2019 20:26:02 +0000 Original-Received: (at 35383) by debbugs.gnu.org; 18 May 2019 20:25:52 +0000 Original-Received: from localhost ([127.0.0.1]:33032 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hS5tv-0005r9-Un for submit@debbugs.gnu.org; Sat, 18 May 2019 16:25:52 -0400 Original-Received: from ericabrahamsen.net ([52.70.2.18]:55666 helo=mail.ericabrahamsen.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hS5tu-0005qw-85 for 35383@debbugs.gnu.org; Sat, 18 May 2019 16:25:51 -0400 Original-Received: from localhost (97-113-32-199.tukw.qwest.net [97.113.32.199]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id DD2D8FA625; Sat, 18 May 2019 20:25:42 +0000 (UTC) In-Reply-To: <87woiuf6ya.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Mon, 13 May 2019 13:14:05 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159507 Archived-At: --=-=-= Content-Type: text/plain Eric Abrahamsen writes: > Katsumi Yamaoka writes: > >>> On 04/23/19 17:12 PM, Katsumi Yamaoka wrote: >>>> Though I'm not quite sure >>>> yet, the new and the old newsrc.eld files (containing non-ASCII >>>> nnml and nnrss groups) seem to be compatible with the new and >>>> the old Gnus mutually. >> >> Not mutually but one-way from old Gnus[1] to new Gnus[2] is ok. >> To activate the groups of the non-ASCII names for the old Gnus, >> I realized I needed to convert those group names to that of >> >> (prin1-to-string (encode-coding-string "Group Name" 'utf-8)) >> >> one by one in the .newsrc.eld file before starting the old Gnus. >> No other tweak is necessary to switch back to the old Gnus, and >> nothing to be done to switch to the new Gnus again. I verified >> it with only nnml and nnrss groups as I tried Gnus of the latest >> git master today for the first time in about a month. >> >> [1] currently that of the master and the emacs-26 branches >> [2] currentlt that of the scratch/gnus-decoded branch > > Thanks for the analysis. I think I only had nnimap groups that were > properly (utf-8) encoded in .newsrc.eld, but still worked with the "old" > Gnus code (in your sense, above). I guess that was different with > nnml/nnrss. > > I have some more group sorting issues to fix in the current master code, > then I'll call for testers for the scratch/gnus-decoded branch, then > hopefully this whole thing can go in. Before that, I realized that I hadn't updated some of the *Group* buffer sorting code, for sorting flat groups. The attached patch should go into master, and then master merged into scratch/gnus-decoded. Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=gnus-group-sorting.diff diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index c757c82fbc..4a14de33b0 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el @@ -3300,21 +3300,31 @@ gnus-group-sort-groups (funcall gnus-group-sort-alist-function (gnus-make-sort-function func) reverse) (gnus-group-unmark-all-groups) + ;; Redisplay all groups according to the newly-sorted order of + ;; `gnus-group-list'. (gnus-group-list-groups) (gnus-dribble-touch)) (defun gnus-group-sort-flat (func reverse) - ;; We peel off the dummy group from the alist. + "Sort groups in a flat list using sorting function FUNC. +If REVERSE is non-nil, reverse the sort order. + +This function sets a new value for `gnus-group-list'; its return +value is disregarded." (when func - (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group") - (pop gnus-newsrc-alist)) - ;; Do the sorting. - (setq gnus-newsrc-alist - (sort gnus-newsrc-alist func)) - (when reverse - (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))) - ;; Regenerate the hash table. - (gnus-make-hashtable-from-newsrc-alist))) + (let* ((groups (remove "dummy.group" gnus-group-list)) + (sorted-infos + (sort (mapcar (lambda (g) + (gnus-get-info g)) + groups) + func))) + (setq gnus-group-list + (mapcar (lambda (i) + (gnus-info-group i)) + sorted-infos)) + (when reverse + (setq gnus-group-list (nreverse gnus-group-list))) + (setq gnus-group-list (cons "dummy.group" gnus-group-list))))) (defun gnus-group-sort-groups-by-alphabet (&optional reverse) "Sort the group buffer alphabetically by group name. @@ -3377,27 +3387,26 @@ gnus-group-sort-selected-groups (gnus-dribble-touch))) (defun gnus-group-sort-selected-flat (groups func reverse) - (let (entries infos) - ;; First find all the group entries for these groups. - (while groups - (push (nthcdr 2 (gnus-group-entry (pop groups))) - entries)) - ;; Then sort the infos. - (setq infos - (sort - (mapcar - (lambda (entry) (car entry)) - (setq entries (nreverse entries))) - func)) + "Sort only the selected GROUPS, using FUNC. +If REVERSE is non-nil, reverse the sorting." + (let ((infos (sort + (mapcar (lambda (g) + (gnus-get-info g)) + groups) + func)) + sorted-groups) (when reverse (setq infos (nreverse infos))) - ;; Go through all the infos and replace the old entries - ;; with the new infos. - (while infos - (setcar (car entries) (pop infos)) - (pop entries)) - ;; Update the hashtable. - (gnus-make-hashtable-from-newsrc-alist))) + (setq sorted-groups (mapcar (lambda (i) (gnus-info-group i)) infos)) + + ;; Find the original locations of GROUPS in `gnus-group-list', and + ;; replace each one, in order, with a group from SORTED-GROUPS. + (dolist (i (sort (mapcar (lambda (g) + (seq-position gnus-group-list g)) + groups) + #'<)) + (setf (nth i gnus-group-list) + (pop sorted-groups))))) (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse) "Sort the group buffer alphabetically by group name. diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el index 2f8a260bf1..16d167613e 100644 --- a/lisp/gnus/gnus-start.el +++ b/lisp/gnus/gnus-start.el @@ -583,11 +583,11 @@ gnus-subscribe-randomly (defun gnus-subscribe-alphabetically (newgroup) "Subscribe new NEWGROUP and insert it in alphabetical order." - (let ((groups (cdr gnus-newsrc-alist)) + (let ((groups (cdr gnus-group-list)) before) (while (and (not before) groups) - (if (string< newgroup (caar groups)) - (setq before (caar groups)) + (if (string< newgroup (car groups)) + (setq before (car groups)) (setq groups (cdr groups)))) (gnus-subscribe-newsgroup newgroup before))) @@ -618,15 +618,15 @@ gnus-subscribe-interactively it is killed." (if (gnus-y-or-n-p (format "Subscribe new newsgroup %s? " group)) (gnus-subscribe-hierarchically group) - (push group gnus-killed-list))) + (gnus-subscribe-killed group))) (defun gnus-subscribe-zombies (group) "Make the new GROUP into a zombie group." - (push group gnus-zombie-list)) + (cl-pushnew group gnus-zombie-list :test #'equal)) (defun gnus-subscribe-killed (group) "Make the new GROUP a killed group." - (push group gnus-killed-list)) + (cl-pushnew group gnus-killed-list :test #'equal)) (defun gnus-subscribe-newsgroup (newsgroup &optional next) "Subscribe new NEWSGROUP. --=-=-=--