Subject: 28.0.50; minor mode keymaps should not override keymap given to read-from-minibuffer

From: Jimmy Yuen Ho Wong <[email-masked]>
Date: Sun, 02 May 2021 07:58:32 +0100

After typing C-x b or C-x C-f, the minor mode maps from the buffer that launched
the minibuffer will override the keymap given to `read-from-minibuffer`,
this seems to be a regression in emacs 28 master.

Reproduction:

1. Turn on `ido-mode`
2. Turn on some minor mode that rebinds `C-k` with `(define-key
some-minor-mode-map (kbd "C-k") 'some-func)`
3. C-x b
4. Select a buffer and type C-k

Expectation:

C-k should be bound to `ido-kill-buffer-at-head` and calls it, but
instead `some-func` is called.

Since C-k is bound in `ido-completion-map`, and it is given to
`read-from-minibuffer`, all the bindings in `ido-completion-map` should
take precedence.

Additional info:

After some debugging with `enable-recursive-minibuffers`, I typed
Shift-Meta-; to open a recursive eval buffer inside the
`ido-switch-buffer` buffer, `(cl-loop for buf in (buffer-list) if
(minibufferp buf) do (with-current-buffer buf (key-binding (kbd
"C-k"))))` reveals that indeed C-k isn't bound inside any minibuffer
buffers.

In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.4.0, NS appkit-2022.44 Version 11.3 (Build 20E232))
 of 2021-05-02 built on mg559.lan
Repository revision: f1adb6b77a948e4f2f3223940edb15e56c30466d
Repository branch: HEAD
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.3

Configured using:
 'configure --prefix=/opt/local --disable-silent-rules --without-dbus
 --without-gconf --without-libotf --without-m17n-flt --with-gmp
 --with-gnutls --with-json --with-xml2 --with-modules --infodir
 /opt/local/share/info/emacs --with-ns --with-lcms2 --without-harfbuzz
 --without-imagemagick --without-xaw3d --with-native-compilation
 --with-rsvg 'CFLAGS=-pipe -Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -arch
 x86_64' 'CPPFLAGS=-I/opt/local/include
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk'
 'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-no_pie
 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk
 -arch x86_64''

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE NS PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM
ZLIB

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

Major mode: ELisp/l

Minor modes in effect:
  projectile-rails-global-mode: t
  projectile-mode: t
  eldoc-box-hover-at-point-mode: t
  company-box-mode: t
  company-prescient-mode: t
  prescient-persist-mode: t
  rainbow-mode: t
  elisp-def-mode: t
  display-line-numbers-mode: t
  subword-mode: t
  form-feed-mode: t
  beginend-prog-mode: t
  imenu-list-minor-mode: t
  purpose-mode: t
  diff-hl-flydiff-mode: t
  crm-custom-mode: t
  override-global-mode: t
  dap-tooltip-mode: t
  dap-ui-many-windows-mode: t
  dap-ui-controls-mode: t
  dap-ui-mode: t
  treemacs-filewatch-mode: t
  treemacs-follow-mode: t
  treemacs-git-mode: deferred
  treemacs-fringe-indicator-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  winner-mode: t
  which-key-mode: t
  which-function-mode: t
  smooth-scrolling-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  show-paren-mode: t
  server-mode: t
  savehist-mode: t
  save-place-mode: t
  rxt-global-mode: t
  rxt-mode: t
  recentf-mode: t
  minibuffer-depth-indicate-mode: t
  ido-vertical-mode: t
  ido-ubiquitous-mode: t
  global-whitespace-cleanup-mode: t
  whitespace-cleanup-mode: t
  global-tree-sitter-mode: t
  global-so-long-mode: t
  global-origami-mode: t
  origami-mode: t
  global-move-dup-mode: t
  move-dup-mode: t
  global-flycheck-mode: t
  global-diff-hl-show-hunk-mouse-mode: t
  diff-hl-show-hunk-mouse-mode: t
  global-diff-hl-mode: t
  diff-hl-mode: t
  global-company-mode: t
  company-mode: t
  global-auto-revert-mode: t
  flx-ido-mode: t
  ido-everywhere: t
  icomplete-vertical-mode: t
  icomplete-mode: t
  fido-mode: t
  editorconfig-mode: t
  desktop-save-mode: t
  delete-selection-mode: t
  dap-auto-configure-mode: t
  dap-mode: t
  yas-minor-mode: t
  auto-compile-on-save-mode: t
  auto-compile-mode: t
  amx-mode: t
  abridge-diff-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  window-divider-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  buffer-read-only: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Load-path shadows:
/opt/local/share/emacs/site-lisp/cmake-mode hides /Users/jimmyyuenhowong/.emacs.d/elpa/cmake-mode-20210104.1831/cmake-mode
/Users/jimmyyuenhowong/.emacs.d/elpa/transient-20210426.2141/transient hides /Applications/MacPorts/Emacs.app/Contents/Resources/lisp/transient

