On Mon, Jun 26, 2023 at 1:31 PM Bram Moolenaar <[email protected]> wrote:
>
>
> 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.
>
> > • Maybe the GTK3 GUI with GTK3 3.4 or later should evaluate
> > exists('tearoff') to zero in all cases?
> > • Maybe the help for :tearoff (which is in gui_w32.txt) should insist
> > on the fact that this command applies only to Windows?
>
> It won't hurt to state that explicitly.
OK. Maybe it could have been regarded as "implicit" but me too I
believe that saying it explicitly won't hurt.
>
> > • Or, contrariwise, maybe the :tearoff command should be extended to
> > Motif and GTK2 GUIs, which have tearoff menus (but only by mouse
> > AFAICT)?
>
> I do not know how to do that. Perhaps there is a function for that, I
> haven't attempted finding it.
Well, at least we can tear off menus by mouse (but only in these two
GUIs and only in GUI mode). OK, leave that for "whoever whenever,
low-priority" then.
>
> --
> Google is kind of like Dr. Who's Tardis; it's weirder on the
> inside than on the outside...
Best regards,
Tony.
--
--
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/CAJkCKXuzf%3D-Hxy2ouPLkF8_XYHMNkreNaYkW4WyUKe-PYgUy0g%40mail.gmail.com.