Subject: bug#52907: 28.0.90; M-X is broken if (current-local-map)=nil

From: Daniel Mendler <[email-masked]>
Date: Sat, 15 Jan 2022 15:29:54 +0100

On 1/15/22 10:48, Lars Ingebrigtsen wrote:
>> 1. Start emacs -Q
>>
>> 2. Define in the scratch buffer
>>    (defun broken-command ()
>>      (interactive fundamental-mode))
>>
>> 3. Switch to fundamental mode
>>    (fundamental-mode)
>>
>> 4. M-X brok TAB ===> Error (see below)
>>
>> The problem is that the (current-local-map) is nil. This breaks
>> the predicate of execute-extended-command-for-buffer.

There are no additional steps. I can still reproduce this in Emacs 28.
The problematic definition is:

          (keymaps
           ;; The major mode's keymap and any active minor modes.
           (cons
            (current-local-map) ;; can be nil!
            (mapcar
             #'cdr
             (seq-filter
              (lambda (elem)
                (symbol-value (car elem)))
              minor-mode-map-alist))))

The map is nil, when I evaluate in the scratch buffer:

1. (fundamental-mode)
2. (current-local-map) -> returns nil

I haven't tried 29 yet, but the problematic definition is still present
there. However maybe where-is-internal has been changed to accept nil
keymaps?