Nikolay Pavlov wrote:

> 2017-03-31 17:58 GMT+03:00 Matthieu Coudron <[email protected]>:
> > I can see it's useful. Currently the values could be obtained with a :menu
> > command, but parsing the output is quite complicated.
> >
> > correct. Just dumping the menus is enough for the scenariis I have in mind
> > so I've nothing else to propose, script can keep using :menu and/or :unmenu.
> >
> > Here is what the help could look like, I am not sure what would be a typical
> > vim name for the function (exportmenu ? dumpmenu ? menu2dict :D )
> 
> getsmth. Though more recent functions do use underscore, so the result
> may be get_menu().

I've started grouping functions in a way that makes them easier to find.
Grouping by "get" is not very useful.  Thus I would prefer menu_get().
Later we could add more menu_xyz() functions (if there are any).

> I would also suggest that get_menu() output (values describing the
> menu) should share some keys with maparg(,,, 1) output: make it
> dictionary with items
> 
>    name: entry name.
>    priority: menu priority.
>    icon: path to icon (string), may be missing.
>    enabled: 0 or 1 (see `:h disable-menus`).
>    tooltip: string (see `:h :tmenu`), may be missing.
>    hint: menu hint (what you place after `<Tab>` when defining menu),
> may be missing.
>    shortcut: shortcut key, may be missing.
>    hidden: 0 or 1 (`1` in the example, see `:h hidden-menus`).
> 
>    children: children menus. One entry may have either children or
> implementations+hint.
>    implementations: entry implementations, one per mode. One
> dictionary may have either children or implementations, not both.
> 
> And here implementations values are partially shared with maparg(,,, 1):
> 
>    silent: 1 if <silent> modifier was used, 0 otherwise.
>    noremap: 2 if <script> modifier was used, 1 if noremenu was used, 0
> otherwise.
>    sid: script ID.
>    rhs: string, right-hand side.
> 
> So the result will look something like
> 
> {'Plugin': {
>   'name': 'Plugin',
>   'hidden': 0,
>   'shortcut': 'P',
>   'children': {
>     'comment': {
>       'name': 'comment',
>       'priority': 500,
>       'enabled': 1,
>       'shortcut': 'c',
>       'children': {
>         'Comment': {
>           'name': 'Comment',
>           'priority': 500,
>           'enabled': 1,
>           'hint': '\cc',
>           'implementations': {
>             'n': {'noremap': 2, 'sid': 1, 'rhs':
> '<Plug>NERDCommenterComment'}, 'silent': 1},
>             'v': {'noremap': 2, 'sid': 1, 'rhs':
> '<Plug>NERDCommenterComment'}, 'silent': 1},
>           },
>         }
>       }
>     }
>   }
> }}
> 
> Note: no lists, but `name` allows working with `values()` and ignore `keys()`.
> 
> And do not keep compatibility with maparg() regarding `noremap`: `menu
> <script>` and `noremenu` must be distinguishable.

Looks OK.  Sometimes a list is easier to deal with.  But it should be
possible to create the list from the dict, using the priority.  An
example in the docs would be very helpful.

-- 
"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/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui