Hot answers tagged

8

I can add not an exact answer to your question, but a workflow that eliminates the need for it. I use smex instead of execute-extended-command. Once in the minibuffer of smex: RET calls execute-extended-command C-h f calls smex-describe-function M-. calls smex-find-function I don't like the default bindings, so I've customized them: (eval-after-load '...


7

The "easiest way" is to just define your own version of describe-function, and bind that to C-h f. Take the vanilla code, and change only the call to completing-read so that it uses the same history list that M-x (execute-extended-command) uses, which is extended-command-history. (defun my-describe-function (function) "Display the full documentation of ...


6

Please note that it's very easy to invoke the command from its Help buffer. After typing C-h f just type M-x M-n RET. This works because in a new Help buffer the command name is at the top of the buffer under the cursor, and M-n retrieves it to the minibuffer. However, if you want to add a command to extended-command-history every time you visit its ...


4

Based on xuchunyang's answer, I was able to add helm-M-x to helm sources. (defvar helm-source-emacs-commands (helm-build-sync-source "Emacs commands" :candidates (lambda () (let ((cmds)) (mapatoms (lambda (elt) (when (commandp elt) (push elt cmds)))) cmds)) :coerce #'...


4

(defvar helm-source-emacs-commands (helm-build-sync-source "Emacs commands" :candidates (lambda () (let ((cmds)) (mapatoms (lambda (elt) (when (commandp elt) (push elt cmds)))) cmds)) :coerce #'intern-soft :action #'command-execute) "A simple helm source for Emacs ...


4

Check out https://github.com/syl20bnr/spacemacs/issues/13100. There was a breaking change in Helm which removed the fuzzy- variables you defined. In place, you have to set the following variables in your init.el: For emacs27: (setq helm-completion-style 'emacs) (setq completion-styles '(flex)) For emacs26: (setq helm-completion-style 'emacs) (setq ...


3

*insert TAB will work for execute-extended-command, but smex is just much better.


3

The key sequence M-x calls execute-extended-command. That command uses read-extended-command for reading from minibuffer. In read-extended-command the c-function completing-read does the main job. But, the INITIAL-INPUT argument for that command is hard-coded to nil. We should not temporarily advise completing-read since that function can be compiled-in. ...


2

You may want to try ivy + ivy-rich. The relevant section of the documentation has this screenshot: You need to include the following lines in your init.el: (require 'ivy) (ivy-mode 1) (require 'ivy-rich) (ivy-rich-mode 1) (setq ivy-use-virtual-buffers t) (setq enable-recursive-minibuffers t) (global-set-key (kbd "M-x") 'counsel-M-x)


2

The quick and dirty way is to pretend you pressed *. (defun execute-my-extended-command (&rest args) "Read a command name to call, favoring commands that begin with `*'. Like `execute-extended-command', but when called interactively, preload a leading `*' into the minibuffer." (interactive) (if (interactive-p) (progn (setq unread-...


2

Others have mentioned smex and icicles which give such completions. I'll add Helm. Install from MELPA with M-x package-install helm. (helm-mode t) will turn it on globally. It doesn't steal your M-x key for itself, so also add (global-set-key (kbd "M-x") 'helm-M-x) to give it the key.


2

C-xz calls repeat which repeats the most recently-excuted command. Note especially that you can keep repeating the command with only the final key in the sequence. e.g. C-xzzzzz C-x z runs the command repeat (found in global-map), which is an interactive autoloaded compiled Lisp function in ‘repeat.el’. It is bound to C-x z. (repeat REPEAT-ARG) Repeat ...


2

The generate-new-buffer function is not an interactive command, and so it cannot be called using M-x. Commands are lisp functions that have an (interactive) form to define how arguments can be provided interactively. M-x can only be used to call such commands. If you wanted you could write your own command to wrap a function like generate-new-buffer: (...


2

You need to distinguish between a common function and an interactive command. The latter is also a function, but with the addition of (interactive) to its body. You can run the latter, but not the former, by binding commands to keys or calling them by name via M-x. See the elisp manual links above more more details.


2

You can use the following command which is independent of the used completion framework because it uses completing-read: (defun execute-binding+ (arg) "Completing read a command and execute it. With ARG non-nil only present commands without a key binding otherwise only those which have one." (interactive "P") (let ((cmd (completing-read ...


1

There is a smex package that among other persists all M-x calls between emacs sessions in MRU. You can either call smex directly instead of general execute-extended-command or call counsel-M-x (ivy+counsel packages) that will use smex under the hood. I was thinking helm-m-x could do the same but if not, I believe it could be extended in the similar manner. ...


1

You can use savehist-mode to do what you want, if you customize savehist-additional-variables to add command-history to it. M-x puts each executed command on command-history as a list of the command and the arguments you (implicitly or explicitly) provided. It is not a plain minibuffer history, so it isn't handled automatically by savehist-mode. But if you ...


1

If you use helm-M-x, there is no need to type C-h f to look up commands's documentation, just use C-j or C-z while running helm-M-x to toggle the display of documentation. See also Helm M-x's features.


1

In Icicles you get such completion using S-TAB (by default - you can change the key, of course). By default: TAB gives you prefix completion. (Or vanilla Emacs completion - e.g., *insert TAB will do as @abo-abo indicated.) S-TAB gives you "apropos"-style (i.e., regexp) completion, which of course includes substring completion. Just use a different ...


1

Have you changed the value of smex-auto-update? The default is t. smex-auto-update is a compiled Lisp function in `smex.el'. (smex-auto-update &optional IDLE-TIME) Update Smex when Emacs has been idle for IDLE-TIME.


Only top voted, non community-wiki answers of a minimum length are eligible