Features:
(shadow sort mail-extr emacsbug sendmail visual-regexp-steroids
visual-regexp misearch multi-isearch tabify cl-print jka-compr helpful
trace edebug info-look elisp-refs two-column vc-mtn vc-hg vc-bzr vc-src
vc-sccs vc-svn vc-cvs vc-rcs diff-hl-dired all-the-icons-dired
dired-collapse dired-hacks-utils projectile-rails rake inflections
inf-ruby smartparens-ruby ruby-mode smie autoinsert projectile vc-git
eldoc-box company-box company-box-doc frame-local company-box-icons
dash-functional company-prescient prescient company-keywords
company-etags etags fileloop generator company-gtags
company-dabbrev-code company-dabbrev company-yasnippet company-capf
company-files company-cmake company-clang company-semantic
company-template company-bbdb rainbow-mode elisp-def ert debug backtrace
display-line-numbers cap-words superword subword smartparens-config
smartparens-javascript smartparens-markdown smartparens-text
smartparens-c form-feed editorconfig-core editorconfig-core-handle
editorconfig-fnmatch beginend window-purpose-x shut-up imenu-list
hideshow window-purpose window-purpose-fixes
window-purpose-prefix-overload window-purpose-switch
window-purpose-layout window-purpose-core window-purpose-configuration
eieio-compat window-purpose-utils windmove dired-hide-dotfiles
shrink-path magit-lfs forge-list forge-commands forge-semi
forge-bitbucket buck forge-gogs gogs forge-gitea gtea forge-gitlab glab
forge-github ghub-graphql treepy gsexp ghub let-alist gnutls
forge-notify forge-revnote forge-pullreq forge-issue forge-topic
bug-reference forge-post forge-repo forge forge-core forge-db closql
magit-submodule magit-obsolete magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log diff-hl-flydiff
ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init
ediff-util dumb-jump popup rg rg-info-hack rg-menu rg-ibuffer rg-result
wgrep-rg wgrep rg-history rg-header ibuf-ext ibuffer ibuffer-loaddefs
grep lsp-metals view lsp-metals-treeview lsp-metals-protocol yard-mode
typescript-mode json-mode json-reformat json-snatcher js cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs reformatter cl-lib-highlight eterm-256color term disp-table
ehelp xterm-color native-complete emacsql-sqlite emacsql
emacsql-compiler url-http url-auth url-gw lsp-sourcekit lsp lsp-pyright
lsp-jedi tree-sitter-langs tree-sitter-langs-build tar-mode arc-mode
archive-mode tree-sitter-hl iedit iedit-lib mc-hide-unmatched-lines-mode
mc-mark-more mc-cycle-cursors multiple-cursors-core rect
icomplete-vertical crm-custom pager-default-keybindings pager
browse-kill-ring paradox paradox-menu paradox-commit-list
paradox-execute paradox-github paradox-core parse-time iso8601
use-package-bind-key bind-key use-package-delight osx-trash
exec-path-from-shell all-the-icons all-the-icons-faces data-material
data-weathericons data-octicons data-fileicons data-faicons
data-alltheicons spaceline-config spaceline-segments spaceline powerline
powerline-separators powerline-themes solarized-dark-theme
solarized-theme solarized solarized-faces delight quelpa-use-package
use-package-core quelpa lisp-mnt help-fns radix-tree dap-mouse dap-ui
lsp-treemacs lsp-treemacs-themes treemacs treemacs-header-line
treemacs-compatibility treemacs-mode treemacs-interface
treemacs-extensions treemacs-mouse-interface treemacs-tags
treemacs-persistence treemacs-filewatch-mode treemacs-follow-mode
treemacs-rendering treemacs-async treemacs-workspaces treemacs-dom
treemacs-visuals treemacs-fringe-indicator treemacs-scope pulse
treemacs-faces treemacs-icons treemacs-themes treemacs-core-utils
pfuture hl-line treemacs-logging treemacs-customization treemacs-macros
gdb-mi gud bui bui-list bui-info bui-entry bui-core bui-history
bui-button bui-utils lsp-lens magit-diff smerge-mode diff git-commit
log-edit message rfc822 mml mml-sec epa derived gnus-util rmail
rmail-loaddefs time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev
mail-utils gmm-utils mailheader add-log magit-core magit-autorevert
magit-margin magit-transient magit-process with-editor shell pcomplete
magit-mode transient format-spec magit-git magit-section magit-utils crm
winner which-key which-func smooth-scrolling smartparens paren server
savehist saveplace pcre2el rxt re-builder recentf mb-depth
ido-vertical-mode ido-completing-read+ memoize cus-edit pp minibuf-eldef
help-at-pt whitespace-cleanup-mode whitespace tree-sitter
tree-sitter-load tree-sitter-cli tsc tsc-dyn tsc-dyn-get dired-aux dired
dired-loaddefs tsc-obsolete so-long origami origami-parsers move-dup
flycheck find-func diff-hl-show-hunk diff-hl-inline-popup diff-hl
log-view pcvs-util vc-dir vc vc-dispatcher diff-mode company autorevert
flx-ido advice flx ido icomplete editorconfig desktop frameset delsel
dap-mode dap-launch posframe dap-overlays lsp-mode lsp-protocol
yasnippet-snippets yasnippet xref project tree-widget wid-edit spinner
network-stream puny nsm rmc markdown-mode color thingatpt noutline
outline easy-mmode lv inline imenu ht filenotify f ewoc epg epg-config
dash compile text-property-search comint ansi-color ring auto-compile
packed amx s abridge-diff cus-load edmacro kmacro cl info package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap url-handlers url-parse
auth-source eieio eieio-core eieio-loaddefs password-cache json map
url-vars comp comp-cstr warnings subr-x rx cl-seq cl-macs cl-extra
help-mode seq byte-opt bytecomp byte-compile cconv gv pcase cl-loaddefs
cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-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 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 kqueue cocoa ns lcms2
multi-tty make-network-process nativecomp emacs)

Memory information:
((conses 16 1144104 503139)
 (symbols 48 53507 0)
 (strings 32 202614 92506)
 (string-bytes 1 7453813)
 (vectors 16 153419)
 (vector-slots 8 3884557 589614)
 (floats 8 2540 3047)
 (intervals 56 8434 5150)
 (buffers 992 29))