Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
25849:ecbd01ddf78d | 25850:6f615b2fdc66 |
---|---|
7936 | 7936 |
7937 | 7937 |
7938 menu_info({name} [, {mode}]) *menu_info()* | 7938 menu_info({name} [, {mode}]) *menu_info()* |
7939 Return information about the specified menu {name} in | 7939 Return information about the specified menu {name} in |
7940 mode {mode}. The menu name should be specified without the | 7940 mode {mode}. The menu name should be specified without the |
7941 shortcut character ('&'). | 7941 shortcut character ('&'). If {name} is "", then the top-level |
7942 menu names are returned. | |
7942 | 7943 |
7943 {mode} can be one of these strings: | 7944 {mode} can be one of these strings: |
7944 "n" Normal | 7945 "n" Normal |
7945 "v" Visual (including Select) | 7946 "v" Visual (including Select) |
7946 "o" Operator-pending | 7947 "o" Operator-pending |
7987 Returns an empty dictionary if the menu item is not found. | 7988 Returns an empty dictionary if the menu item is not found. |
7988 | 7989 |
7989 Examples: > | 7990 Examples: > |
7990 :echo menu_info('Edit.Cut') | 7991 :echo menu_info('Edit.Cut') |
7991 :echo menu_info('File.Save', 'n') | 7992 :echo menu_info('File.Save', 'n') |
7993 | |
7994 " Display the entire menu hierarchy in a buffer | |
7995 func ShowMenu(name, pfx) | |
7996 let m = menu_info(a:name) | |
7997 call append(line('$'), a:pfx .. m.display) | |
7998 for child in m->get('submenus', []) | |
7999 call ShowMenu(a:name .. '.' .. escape(child, '.'), | |
8000 \ a:pfx .. ' ') | |
8001 endfor | |
8002 endfunc | |
8003 new | |
8004 for topmenu in menu_info('').submenus | |
8005 call ShowMenu(topmenu, '') | |
8006 endfor | |
7992 < | 8007 < |
7993 Can also be used as a |method|: > | 8008 Can also be used as a |method|: > |
7994 GetMenuName()->menu_info('v') | 8009 GetMenuName()->menu_info('v') |
7995 | 8010 |
7996 | 8011 |