On Wed, Feb 10, 2021 at 08:50:10PM -0600, Stefan Kangas wrote: > Lars Ingebrigtsen writes: > > > Matt Armstrong writes: > > > >> What if instead help showed all the interactive commands provided by > >> the mode? What if M-x were smarter about highlighting mode specific > >> commands? > > > > It's been discussed before -- somebody just has to implement one of the > > various possibilities here. The problem is that commands are only tied > > very loosely to modes: > > > > (defun foo-thing () > > (interactive) > > ...) > > > > will make `M-x fTAB' show `foo-thing' even if it's useless outside of > > all other modes than `foo-mode'. Conversely, `C-h m' in `foo-mode' > > won't, as you mention, list `foo-thing' unless there's a binding for it. > > > > My suggestion is to introduce a new form: > > > > (defun foo-thing () > > (command foo-mode) > > ...) > > > > This would be just like `interactive', but will do the right thing in > > `M-x fTAB' and `C-h m' in modes derived from `foo-mode'. (It could also > > be a list of mode, of course, but that'd be more rare, is my guess.) > > It would indeed be very useful to provide a mechanism to exclude > commands from M-x that are useless outside of their major mode. Nobody uses M-x in an explorative way? IMO this is a bad idea for discoverability. What is (and what is not) relevant to a mode is necessarily subject to a judgement call by someone. Some thought needs to go into how give users a way to escape that confinement, I think. Cheers - t