branch: externals/transient
commit 7d08039c44f04f28e80718e3c22acf522b2d4baf
Author: Jonas Bernoulli <jo...@bernoul.li>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    transient-common-command-prefix: New option
---
 docs/transient.org  | 139 ++++++++++++++++++++++-----------------------------
 docs/transient.texi | 139 ++++++++++++++++++++++-----------------------------
 lisp/transient.el   | 140 ++++++++++++++++++++++++++++++++++------------------
 3 files changed, 212 insertions(+), 206 deletions(-)

diff --git a/docs/transient.org b/docs/transient.org
index 0f978ca867..243a45ddc7 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -188,33 +188,56 @@ documentation string.
 #+cindex: common suffix commands
 
 A few shared suffix commands are available in all transients.  These
-suffix commands are not shown in the popup buffer by default.
+suffix commands are not shown permanently in every menu by default.
+Most of these commands share a common prefix key and pressing that key
+causes the common commands to be temporarily shown in the active menu.
 
-This includes the aborting commands mentioned in the previous section,
-as well as some other commands that are all bound to {{{kbdvar(C-x <KEY>)}}}.  
After
-{{{kbd(C-x)}}} is pressed, a section featuring all these common commands is
-temporarily shown in the popup buffer.  After invoking one of them,
-the section disappears again.  Note, however, that one of these
-commands is described as “Show common permanently”; invoke that if you
-want the common commands to always be shown for all transients.
+- User Option: transient-show-common-commands ::
 
-- Key: C-x t (transient-toggle-common) ::
+  This option controls whether shared suffix commands are permanently
+  shown alongside the menu-specific infix and suffix commands.  By
+  default, the shared commands are not permanently shown to avoid
+  wasting precious space and overwhelming the user with too many
+  choices.
 
-  This command toggles whether the generic commands that are common to
-  all transients are always displayed or only after typing the
-  incomplete prefix key sequence {{{kbd(C-x)}}}.  This only affects the current
-  Emacs session.
+  If you prefer to always see these commands, then set this option to
+  a non-~nil~ value.  Alternatively the value can be toggled for the
+  current Emacs session only, using ~transient-toggle-common~, described
+  below.
 
-- User Option: transient-show-common-commands ::
+- User Option: transient-common-command-prefix ::
+
+  This option specifies the prefix key used in all transient menus
+  to invoke most of the shared commands, which are available in all
+  transient menus.  By default these bindings are only shown after
+  pressing that prefix key and before following that up with a valid
+  key binding (but see the previous option).
+
+  For historic reasons {{{kbd(C-x)}}} is used by default, but users are
+  encouraged to pick another key, preferably one that is not commonly
+  used in Emacs but is still convenient to them.
+
+  Usually, while a transient menu is active, the user cannot invoke
+  commands that are not bound in the menu itself.  For those menus it
+  does not matter, if {{{kbd(C-x)}}} or another commonly used prefix key is 
used
+  for common menu commands.  However, certain other, newer menus do
+  not suppress key bindings established outside the menu itself, and
+  in those cases a binding for a common menu command could shadow an
+  external binding.  For example, {{{kbd(C-x C-s)}}} could not be used to 
invoke
+  ~save-buffer~, if that binding is shadowed by the menu binding for
+  ~transient-save~.
+
+  Which key is most suitable depends on the user's preferences, but
+  good choices may include function keys and {{{kbd(C-z)}}} (for many keyboard
+  layouts {{{kbd(z)}}} is right next to {{{kbd(x)}}}, and invoking 
~suspend-frame~, while a
+  transient menu is active, would not be a good idea anyway).
 
-  This option controls whether shared suffix commands are shown
-  alongside the transient-specific infix and suffix commands.  By
-  default, the shared commands are not shown to avoid overwhelming
-  the user with too many options.
+- Key: C-x t (transient-toggle-common) ::
 
