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

From: Daniel Mendler <[email-masked]>
Date: Fri, 31 Dec 2021 00:29:49 +0100

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.

Debugger entered--Lisp error: (wrong-type-argument keymapp (nil))
  where-is-internal(pr-ps-file-preview (nil))
  #f(compiled-function (symbol buffer) #<bytecode
-0xfe888ceef865b96>)(pr-ps-file-preview #<buffer *scratch*>)
  #f(compiled-function (sym) #<bytecode
-0xe7f2f8368079eff>)(pr-ps-file-preview)
  #f(compiled-function (sym) #<bytecode
0x1b9587ed05cbdcf8>)(pr-ps-file-preview)
  try-completion("" ...)
  funcall-interactively(minibuffer-complete)
  command-execute(minibuffer-complete)
  completing-read-default("M-X " #<subr
F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49>
#f(compiled-function (sym) #<bytecode -0xe7f2f8368079eff>) t nil
extended-command-history nil nil)
  read-extended-command()
  byte-code("\304\30\305 \306\307\310\311\11\"\"B\312\313\2\"\32\13\314
\10E*\207" [execute-extended-command--last-typed minor-mode-map-alist
read-extended-command-predicate current-prefix-arg nil current-local-map
mapcar cdr seq-filter #f(compiled-function (elem) #<bytecode
0x11708780893b0c99>) make-closure #f(compiled-function (symbol buffer)
#<bytecode -0x7e5012e94bc5b96>) read-extended-command] 6)
  command-execute(execute-extended-command-for-buffer)

In GNU Emacs 28.0.90 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5,
cairo version 1.16.0)
 of 2021-12-23 built on projects
Repository revision: 1e578267fb19208504d28253e0c892ceb9a34fb4
Repository branch: emacs-28
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux 10 (buster)

Configured using:
 'configure --prefix=/home/user/emacs/install --with-cairo --with-json
 --with-native-compilation --with-xwidgets'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cache json map text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail comp comp-cstr warnings subr-x rx cl-seq cl-macs cl-extra
help-mode cl-loaddefs cl-lib rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils seq byte-opt gv bytecomp byte-compile cconv
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads
xwidget-internal dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 86561 9432)
 (symbols 48 7859 1)
 (strings 32 21679 3028)
 (string-bytes 1 755602)
 (vectors 16 16666)
 (vector-slots 8 312728 15391)
 (floats 8 28 33)
 (intervals 56 242 0)
 (buffers 992 12))