On Sun, Jan 04, 2015 at 06:52:00PM +0100, Marc André Tanner wrote: > On Sun, Jan 04, 2015 at 06:22:00PM +0100, Silvan Jegen wrote: > > On Sun, Jan 04, 2015 at 06:12:00PM +0100, Matthias Rabault wrote: > > > Thanks for the patch, I'll check it out this evening (can't yet, I'm > > > using my phone). What I was thinking of was adding code in main() that > > > alters the Editor structure according to config.def.h defines, just > > > before calling the main loop. > > > > When looking at the main function you can see that the editor's statusbar > > field is being set using the "config"-pointer and a corresponding function > > called editor_statusbar_set. > > > > If you want to follow that pattern you can add two setter functions for > > tabwidth and expandtab and set the fields that way (either using the > > Config in config or a "#define"d value). > > > > I wonder though if it wouldn't be cleaner to just pass a pointer to the > > Config struct to the editor_new function and dealing with the field > > value initializations there. > > I agree, adding individual options to editor_new is wrong.
I tried another way, without adding options to editor_new. The idea was editing the fields in Editor in the main() function. The patch is attached. What do you think of it ? Cheers, Matthias
>From 2201279c011e409ac573b92728c74c959e6823d1 Mon Sep 17 00:00:00 2001 From: Matthias Rabault <matthias.raba...@mailoo.org> Date: Sun, 4 Jan 2015 22:11:37 +0100 Subject: [PATCH] Set tabwidth and expandtab in config.def.h --- config.def.h | 3 +++ vis.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index aac28a8..70c1708 100644 --- a/config.def.h +++ b/config.def.h @@ -12,6 +12,9 @@ { { NONE(127) }, (func), { .name = (arg) } }, \ { { CONTROL('B') }, (func), { .name = (arg) } } +#define TABWIDTH 8 +#define EXPANDTAB false + /* a mode contains a set of key bindings which are currently valid. * * each mode can specify one parent mode which is consultated if a given key diff --git a/vis.c b/vis.c index 7ccfa22..2be7b67 100644 --- a/vis.c +++ b/vis.c @@ -1891,7 +1891,9 @@ int main(int argc, char *argv[]) { if (!editor_syntax_load(vis, syntaxes, colors)) die("Could not load syntax highlighting definitions\n"); editor_statusbar_set(vis, config->statusbar); - + vis->tabwidth = TABWIDTH; + vis->expandtab = EXPANDTAB; + char *cmd = NULL; for (int i = 1; i < argc; i++) { if (argv[i][0] == '-') { -- 2.2.1