vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 3078e69950301a4bac565c3db28c8f88fc13c957
parent e5f7a1529fa7cc268a90fc950be02f1ad5eded37
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue, 22 Nov 2016 14:35:57 +0100

vis: populate :set option map at startup

Diffstat:
Msam.c | 8++++++++
Mvis-cmds.c | 11-----------
2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/sam.c b/sam.c @@ -375,6 +375,14 @@ bool sam_init(Vis *vis) { bool ret = true; for (const CommandDef *cmd = cmds; cmd && cmd->name; cmd++) ret &= map_put(vis->cmds, cmd->name, cmd); + + if (!(vis->options = map_new())) + return false; + for (int i = 0; i < LENGTH(options); i++) { + for (const char *const *name = options[i].names; *name; name++) + ret &= map_put(vis->options, *name, &options[i]); + } + return ret; } diff --git a/vis-cmds.c b/vis-cmds.c @@ -79,17 +79,6 @@ static bool parse_bool(const char *s, bool *outval) { static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor *cur, Filerange *range) { - if (!vis->options) { - if (!(vis->options = map_new())) - return false; - for (int i = 0; i < LENGTH(options); i++) { - for (const char *const *name = options[i].names; *name; name++) { - if (!map_put(vis->options, *name, &options[i])) - return false; - } - } - } - if (!argv[1] || argv[3]) { vis_info_show(vis, "Expecting: set option [value]"); return false;