Context-aware commands completion? reddit / emacs ---------------------------------------------------------------------- mmontone · 2022-04-02 15:56 Let's say I'm editing a Markdown document, markdown-mode is active. I would like to type: `M-x link TAB`, and see `markdown-insert-link` as one of the first options in the completion list, because markdown- mode is currently active. I don't want to have to enter 'markdown', that should be inferred from the context. I thought that a menus commands completion could be pretty close to what I'm looking, since often menus have the most relevant commands for the active modes. I've found [LaCarte](https://www.emacswiki.org/emacs/LaCarte) library, that lets me execute menu-bar menu commands from the keyboard, using completion. That's pretty close to what I want, but its icycles completion is not working very well for me. I wonder if there other options out there? Or ideas on how to implement? (I can do some Emacs lisp). ---------------------------------------------------------------------- poinkalum · 2022-04-02 16:05 Emacs 28 ships `execute-extended-command-for-buffer` which is pretty much what you want. [Here](https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in- emacs/) is an article from Lars Ingebrigtsen that explains the feature. What version of Emacs are you using ? ---------------------------------------------------------------------- mmontone · 2022-04-02 16:22 I'm on Emacs 29. I'll give it a try, thanks. ---------------------------------------------------------------------- mmontone · 2022-04-02 16:31 Wow. That is exactly what I was looking for. I didn't expect to be so easy. Thanks! ---------------------------------------------------------------------- 00-11 · 2022-04-02 16:32 [La Carte](https://www.emacswiki.org/emacs/LaCarte) is independent of [Icicles](https://www.emacswiki.org/emacs/Icicles). La Carte makes use of `completing-read`. Whatever completion framework or `completion-styles` you use, it is *they* that determine what `completing-read` does. You should be able to use La Carte with any of them. If you do use Icicles with La Carte then you get Icicles possibilities for completing. There are a number of [completion methods](https://www.emacswiki.org/emacs/Icicles_- _Completion_Methods_and_Styles) you can use, including various fuzzy matching methods, and of course you can use `completion-styles` as usual. ---------------------------------------------------------------------- mmontone · 2022-04-02 16:40 Ah, good. Yes, I see I have a problem with my completion system. I have `completion-style` set to `flex` (I want it that way). But when completing, I would like the completed list to get focus and navigate it using the keyboard, not the mouse. But that's not LaCarte specific. ---------------------------------------------------------------------- mmontone · 2022-04-02 16:51 Just for reference, this fixed my problem with the completions list interaction: (define-key minibuffer-mode-map (kbd "") 'switch-to- completions) ---------------------------------------------------------------------- organic-bookworm · 2022-04-02 17:13 If you use [consult](https://github.com/minad/consult#modes), there's also `consult-mode-command`. >Run a command from the currently active minor or major modes. Supports narrowing to local-minor/global-minor/major mode via the keys `l/g/m`.