Subject: 29.0.60; help-quick should use C-/ for undo

From: Philip Kaludercic <[email-masked]>
Date: Thu, 15 Dec 2022 19:21:34 +0000

The new help-quick command makes use of `where-is-internal' to find the
binding for a command ti displays.  This works fine if a command has
only one binding, but in the case of `undo', C-_ is the first one it
suggests, since

    (mapcar #'key-description (where-is-internal 'undo))
    ;; => ("C-_" "<undo>" "C-/" "<menu-bar> <edit> <undo>")

    (key-description (where-is-internal 'undo nil t))
    ;; => "C-_"

It appears this issue can be resolved by setting

    (setq where-is-preferred-modifier 'C)

    (mapcar #'key-description (where-is-internal 'undo))
    ;; => ("C-_" "<undo>" "C-/" "<menu-bar> <edit> <undo>")

    (key-description (where-is-internal 'undo nil t))
    ;; => "C-/"

But to be honest, I don't understand why, nor do I think the solution is
particularly robust.

I think some general mechanism to associate preferred binding with keys
would be nice to have.  What I wonder is if this is general enough of a
use-case to be added to where-is-internal, or should this be fixed
inside of help-quick?

The other issue is how does one determine what binding is preferable.  I
had previously generalised that C-/ is obviously preferable, but that
differs from layout to layout and depending on what keys Emacs can even
detect (I believe C-x u is often the only key that can be used in TUI
mode).

In GNU Emacs 29.0.60 (build 5, x86_64-pc-linux-gnu, GTK+ Version
 3.24.35, cairo version 1.16.0) of 2022-12-14 built on quetzal
Repository revision: 622838b957e240d700585050e9ddbd036e690513
Repository branch: emacs-29
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --with-pgtk --with-imagemagick'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
IMAGEMAGICK JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES
NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER XIM GTK3 ZLIB

Important settings:
  value of $EMACSLOADPATH: 
  value of $LC_MONETARY: en_US.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LC_TIME: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  rcirc-color-mode: t
  rcirc-track-minor-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  server-mode: t
  shell-dirtrack-mode: t
  editorconfig-mode: t
  repeat-mode: t
  display-battery-mode: t
  display-time-mode: t
  diff-hl-flydiff-mode: t
  winner-mode: t
  windmove-mode: t
  corfu-history-mode: t
  vertico-multiform-mode: t
  vertico-mode: t
  electric-pair-mode: t
  recentf-mode: t
  save-place-mode: t
  savehist-mode: t
  pixel-scroll-precision-mode: t
  pixel-scroll-mode: t
  xterm-mouse-mode: t
  which-function-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/philip/.config/emacs/site-lisp/sbbs-pld/sbbs hides /home/philip/.config/emacs/site-lisp/sbbs/sbbs
/home/philip/.config/emacs/site-lisp/flymake-proselint/flymake-proselint hides /home/philip/.config/emacs/elpa/flymake-proselint-0.3.0/flymake-proselint
/home/philip/.config/emacs/site-lisp/writegood-mode/writegood-mode hides /home/philip/.config/emacs/elpa/writegood-mode-2.2.0/writegood-mode
/home/philip/.config/emacs/site-lisp/writegood-mode/writegood-mode-autoloads hides /home/philip/.config/emacs/elpa/writegood-mode-2.2.0/writegood-mode-autoloads
/home/philip/.config/emacs/site-lisp/writegood-mode/writegood-mode-pkg hides /home/philip/.config/emacs/elpa/writegood-mode-2.2.0/writegood-mode-pkg
/home/philip/.config/emacs/elpa/transient-0.3.7/transient hides /home/philip/Source/emacs/lisp/transient

Features:
(shadow emacsbug tutorial goto-addr emacs-authors-mode view find-dired
macrostep flymake-proselint mhtml-mode css-mode js sgml-mode facemenu
trace flow-fill ibuf-ext flymake-cc ox-texinfo org-timer org-tempo
org-protocol org-num org-lint org-feed org-datetree org-colview
org-duration org-capture org-attach-git org-archive test-ox
org-inlinetask ob-sed ob-plantuml ob-lilypond org-test ert-x org-clock
tempo ox-odt rng-loc rng-uri rng-parse rng-match rng-pttrn nxml-parse
nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar ox-html table
ox-ascii ox-publish ox org-agenda org-attach esh-mode ob-sql geiser
python ob-octave eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg
esh-module esh-groups esh-util calc-store calc-trail calc-ext calc
calc-loaddefs rect calc-macs cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs org-autoloads avy 0x0
0x0-autoloads tar-mode arc-mode archive-mode term/xterm xterm eat ert
eat-autoloads nndoc gnus-dup debbugs-gnu debbugs-compat debbugs
soap-client rng-xsd rng-dt rng-util xsd-regexp rcirc-color rcirc
cap-words superword subword go-mode find-file etags fileloop nroff-mode
org-element org-persist org-id org-refile avl-tree generator oc-basic
ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus
nnselect ol-docview doc-view jka-compr image-mode exif ol-bibtex bibtex
ol-bbdb ol-w3m ol-doi org-link-doi org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-src ob-comint org-pcomplete org-list
org-footnote org-faces org-entities ob-emacs-lisp ob-core ob-eval
org-cycle org-table ol org-fold org-fold-core org-keys oc org-loaddefs
cal-menu calendar cal-loaddefs org-version org-compat org-macs
modus-vivendi-theme vc-filewise follow magit-extras face-remap
magit-bookmark 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
magit-diff git-commit log-edit add-log magit-core magit-autorevert
autorevert filenotify magit-margin magit-transient magit-process
with-editor server magit-mode transient edmacro magit-git magit-section
magit-utils crm dash vc-src vc-sccs vc-cvs vc-rcs vertico-buffer
mailalias smtpmail ecomplete bug-reference dictionary
dictionary-connection ibuffer ibuffer-loaddefs whitespace vc-annotate
descr-text pulse color shortdoc ffap edebug reposition consult-imenu
cl-print debug backtrace find-func grep agda2-mode xref agda2-abbrevs
skeleton agda2-highlight agda2 agda-input quail eri char-fold misearch
multi-isearch smerge-mode mule-util package-vc inline url-cache url-http
url-auth url-gw display-line-numbers vc-hg vc-bzr vertico-directory
sh-script smie treesit executable orderless vertico-flat vc-svn vc-git
tramp-cache tramp-sh tramp tramp-loaddefs trampver tramp-integration
cus-start tramp-compat shell pcomplete ls-lisp consult-register
consult-vertico consult compat-28 kmacro bookmark files-x vc-backup
copyright time-stamp mm-archive dired-aux gnus-dired buffer-env compat
compat-macs sort smiley gnus-cite mail-extr textsec uni-scripts
idna-mapping ucs-normalize uni-confusable textsec-check gnus-async
gnus-bcklg qp gnus-ml disp-table nndraft nnmh utf-7 nnfolder epa-file
network-stream nsm gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig nntp
gnus-cache gnus-sum shr pixel-fill kinsoku url-file svg dom gnus-group
gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7
nnoo parse-time iso8601 gnus-spec gnus-int gnus-range message yank-media
puny dired-x dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader gnus-win noutline outline checkdoc
flymake-proc flymake yasnippet-snippets warnings yasnippet editorconfig
editorconfig-core editorconfig-core-handle editorconfig-fnmatch flyspell
ispell init repeat project format-spec battery dbus xml shell-command+
thingatpt rx time sendmail rfc2047 rfc2045 ietf-drums gnus nnheader
gnus-util time-date mail-utils range mm-util mail-prsvr finder-inf
diff-hl-flydiff diff diff-hl log-view pcvs-util vc-dir ewoc vc
vc-dispatcher diff-mode easy-mmode hippie-exp winner windmove
corfu-history corfu vertico-multiform vertico cl-extra elec-pair recentf
tree-widget saveplace savehist pixel-scroll cua-base xt-mouse
modus-operandi-theme modus-themes pcase which-func imenu cus-edit pp
cus-load icons wid-edit 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 cl-seq eieio eieio-core
cl-macs password-cache json subr-x map byte-opt gv url-vars setup
site-lisp auto-site compile text-property-search comint ansi-osc
ansi-color bytecomp byte-compile loaddefs-gen generate-lisp-file
lisp-mnt info caml-autoloads consult-autoloads
flymake-proselint-autoloads corfu-autoloads diff-hl-autoloads
focus-autoloads haskell-mode-autoloads buffer-env-autoloads
avy-autoloads yasnippet-snippets-autoloads magit-autoloads
geiser-mit-autoloads inspector-autoloads bash-completion-autoloads
ef-themes-autoloads auctex-autoloads tex-site git-commit-autoloads
with-editor-autoloads geiser-guile-autoloads geiser-impl help-fns
radix-tree help-mode cl-loaddefs cl-lib geiser-custom geiser-base ring
geiser-autoloads transient-autoloads magit-section-autoloads
vertico-autoloads debbugs-autoloads compat-autoloads
editorconfig-autoloads rcirc-color-autoloads orderless-autoloads
yasnippet-autoloads markdown-mode-autoloads slime-autoloads
macrostep-autoloads writegood-mode-autoloads go-mode-autoloads
dash-autoloads rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win pgtk-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 nadvice seq simple cl-generic
indonesian philippine 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 abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk pgtk
lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 2434927 285156)
 (symbols 48 80808 3175)
 (strings 32 393048 106951)
 (string-bytes 1 11497968)
 (vectors 16 174618)
 (vector-slots 8 3411953 405729)
 (floats 8 3321 2460)
 (intervals 56 128930 7495)
 (buffers 984 158))