emacs-devel
[Top][All Lists]
Advanced

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

RE: [External] : Re: master 927b885 1/3: Disable filtering of commands i


From: Drew Adams
Subject: RE: [External] : Re: master 927b885 1/3: Disable filtering of commands in M-x completion
Date: Thu, 18 Feb 2021 16:25:45 +0000

> >> I'd like also to suggest to filter out commands
> >> having "r" in their interactive specs - they signal
> >> an error when the region is not active, so no
> >> need to show them.
> >
> > Are you sure they raise an error?
> >
> > (defun foo (&optional beg end)
> >   (interactive "r")
> >   (message "FOO"))
> 
> Yes, I'm sure.  'M-x foo RET' without an active region
> raises an error:
>   command-execute: The mark is not active now

I don't see that in Emacs 27.1 or prior (with
`emacs -Q').  Is this perhaps new for 28?
If so, why would we do that?

`interactive' code `r' gives you the region
limits, regardless of whether the region is
active - which is TRT.

I don't understand why this should now raise an
error (even if `r' gave you the limits only when
the region were active - which it shouldn't).

And certainly in a case like the example I gave,
where the args are optional.  I don't see the
motivation for now raising an error.

> > I also think it's misleading to base filtering on
> > an `interactive' form that uses a string.  That's
> > inherently fragile/limiting.  It won't apply to a
> > form that evaluates a sexp to provide the args.
> > The resulting incoherence will confuse users.
> 
> This means that more complex interactive specs
> need manual tagging using a new tag:
>   (declare (predicate (use-region-p)))

That's not what `r' has done forever (up through
Emacs 27.1, at least).  It's never been only about
the _active_ region.

Anyway, that's only for `r'.  You can no doubt
propose something for other `interactive' codes.
But even that won't handle arbitrary `interactive'
sexps, right?

`interactive' can accept a string arg, which, in
effect, has its own, parsable language.  So you
can try to parse, and try to do some somewhat
relevant tagging based on that parsing.

But `interactive' is much more general than what's
represented by that string-arg language.  Trying
to base your tagging on `interactive' seems
fundamentally flawed/misguided.

> >> Also filter out commands with "*" in read-only buffers.
> > Same problem.  Relying on a string arg to `interactive'
> > is not a great idea, I think.
> 
> Same tag:
>   (declare (predicate (not buffer-read-only)))

And what about commands that might be usable
interactively, but whose `interactive' spec
doesn't encapsulate all that's involved?  In that
case, manual addition of a declaration will need
to look into the logic of the command body as
well.  (Admittedly, such commands are uncommon.)

> >> `describe-command' is a very good idea for searching
> >> and discovering commands.
> >
> > I mentioned that I defined that long ago.  But I'll
> > also mention that `describe-function' with a prefix
> > arg already gives you that behavior.  Oops!  Nope,
> > that too is something I defined long ago in
> > `help-fns+.el'.
> >
> > Similarly, I defined `describe-option', and a prefix
> > arg to (my definition of) `describe-variable' limits
> > choices to user options (like `describe-option').
> 
> Using a prefix arg for 'C-h f' and 'C-h v' to limit the list
> of completions would be nice.
> 
> But I guess M-x can't use a prefix arg to limit completions?

Why do you think so?  `C-u M-x describe-function TAB'
(with my definition from `help-fns+.el') shows only
commands as candidates.



reply via email to

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