-  While a transient is active, pressing {{{kbd(C-x)}}} always shows the common
-  commands.  The value of this option can be changed for the current
-  Emacs session by typing {{{kbd(C-x t)}}} while a transient is active.
+  This command toggles whether the generic commands, that are common
+  to all transients, are permanently displayed or only after typing
+  the incomplete prefix key sequence{{{kbd()}}}.  This only affects the current
+  Emacs session.
 
 The other common commands are described in either the previous or in
 one of the following sections.
@@ -236,6 +259,10 @@ suffix command, then the value is merely saved to the 
transient's
 history.  That value won't be used when the transient is next invoked,
 but it is easily accessible (see [[*Using History]]).
 
+Option ~transient-common-command-prefix~ controls the prefix key used
+in the following bindings.  For simplicity's sake the default, {{{kbd(C-x)}}},
+is shown below.
+
 - Key: C-x s (transient-set) ::
 
   This command saves the value of the active transient for this Emacs
@@ -267,6 +294,10 @@ value is saved to its history.  These values can be cycled 
through,
 the same way one can cycle through the history of commands that read
 user-input in the minibuffer.
 
+Option ~transient-common-command-prefix~ controls the prefix key used
+in the following bindings.  For simplicity's sake the default, {{{kbd(C-x)}}},
+is shown below.
+
 #+attr_texinfo: :compact t
 - Key: C-M-p (transient-history-prev) ::
 - Key: C-x p ::
@@ -354,8 +385,8 @@ For suffixes, 0 is also valid; it means that the suffix is 
not
 displayed at any level.
 
 The levels of individual transients and/or their individual suffixes
-can be changed interactively, by invoking the transient and then
-pressing {{{kbd(C-x l)}}} to enter the “edit” mode, see below.
+can be changed interactively, by invoking the menu and entering its
+“edit” mode using the command ~transient-set-level~, as described below.
 
 The default level for both transients and their suffixes is 4.  The
 ~transient-default-level~ option only controls the default for
@@ -376,6 +407,10 @@ available even if the user lowers the transient level.
   This option names the file that is used to persist the levels of
   transients and their suffixes between Emacs sessions.
 
+Option ~transient-common-command-prefix~ controls the prefix key used
+in the following bindings.  For simplicity's sake the default, {{{kbd(C-x)}}},
+is shown below.
+
 - Key: C-x l (transient-set-level) ::
 
   This command enters edit mode.  When edit mode is active, then all
@@ -497,7 +532,7 @@ Values]], in [[* Using History]] and in [[* Enabling and 
Disabling Suffixes]].
 :UNNUMBERED: notoc
 :END:
 
-Also see [[* Common Suffix Commands]].
+Two more essential options are documented in [[* Common Suffix Commands]].
 
 - User Option: transient-show-popup ::
 
@@ -520,17 +555,6 @@ Also see [[* Common Suffix Commands]].
     the popup is shown after that many seconds of inactivity (using
     the absolute value).
 
-- User Option: transient-show-common-commands ::
-
-  This option controls whether shared suffix commands are shown
-  alongside the transient-specific infix and suffix commands.  By
-  default, the shared commands are not shown to avoid overwhelming
-  the user with too many options.
-
-  While a transient is active, pressing {{{kbd(C-x)}}} always shows the common
-  commands.  The value of this option can be changed for the current
-  Emacs session by typing {{{kbd(C-x t)}}} while a transient is active.
-
 - User Option: transient-show-during-minibuffer-read ::
 
   This option controls whether the transient menu continues to be
@@ -2627,51 +2651,6 @@ See 
https://github.com/magit/transient/wiki/Comparison-with-prefix-keys-and-univ
 
 See https://github.com/magit/transient/wiki/Comparison-with-other-packages.
 
-** Why did some of the key bindings change?
-:PROPERTIES:
-:UNNUMBERED: notoc
-:END:
-
-You may have noticed that the bindings for some of the common commands
-do *not* have the prefix {{{kbd(C-x)}}} and that furthermore some of these 
commands
-are grayed out while others are not.  That unfortunately is a bit
-confusing if the section of common commands is not shown permanently,
-making the following explanation necessary.
-
-The purpose of usually hiding that section but showing it after the
-user pressed the respective prefix key is to conserve space and not
-overwhelm users with too much noise, while allowing the user to
-quickly list common bindings on demand.
-
-That however should not keep us from using the best possible key
-bindings.  The bindings that do use a prefix do so to avoid wasting
-too many non-prefix bindings, keeping them available for use in
-individual transients.  The bindings that do not use a prefix and that
-are *not* grayed out are very important bindings that are *always*
-available, even when invoking the “common command key prefix” or *any
-other* transient-specific prefix.  The non-prefix keys that *are* grayed
-out however, are not available when any incomplete prefix key sequence
-is active.  They do not use the “common command key prefix” because it
-is likely that users want to invoke them several times in a row and
-e.g., {{{kbd(M-p M-p M-p)}}} is much more convenient than {{{kbd(C-x M-p C-x 
M-p C-x M-p)}}}.
-
-You may also have noticed that the “Set” command is bound to {{{kbd(C-x s)}}},
-while Magit-Popup used to bind {{{kbd(C-c C-c)}}} instead.  I have seen several
-users praise the latter binding (sic), so I did not change it
-willy-nilly.  The reason that I changed it is that using different
-prefix keys for different common commands, would have made the
-temporary display of the common commands even more confusing, i.e.,
-after pressing {{{kbd(C-c)}}} all the bindings that begin with the 
{{{kbd(C-x)}}} prefix
-would be grayed out.
-
-Using a single prefix for common commands key means that all other
-potential prefix keys can be used for transient-specific commands
-*without* the section of common commands also popping up.  {{{kbd(C-c)}}} in
-particular is a prefix that I want to (and already do) use for Magit, and
-also using that for a common command would prevent me from doing so.
-
-(See also the next question.)
-
 ** Why does {{{kbd(q)}}} not quit popups anymore?
 :PROPERTIES:
 :UNNUMBERED: notoc
diff --git a/docs/transient.texi b/docs/transient.texi
index 962c4d02f0..a729599561 100644
--- a/docs/transient.texi
+++ b/docs/transient.texi
@@ -308,37 +308,60 @@ if any.
 @cindex common suffix commands
 
 A few shared suffix commands are available in all transients.  These
-suffix commands are not shown in the popup buffer by default.
+suffix commands are not shown permanently in every menu by default.
+Most of these commands share a common prefix key and pressing that key
+causes the common commands to be temporarily shown in the active menu.
 
-This includes the aborting commands mentioned in the previous section,
-as well as some other commands that are all bound to @kbd{C-x @var{KEY}}.  
After
-@kbd{C-x} is pressed, a section featuring all these common commands is
-temporarily shown in the popup buffer.  After invoking one of them,
-the section disappears again.  Note, however, that one of these
-commands is described as ``Show common permanently''; invoke that if you
-want the common commands to always be shown for all transients.
+@defopt transient-show-common-commands
+This option controls whether shared suffix commands are permanently
+shown alongside the menu-specific infix and suffix commands.  By
+default, the shared commands are not permanently shown to avoid
+wasting precious space and overwhelming the user with too many
+choices.
+
+If you prefer to always see these commands, then set this option to
+a non-@code{nil} value.  Alternatively the value can be toggled for the
+current Emacs session only, using @code{transient-toggle-common}, described
+below.
+@end defopt
+
+@defopt transient-common-command-prefix
+This option specifies the prefix key used in all transient menus
+to invoke most of the shared commands, which are available in all
+transient menus.  By default these bindings are only shown after
+pressing that prefix key and before following that up with a valid
+key binding (but see the previous option).
+
+For historic reasons @kbd{C-x} is used by default, but users are
+encouraged to pick another key, preferably one that is not commonly
+used in Emacs but is still convenient to them.
+
+Usually, while a transient menu is active, the user cannot invoke
+commands that are not bound in the menu itself.  For those menus it
+does not matter, if @kbd{C-x} or another commonly used prefix key is used
+for common menu commands.  However, certain other, newer menus do
+not suppress key bindings established outside the menu itself, and
+in those cases a binding for a common menu command could shadow an
+external binding.  For example, @kbd{C-x C-s} could not be used to invoke
+@code{save-buffer}, if that binding is shadowed by the menu binding for
+@code{transient-save}.
+
+Which key is most suitable depends on the user's preferences, but
+good choices may include function keys and @kbd{C-z} (for many keyboard
+layouts @kbd{z} is right next to @kbd{x}, and invoking @code{suspend-frame}, 
while a
+transient menu is active, would not be a good idea anyway).
+@end defopt
 
 @table @asis
 @item @kbd{C-x t} (@code{transient-toggle-common})
 @kindex C-x t
 @findex transient-toggle-common
