]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix insertion logic of newly subscribed Gnus groups
authorEric Abrahamsen <eric@ericabrahamsen.net>
Sun, 24 Jan 2021 18:09:05 +0000 (10:09 -0800)
committerEric Abrahamsen <eric@ericabrahamsen.net>
Sun, 24 Jan 2021 18:09:05 +0000 (10:09 -0800)
* lisp/gnus/gnus-start.el (gnus-subscribe-newsgroup): This was a
misunderstanding of the next/previous argument: no group should ever
be inserted before "dummy.group".
(gnus-group-change-level): Make it clearer that PREVIOUS can be
nil. In fact none of this code would error on a nil value, but it
_looks_ like nil is unexpected.

lisp/gnus/gnus-start.el

index fbdbf41dc059a1de80aeb99983aab631843af3f5..cf37a1ccdfca529b6a06190399d337dc970fe3d2 100644 (file)
@@ -637,7 +637,7 @@ the first newsgroup."
     ;; We subscribe the group by changing its level to `subscribed'.
     (gnus-group-change-level
      newsgroup gnus-level-default-subscribed
-     gnus-level-killed (or next "dummy.group"))
+     gnus-level-killed next)
     (gnus-request-update-group-status newsgroup 'subscribe)
     (gnus-message 5 "Subscribe newsgroup: %s" newsgroup)
     (run-hook-with-args 'gnus-subscribe-newsgroup-functions newsgroup)
@@ -1282,7 +1282,8 @@ string name) to insert this group before."
        (gnus-dribble-enter
         (format "(gnus-group-change-level %S %S %S %S %S)"
                 group level oldlevel
-                (cadr (member previous gnus-group-list))
+                (when previous
+                  (cadr (member previous gnus-group-list)))
                 fromkilled)))
 
       ;; Then we remove the newgroup from any old structures, if needed.
@@ -1341,9 +1342,10 @@ string name) to insert this group before."
          ;; at the head of `gnus-newsrc-alist'.
          (push info (cdr gnus-newsrc-alist))
          (puthash group (list num info) gnus-newsrc-hashtb)
-         (when (stringp previous)
+         (when (and previous (stringp previous))
            (setq previous (gnus-group-entry previous)))
-         (let ((idx (or (seq-position gnus-group-list (caadr previous))
+         (let ((idx (or (and previous
+                             (seq-position gnus-group-list (caadr previous)))
                         (length gnus-group-list))))
            (push group (nthcdr idx gnus-group-list)))
          (gnus-dribble-enter