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 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.
>
> dump_menu({path}, {modes}) *dump_menu()*
> Returns a |Dictionary| with all the submenu of {path} (set to
> an empty string to match all menus). Only the commands matching {modes}
> are
> returned ('a' for all, 'i' for insert see |creating-menus|).
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
>
> --
> --
> 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.
--
--
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.