-This command toggles whether the generic commands that are common to
-all transients are always displayed or only after typing the
-incomplete prefix key sequence @kbd{C-x}.  This only affects the current
+This command toggles whether the generic commands, that are common
+to all transients, are permanently displayed or only after typing
+the incomplete prefix key sequence@kbd{}.  This only affects the current
 Emacs session.
 @end table
 
-@defopt transient-show-common-commands
-This option controls whether shared suffix commands are shown
-alongside the transient-specific infix and suffix commands.  By
-default, the shared commands are not shown to avoid overwhelming
-the user with too many options.
-
-While a transient is active, pressing @kbd{C-x} always shows the common
-commands.  The value of this option can be changed for the current
-Emacs session by typing @kbd{C-x t} while a transient is active.
-@end defopt
-
 The other common commands are described in either the previous or in
 one of the following sections.
 
@@ -363,6 +386,10 @@ suffix command, then the value is merely saved to the 
transient's
 history.  That value won't be used when the transient is next invoked,
 but it is easily accessible (see @ref{Using History}).
 
+Option @code{transient-common-command-prefix} controls the prefix key used
+in the following bindings.  For simplicity's sake the default, @kbd{C-x},
+is shown below.
+
 @table @asis
 @item @kbd{C-x s} (@code{transient-set})
 @kindex C-x s
@@ -397,6 +424,10 @@ value is saved to its history.  These values can be cycled 
through,
 the same way one can cycle through the history of commands that read
 user-input in the minibuffer.
 
+Option @code{transient-common-command-prefix} controls the prefix key used
+in the following bindings.  For simplicity's sake the default, @kbd{C-x},
+is shown below.
+
 @table @asis
 @item @kbd{C-M-p} (@code{transient-history-prev})
 @itemx @kbd{C-x p}
@@ -496,8 +527,8 @@ For suffixes, 0 is also valid; it means that the suffix is 
not
 displayed at any level.
 
 The levels of individual transients and/or their individual suffixes
-can be changed interactively, by invoking the transient and then
-pressing @kbd{C-x l} to enter the ``edit'' mode, see below.
+can be changed interactively, by invoking the menu and entering its
+``edit'' mode using the command @code{transient-set-level}, as described below.
 
 The default level for both transients and their suffixes is 4.  The
 @code{transient-default-level} option only controls the default for
@@ -518,6 +549,10 @@ This option names the file that is used to persist the 
levels of
 transients and their suffixes between Emacs sessions.
 @end defopt
 
+Option @code{transient-common-command-prefix} controls the prefix key used
+in the following bindings.  For simplicity's sake the default, @kbd{C-x},
+is shown below.
+
 @table @asis
 @item @kbd{C-x l} (@code{transient-set-level})
 @kindex C-x l
@@ -642,7 +677,7 @@ More options are described in @ref{Common Suffix Commands}, 
in @ref{Saving Value
 @anchor{Essential Options}
 @subheading Essential Options
 
-Also see @ref{Common Suffix Commands}.
+Two more essential options are documented in @ref{Common Suffix Commands}.
 
 @defopt transient-show-popup
 This option controls whether the current transient's infix and
@@ -670,17 +705,6 @@ the absolute value).
 @end itemize
 @end defopt
 
