emacs-devel
[Top][All Lists]
Advanced

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

Re: Current mode command discovery


From: Lars Ingebrigtsen
Subject: Re: Current mode command discovery
Date: Mon, 22 Feb 2021 05:00:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> It makes sense for M-x to "not list it at all" yet for the menu bar to
> still show it (as greyed out) because the circumstances are different
> (the fact that the entry is present in the menu is proof that the
> command is sometimes relevant, just not currently).

Thinking about this some more, I think the `menu-enable' thing is
about a different thing than the completion predicate.

But it is something we could be exploring doing something about, because
it seems like there's an opportunity to do some cleanup in this area.

The issue is: We have a bunch of commands that are available in most
modes, but that can't be executed "right now" -- you have to do
something else for them to become enabled.  I think it would be a
mistake to filter these out in any way -- that would just hinder command
discovery.

But we have this information spread out over a range of mechanisms
today.

* The `menu-enable' symbol property -- a predicate that says whether the
  command is useable

* The :enable thing in menu items

* Some thing in tool bars, I think?

* `disabled' in the symbol

* In the code itself

* "*" in `interactive' specs

And probably more.

All of these are ways to say that the command exists, but can't be
executed right now.  We could introduce one new mechanism that replaces
all this spread-out information in one place, where it belongs:

(defun kill-region (...)
  (declare (inhibited (lambda ()
                        (and (not (region-active-p))
                             "The region is not active"))))
  ...)

Or something along those lines.

This predicate could be used in the menu/tool bar, and also in `M-x TAB'
listings -- it would list `kill-region', but say (Inhibited: The region
is not active")) afterwards, or something like that.

(So the `inhibited' predicate would return a string that explains why
the command isn't usable right now.)

-- 
(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]