emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Limit what M-x TAB lists?


From: Lars Ingebrigtsen
Subject: Limit what M-x TAB lists?
Date: Thu, 26 Dec 2013 15:18:48 +0100
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

Here's today's unrealistic idea: Wouldn't it be nice if `M-x fooTAB' was
more useful?

For instance, if I type `M-x vc-dTAB' in this buffer, I get the
following: 

Possible completions are:
vc-default-check-headers        vc-default-mark-resolved
vc-default-revision-completion-table    vc-delete-file
vc-diff         vc-dir
vc-dir-delete-file      vc-dir-find-file
vc-dir-find-file-other-window   vc-dir-hide-state
vc-dir-hide-up-to-date  vc-dir-ignore
vc-dir-isearch  vc-dir-isearch-regexp
vc-dir-kill-dir-status-process  vc-dir-kill-line
vc-dir-mark     vc-dir-mark-all-files
vc-dir-menu     vc-dir-mode
vc-dir-next-directory   vc-dir-next-line
vc-dir-previous-directory       vc-dir-previous-line
vc-dir-query-replace-regexp     vc-dir-refresh
vc-dir-search   vc-dir-show-fileentry
vc-dir-toggle-mark      vc-dir-unmark
vc-dir-unmark-all-files         vc-dir-unmark-file-up

Out of all this, I think there's two actual commands I can use here --
the rest are just commands bound to keystrokes in VC mode.

It would be really nice for discoverability if only those two applicable
commands were listed.

And it doesn't really seem unachievable.  There's oodles of ways of
achieving this that would require more or less work.

1) Just make M-x list ;;;###autoloaded functions.

That would require us adding those cookies to more functions, though.

2) New form like (command-interactive 'vc-mode "p")

This would say "this command is only valid in VC mode buffers", so it
would not be listed by M-x in other modes.  This would be pretty
flexible, but would be a lot of code churn.  But it wouldn't require a
global Armageddon date, but one could add this at leisure, and M-x would
gradually become nicer.

3) New form like (global-interactive "p")

Kinda like the opposite of 2), but here we mark commands as being
global.  It would be less churn, but be more Armageddon-ey.  Unless we
add cookies per file that says that "this file is now new-style".  Kinda
like

(pragma (local-interactive 'vc-mode))

at the start or something.

The added bonus of both 2) and 3) might be that commands would refuse to
run unless called in the right mode buffers.  Which might mean fewer bug
reports down the line.

There's a bunch of commands (like `quit-window') that apply to many
(special) modes, but we could figure something out for those, too...

(Oops.  I almost ran `M-x quit-window' in this buffer.  I wonder what
would have happened...)

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]