-@defopt transient-show-common-commands
-This option controls whether shared suffix commands are shown
-alongside the transient-specific infix and suffix commands.  By
-default, the shared commands are not shown to avoid overwhelming
-the user with too many options.
-
-While a transient is active, pressing @kbd{C-x} always shows the common
-commands.  The value of this option can be changed for the current
-Emacs session by typing @kbd{C-x t} while a transient is active.
-@end defopt
-
 @defopt transient-show-during-minibuffer-read
 This option controls whether the transient menu continues to be
 displayed while the minibuffer is used to read user input.
@@ -2950,49 +2974,6 @@ See 
@uref{https://github.com/magit/transient/wiki/Comparison-with-prefix-keys-an
 
 See 
@uref{https://github.com/magit/transient/wiki/Comparison-with-other-packages}.
 
-@anchor{Why did some of the key bindings change?}
-@appendixsec Why did some of the key bindings change?
-
-You may have noticed that the bindings for some of the common commands
-do @strong{not} have the prefix @kbd{C-x} and that furthermore some of these 
commands
-are grayed out while others are not.  That unfortunately is a bit
-confusing if the section of common commands is not shown permanently,
-making the following explanation necessary.
-
-The purpose of usually hiding that section but showing it after the
-user pressed the respective prefix key is to conserve space and not
-overwhelm users with too much noise, while allowing the user to
-quickly list common bindings on demand.
-
-That however should not keep us from using the best possible key
-bindings.  The bindings that do use a prefix do so to avoid wasting
-too many non-prefix bindings, keeping them available for use in
-individual transients.  The bindings that do not use a prefix and that
-are @strong{not} grayed out are very important bindings that are 
@strong{always}
-available, even when invoking the ``common command key prefix'' or @strong{any
-other} transient-specific prefix.  The non-prefix keys that @strong{are} grayed
-out however, are not available when any incomplete prefix key sequence
-is active.  They do not use the ``common command key prefix'' because it
-is likely that users want to invoke them several times in a row and
-e.g., @kbd{M-p M-p M-p} is much more convenient than @kbd{C-x M-p C-x M-p C-x 
M-p}.
-
-You may also have noticed that the ``Set'' command is bound to @kbd{C-x s},
-while Magit-Popup used to bind @kbd{C-c C-c} instead.  I have seen several
-users praise the latter binding (sic), so I did not change it
-willy-nilly.  The reason that I changed it is that using different
-prefix keys for different common commands, would have made the
-temporary display of the common commands even more confusing, i.e.,
-after pressing @kbd{C-c} all the bindings that begin with the @kbd{C-x} prefix
-would be grayed out.
-
-Using a single prefix for common commands key means that all other
-potential prefix keys can be used for transient-specific commands
-@strong{without} the section of common commands also popping up.  @kbd{C-c} in
-particular is a prefix that I want to (and already do) use for Magit, and
-also using that for a common command would prevent me from doing so.
-
-(See also the next question.)
-
 @anchor{Why does @kbd{q} not quit popups anymore?}
 @appendixsec Why does @kbd{q} not quit popups anymore?
 
diff --git a/lisp/transient.el b/lisp/transient.el
index 1c0cc8f322..ad45e86f1f 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -105,6 +105,8 @@ TYPE is a type descriptor as accepted by `cl-typep', which 
see."
 (make-obsolete-variable 'transient-hide-during-minibuffer-read
                         'transient-show-during-minibuffer-read "0.8.0")
 
+(defvar transient-common-command-prefix)
+
 (defmacro transient--with-emergency-exit (id &rest body)
   (declare (indent defun))
   (unless (keywordp id)
@@ -282,11 +284,16 @@ See `mode-line-format' for details."
                  (sexp   :tag "Custom mode-line format")))
 
 (defcustom transient-show-common-commands nil
-  "Whether to show common transient suffixes in the popup buffer.
-
-These commands are always shown after typing the prefix key
-\\`C-x' when a transient command is active.  To toggle the value
-of this variable use \\`C-x t' when a transient is active."
+  "Whether to permanently show common suffix commands in transient menus.
+
+By default these commands are only temporarily shown after typing their
+shared prefix key \
+\\<transient--docstr-hint-1>\\[transient-common-command-prefix], \
+while a transient menu is active.  When the value
+of this option is non-nil, then these commands are permanently shown.
+To toggle the value for the current Emacs session only type \
+\\<transient--docstr-hint-2>\\[transient-toggle-common] while
+any transient menu is active."
   :package-version '(transient . "0.1.0")
   :group 'transient
   :type 'boolean)
@@ -494,7 +501,7 @@ Integers between 1 and 7 (inclusive) are valid levels.
 
 The levels of individual transients and/or their individual
 suffixes can be changed individually, by invoking the prefix and
-then pressing \\`C-x l'.
+then pressing \\<transient--docstr-hint-2>\\[transient-set-level].
 
 The default level for both transients and their suffixes is 4.
 This option only controls the default for transients.  The default
@@ -1402,9 +1409,12 @@ commands are aliases for."
             (_ (use key val)))))
       (when spec
         (error "Need keyword, got %S" (car spec)))
-      (when-let* (((not (plist-get args :key)))
-                  (shortarg (plist-get args :shortarg)))
-        (use :key shortarg)))
+      (if-let ((key (plist-get args :key)))
+          (when (string-match "\\`\\({p}\\)" key)
+            (use :key
+                 (replace-match transient-common-command-prefix t t key 1)))
+        (when-let ((shortarg (plist-get args :shortarg)))
+          (use :key shortarg))))
     (list 'list
           level
           (macroexp-quote (or class 'transient-suffix))
@@ -1943,7 +1953,7 @@ to `transient-predicate-map'."
     (keymap-set map "C-t"   #'transient-show)
     (keymap-set map "?"     #'transient-help)
     (keymap-set map "C-h"   #'transient-help)
-    ;; Also bound to "C-x p" and "C-x n" in transient-common-commands.
+    ;; Next two have additional bindings in transient-common-commands.
     (keymap-set map "C-M-p" #'transient-history-prev)
     (keymap-set map "C-M-n" #'transient-history-next)
     (when (fboundp 'other-frame-prefix) ;Emacs >= 28.1
@@ -1958,45 +1968,78 @@ to `transient-predicate-map'.  See also 
`transient-base-map'.")
 (defvar-keymap transient-edit-map
   :doc "Keymap that is active while a transient in is in \"edit mode\"."
   :parent transient-base-map
-  "?"     #'transient-help
-  "C-h"   #'transient-help
-  "C-x l" #'transient-set-level)
+  "?"   #'transient-help
+  "C-h" #'transient-help)
 
 (defvar-keymap transient-sticky-map
   :doc "Keymap that is active while an incomplete key sequence is active."
   :parent transient-base-map
   "C-g" #'transient-quit-seq)
 
-(defvar transient--common-command-prefixes '(?\C-x))
-(put 'transient-common-commands
-     'transient--layout
-     (list
-      (eval
-       (car (transient--parse-child
-             'transient-common-commands
-             [:hide
-              (lambda ()
-                (defvar transient--redisplay-key)
-                (and (not (memq (car transient--redisplay-key)
-                                transient--common-command-prefixes))
-                     (not transient-show-common-commands)))
-              ["Value commands"
-               ("C-x s  " "Set"            transient-set)
-               ("C-x C-s" "Save"           transient-save)
-               ("C-x C-k" "Reset"          transient-reset)
-               ("C-x p  " "Previous value" transient-history-prev)
-               ("C-x n  " "Next value"     transient-history-next)]
-              ["Sticky commands"
-               ;; Like `transient-sticky-map' except that
-               ;; "C-g" has to be bound to a different command.
-               ("C-g" "Quit prefix or transient" transient-quit-one)
-               ("C-q" "Quit transient stack"     transient-quit-all)
-               ("C-z" "Suspend transient stack"  transient-suspend)]
-              ["Customize"
-               ("C-x t" transient-toggle-common)
-               ("C-x l" "Show/hide suffixes" transient-set-level)
-               ("C-x a" transient-toggle-level-limit)]]))
-       t)))
+(defvar transient-common-commands
+  [:hide (lambda ()
+           (defvar transient--redisplay-key)
+           (and (not (equal (vconcat transient--redisplay-key)
+                            (read-kbd-macro transient-common-command-prefix)))
+                (not transient-show-common-commands)))
+   ["Value commands"
+    ("{p} s  " "Set"            transient-set)
+    ("{p} C-s" "Save"           transient-save)
+    ("{p} C-k" "Reset"          transient-reset)
+    ("{p} p  " "Previous value" transient-history-prev)
+    ("{p} n  " "Next value"     transient-history-next)]
+   ["Sticky commands"
+    ;; Like `transient-sticky-map' except that
+    ;; "C-g" has to be bound to a different command.
+    ("C-g" "Quit prefix or transient" transient-quit-one)
+    ("C-q" "Quit transient stack"     transient-quit-all)
+    ("C-z" "Suspend transient stack"  transient-suspend)]
+   ["Customize"
+    ("{p} t" transient-toggle-common)
+    ("{p} l" "Show/hide suffixes" transient-set-level)
+    ("{p} a" transient-toggle-level-limit)]]
+  "Commands available in all transient menus.
+The same functions that are used to change bindings in transient prefix
+commands, can be used to modify these bindings as well, but note that
+customizing `transient-common-command-prefix' resets these bindings and
+that the special meaning of \"{p}\" does not apply when modifying these
+bindings.")
+
+(defun transient--init-common-commands ()
+  (put 'transient-common-commands
+       'transient--layout
+       (list (eval (car (transient--parse-child 'transient-common-commands
+                                                transient-common-commands))
+                   t)))
+  (defvar transient-common-command-prefix)
+  (defvar transient--docstr-hint-1)
+  (defvar transient--docstr-hint-2)
+  (setq transient--docstr-hint-1
+        (define-keymap transient-common-command-prefix
+          'transient-common-command-prefix))
+  (setq transient--docstr-hint-2
+        (define-keymap (concat transient-common-command-prefix " t")
+          'transient-toggle-common)))
+
+(defcustom transient-common-command-prefix "C-x"
+  "The prefix key used for most commands common to all menus.
+
+Some shared commands are available in all transient menus, most of
+which share a common prefix specified by this option.  By default the
+bindings for these shared commands are only shown after pressing that
+prefix key and before following that up with a valid key binding.
+
+For historic reasons \\`C-x' is used by default, but users are
+encouraged to pick another key, preferably one that is not commonly used
+in Emacs but is still convenient to them.  See info node `(transient)
+Common Suffix Commands'."
+  :type 'key
+  :initialize (lambda (symbol exp)
+                (custom-initialize-default symbol exp)
+                (transient--init-common-commands))
+  :set (lambda (symbol value)
+         (set-default symbol value)
+         (transient--init-common-commands)))
 
 (defvar-keymap transient-popup-navigation-map
   :doc "One of the keymaps used when popup navigation is enabled.
@@ -2109,9 +2152,11 @@ of the corresponding object."
 
 (defun transient--make-transient-map ()
   (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map (if transient--editp
-                               transient-edit-map
-                             transient-map))
+    (cond (transient--editp
+           (keymap-set map (concat transient-common-command-prefix " l")
+                       #'transient-set-level)
+           (set-keymap-parent map transient-edit-map))
+          ((set-keymap-parent map transient-map)))
     (dolist (obj transient--suffixes)
       (let ((key (oref obj key)))
         (when (vectorp key)
@@ -4865,7 +4910,8 @@ Type %s and then %s to describe the respective suffix 
command.\n"
         (propertize "<KEY>" 'face 'transient-key)
         (propertize "<N>"   'face 'transient-key)
         (propertize " N "   'face 'transient-enabled-suffix)
-        (propertize "C-x l" 'face 'transient-key)
+        (propertize (concat transient-common-command-prefix " l")
+                    'face 'transient-key)
         (propertize "<N>"   'face 'transient-key)
         (propertize " N "   'face 'transient-enabled-suffix)
         (propertize "C-h"   'face 'transient-key)

Reply via email to