On Sun, 04 Jan 2015 17:47:58 +0100
Matthias Rabault <matthias.raba...@mailoo.org> wrote:

Hey Matthias,

> I see your point and I agree. I didn't think of that, so I'll have to
> think of another way to do that, which doesn't change the prototype.
> Thanks for the insight!

one way to handle this is to pull it in from vis.c via extern.
Attached is a patch which does just that.

Cheers

FRIGN

-- 
FRIGN <d...@frign.de>
>From 3cc548817bf61c71c7744e43da3b0d083b95b8e4 Mon Sep 17 00:00:00 2001
From: FRIGN <d...@frign.de>
Date: Sun, 4 Jan 2015 17:50:41 +0100
Subject: [PATCH] Set tabwidth and expandtab in config.def.h

Initial idea by Matthias Rabault <matthias.raba...@mailoo.org>
---
 config.def.h | 3 +++
 editor.c     | 7 +++++--
 vis.c        | 3 +++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/config.def.h b/config.def.h
index cfd1771..87f0f6b 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/editor.c b/editor.c
index ef59242..38256df 100644
--- a/editor.c
+++ b/editor.c
@@ -17,6 +17,9 @@
 # define MAX_COLOR_PAIRS COLOR_PAIRS
 #endif
 
+extern int tabwidth;
+extern int expandtab;
+
 static EditorWin *editor_window_new_text(Editor *ed, Text *text);
 static void editor_window_free(Editor *ed, EditorWin *win);
 static void editor_windows_invalidate(Editor *ed, size_t start, size_t end);
@@ -441,8 +444,8 @@ Editor *editor_new(int width, int height) {
 		goto err;
 	ed->width = width;
 	ed->height = height;
-	ed->tabwidth = 8;
-	ed->expandtab = false;
+	ed->tabwidth = tabwidth;
+	ed->expandtab = expandtab;
 	ed->windows_arrange = windows_arrange_horizontal;
 	return ed;
 err:
diff --git a/vis.c b/vis.c
index cb401d9..c60db6b 100644
--- a/vis.c
+++ b/vis.c
@@ -526,6 +526,9 @@ static void switchmode_to(Mode *new_mode);
 
 #include "config.h"
 
+int tabwidth = TABWIDTH;
+int expandtab = EXPANDTAB;
+
 static Key getkey(void);
 static void keypress(Key *key);
 static void action_do(Action *a);
-- 
1.8.5.5

Reply via email to