Mercurial > vim
diff runtime/doc/eval.txt @ 25850:6f615b2fdc66 v8.2.3459
patch 8.2.3459: Vim9: need more tests for empty string arguments
Commit: https://github.com/vim/vim/commit/51491adfa86fd66a857cd7ec50d0b57dbdf3da59
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Sep 30 19:00:00 2021 +0100
patch 8.2.3459: Vim9: need more tests for empty string arguments
Problem: Vim9: need more tests for empty string arguments.
Solution: Add more tests. Also use empty argument with menu_info() to get
the top-level menu names. (Yegappan Lakshmanan, closes #8925)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 30 Sep 2021 20:15:04 +0200 |
parents | 65de67669df3 |
children | 2d0bea8aed33 |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -7938,7 +7938,8 @@ max({expr}) Return the maximum value of menu_info({name} [, {mode}]) *menu_info()* Return information about the specified menu {name} in mode {mode}. The menu name should be specified without the - shortcut character ('&'). + shortcut character ('&'). If {name} is "", then the top-level + menu names are returned. {mode} can be one of these strings: "n" Normal @@ -7989,6 +7990,20 @@ menu_info({name} [, {mode}]) *menu_in Examples: > :echo menu_info('Edit.Cut') :echo menu_info('File.Save', 'n') + + " Display the entire menu hierarchy in a buffer + func ShowMenu(name, pfx) + let m = menu_info(a:name) + call append(line('$'), a:pfx .. m.display) + for child in m->get('submenus', []) + call ShowMenu(a:name .. '.' .. escape(child, '.'), + \ a:pfx .. ' ') + endfor + endfunc + new + for topmenu in menu_info('').submenus + call ShowMenu(topmenu, '') + endfor < Can also be used as a |method|: > GetMenuName()->menu_info('v')