vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 05ccf7c075f5dfb9d9109d05addb627324469100 parent 1838d8712a1c3081d2d9e4800d88d2b1f66bd8dd Author: Marc André Tanner <mat@brain-dump.org> Date: Thu, 22 Oct 2015 21:30:53 +0200 vis: remove config selection based on argv[0] I would still like to experiment with a busybox style editor multiplexer which behaves like vi(m), emacs or nano depending on argv[0]. Diffstat:
| M | config.def.h | | | 13 | ------------- |
| M | editor.h | | | 7 | ------- |
| M | vis.c | | | 13 | +------------ |
3 files changed, 1 insertion(+), 32 deletions(-)
diff --git a/config.def.h b/config.def.h @@ -1512,19 +1512,6 @@ static Mode vis_modes[] = { }, }; -/* list of vis configurations, first entry is default. name is matched with - * argv[0] i.e. program name upon execution - */ -static Config editors[] = { - { - .name = "vis", - .mode = &vis_modes[VIS_MODE_NORMAL], - }, -}; - -/* default editor configuration to use */ -static Config *config = &editors[0]; - /* null terminated default settings/commands executed once on editor startup */ static const char *settings[] = { NULL diff --git a/editor.h b/editor.h @@ -62,13 +62,6 @@ struct Mode { }; typedef struct { - char *name; /* is used to match against argv[0] to enable this config */ - Mode *mode; /* default mode in which the editor should start in */ - bool (*keypress)(const char *key); /* called before any other keybindings are checked, - * return value decides whether key should be ignored */ -} Config; - -typedef struct { int count; /* how many times should the command be executed? */ Register *reg; /* always non-NULL, set to a default register */ Filerange range; /* which part of the file should be affected by the operator */ diff --git a/vis.c b/vis.c @@ -2805,17 +2805,6 @@ static void mainloop(Vis *vis) { int main(int argc, char *argv[]) { - /* decide which key configuration to use based on argv[0] */ - char *arg0 = argv[0]; - while (*arg0 && (*arg0 == '.' || *arg0 == '/')) - arg0++; - for (int i = 0; i < LENGTH(editors); i++) { - if (strcmp(editors[i].name, arg0) == 0) { - config = &editors[i]; - break; - } - } - for (int i = 0; i < LENGTH(vis_modes); i++) { Mode *mode = &vis_modes[i]; if (!editor_mode_bindings(mode, &mode->default_bindings)) @@ -2825,7 +2814,7 @@ int main(int argc, char *argv[]) { if (!(vis = editor_new(ui_curses_new()))) die("Could not allocate editor core\n"); - vis->mode_prev = vis->mode = config->mode; + vis->mode_prev = vis->mode = &vis_modes[VIS_MODE_NORMAL]; if (!editor_syntax_load(vis, syntaxes)) die("Could not load syntax highlighting definitions\n");