(

defun

which-key-M-x-prefix+

(

&optional

_

)

"Completing read and execute command from prefix-map.

This command can be used as

`prefix-help-command'

. The optional

argument is ignored and only for compatability with

`which-key-C-h-dispatch'

so this command can be bound in

`which-key-C-h-map'

, too."

(

interactive

)

(

let*

((

evs

(

cond

((

which-key--current-prefix

)

(

which-key--current-key-list

))

(

t

(

butlast

(

append

(

this-command-keys-vector

)

nil

)))))

(

key

(

and

evs

(

apply

#'vector

evs

))))

(

which-key-M-x+

key

)))

(

defun

which-key-M-x+

(

&optional

key

)

"Completing read command and execute it.

Only commands which are bound to keys are considered. If KEY is

given it should be the prefix-key for which commands should be

completed. Otherwise read command from top-level. "

(

interactive

)

(

let

((

cmd

(

which-key--completing-read-cmd+

key

)))

(

when

(

commandp

cmd

)

(

which-key--execute-cmd+

cmd

))))

(

defun

which-key--completing-read-cmd+

(

&optional

prefix

)

"Completing read command for PREFIX.

Read commands for PREFIX or top-level if PREFIX not given."

(

which-key--hide-popup-ignore-command

)

(

let

((

desc

(

completing-read

(

if

prefix

(

format

"Execute (%s): "

(

key-description

prefix

))

"Execute: "

)

(

mapcar

#'

which-key--completing-read-format+

(

which-key--get-current-bindings

prefix

)))))

(

intern

(

car

(

split-string

desc

)))))

(

defun

which-key--execute-cmd+

(

cmd

)

"Execute command CMD as if invoked by key sequence."

(

setq

prefix-arg

current-prefix-arg

)

(

setq

this-command

cmd

)

(

setq

real-this-command

cmd

)

(

command-execute

cmd

'record

))

(

defun

which-key--completing-read-format+

(

bnd

)

"Format binding BND for

`completing-read'

."

(

let*

((

key

(

car

bnd

))

(

cmd

(

cdr

bnd

))

(

desc

(

format

"%s (%s)"

cmd

(

propertize

key

'face

'which-key-key-face

))))

(

which-key--maybe-add-docstring

(

format

"%-50s"

desc

)

cmd

)))