Subject: bug#33263: 27.0.50; Tidying up Gnus modes

From: Noam Postavsky <[email-masked]>
Date: Tue, 06 Nov 2018 08:27:56 -0500

Eric Abrahamsen <[email-masked]> writes:

> Noam Postavsky <[email-masked]> writes:
>
>> Eric Abrahamsen <[email-masked]> writes:
>>
>>> +(defvar gnus-browse-mode-map (make-keymap))
>>>
>>>  (unless gnus-browse-mode-map
>>> -  (setq gnus-browse-mode-map (make-keymap))
>>> +  (defvar gnus-browse-mode-map (make-keymap))
>>
>> This doesn't look right.
>
> Hmm, you're right, I think I got confused there. TBH I don't really know
> why these things are wrapped in `unless', but I think what should have
> happened is that `gnus-browse-mode-map' is first defvar'ed to nil, and
> later setq'ed to (make-keymap).

The usual idiom for this is

    (defvar gnus-browse-mode-map
      (let ((map (make-sparse-keymap)))
        (define-key map ...)
        ...
        map))

It seems that (the expansion of) gnus-define-keys relies on dynamic
binding of the map variable (i.e., it must be called after the defvar,
not inside), so that's the reason to split in two parts.