Tony wrote:
> > > • In Normal gvim with Motif GUI in GUI mode, :echo exists(':tearoff')
> > > gives 0 but menus can be teared off from the menu bar with the mouse
> > > • In the same in Console mode, :echo exists(':tearoff') gives 2
> > > • In Huge gvim with GTK3 GUI (where menus cannot be teared off with
> > > the mouse), :echo exists(':tearoff') gives 2 even in the GUI.
> > > • In all these cases, :tearoff PopUp (or with any other menu name)
> > > gives error "E319: Sorry, the command is not available in this
> > > version."
> > >
> > > In my humble opinion, E319 ought never to happen if a prior check with
> > > exists(':command') has given 2.
> >
> > This is a special case: The command is in the list of supported
> > commands, but it is only actually implemented for MS-Windows.
> >
> > > :help tear-off-menus says that tearoff menus are available with Motif
> > > or GTK2 GUIs but not GTK3 version 3.4 or later and indeed, I can tear
> > > off menus (but only with the mouse) in Motif gvim but not in GTK3
> > > 3.24.38.
> > >
> > > • Maybe the Motif Vim should evaluate exists(':tearoff') to zero even
> > > when not in GUI mode?
> >
> > Having exists() return non-zero for a command that doesn't work is
> > misleading. However, returning zero also isn't correct, since Vim does
> > know about the command.
>
> Hm… Vim does know about the command, but it is not implemented in the
> current build. Similarly, Vim knows about the +python and +python3
> features, and in a Vim built with -python -python3 the expressions
> has('python') has('python3') both return 0 (which is what I expected)
> but "echo exists(':python') exists(':python3') exists(':pythonx')"
> returns 2 0 0 which I find even more misleading. I would have expected
> them all to be "undefined" (and therefore zero, as mentioned at
> builtin.txt line 2307) whenever they are excluded at compile-time in
> the current Vim.
>
> > Currently the returned values are:
> >
> > 1 for match with start of a command
> > 2 full match with a command
> > 3 matches several user commands
> >
> > That doesn't leave room for a new value. The best I can think of would
> > be to return one:
> >
> > 1 for match with start of a command
> > and full match with command that is
> > not implemented
> >
> > Any better ideas?
>
> I would have preferred 0 for "unknown, or not included in the current
> build" similarly to how has() behaves, but the above is better than
> nothing.
Looking at this again, changing exists() in a way that the returned
value is not very clear is not a good solution. exists() is more for a
runtime check anyway, we have has() for compile time checks. So we can
make has(':tearoff') return 0 or 1, depending on whether the command is
supported or not. And not change exists(). That is backwards
compatible and gives a clear answer.
It might be worth doing this for all Ex commands, when the has()
argument starts with a colon.
--
"After a few years of marriage a man can look right at a woman
without seeing her and a woman can see right through a man
without looking at him."
- Helen Rowland
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230627151315.03CB31C054C%40moolenaar.net.