Re: [dev] [vis] [PATCH] Set tabwidth and expandtab in config.def.h

From: Matthias Rabault <matthias.rabault_AT_mailoo.org>
Date: Sun, 04 Jan 2015 17:46:03 +0100

Oops ... The empty line removal was an accident. As to yesterday's blunder, I knew how to use the preprocessor, I was only tired and did everything too fast ...

Silvan Jegen <s.jegen_AT_gmail.com> a écrit :

>Heyhey
>
>On Sun, Jan 4, 2015 at 4:42 PM, Matthias Rabault
><matthias.rabault_AT_mailoo.org> wrote:
>> I submitted a patch yesterday so that expandtab and tabwidth are set in
>> config.def.h, but it was complete shit. Discard the other one. This one
>> should be much better. I had to add arguments to editor_new().
>>
>> Sorry for yesterday's shitty patch.
>
>In my opinion making mistakes is okay. You should have read up on how
>the C pre-processor works before sending a first patch though.
>
>I have only one comment (inline below).
>
>> ---
>> config.def.h | 3 +++
>> editor.c | 6 +++---
>> editor.h | 2 +-
>> vis.c | 3 +--
>> 4 files changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/config.def.h b/config.def.h
>> index aac28a8..70c1708 100644
>> --- a/config.def.h
>> +++ b/config.def.h
>> _AT_@ -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..ae7338f 100644
>> --- a/editor.c
>> +++ b/editor.c
>> _AT_@ -431,7 +431,7 @@ void editor_window_close(EditorWin *win) {
>> editor_draw(ed);
>> }
>>
>> -Editor *editor_new(int width, int height) {
>> +Editor *editor_new(int width, int height, int tabwidth, bool expandtab) {
>> Editor *ed = calloc(1, sizeof(Editor));
>> if (!ed)
>> return NULL;
>> _AT_@ -441,8 +441,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/editor.h b/editor.h
>> index 5dcb122..e358923 100644
>> --- a/editor.h
>> +++ b/editor.h
>> _AT_@ -110,7 +110,7 @@ struct Editor {
>> bool expandtab; /* whether typed tabs should be converted to spaces */
>> };
>>
>> -Editor *editor_new(int width, int height);
>> +Editor *editor_new(int width, int height, int tabwidth, bool expandtab);
>> void editor_free(Editor*);
>> void editor_resize(Editor*, int width, int height);
>> void editor_draw(Editor*);
>> diff --git a/vis.c b/vis.c
>> index 7ccfa22..ee09be6 100644
>> --- a/vis.c
>> +++ b/vis.c
>> _AT_@ -55,7 +55,6 @@ typedef struct {
>>
>> #define MAX_KEYS 2
>> typedef Key KeyCombo[MAX_KEYS];
>> -
>
>There is no need to remove this empty line in this patch. If you
>really want to suggest to do so, send a new patch (but I don't think
>such a patch will be very welcome).
>
>> typedef struct {
>> KeyCombo key;
>> void (*func)(const Arg *arg);
>> _AT_@ -1886,7 +1885,7 @@ int main(int argc, char *argv[]) {
>> mode_prev = mode = config->mode;
>> setup();
>>
>> - if (!(vis = editor_new(screen.w, screen.h)))
>> + if (!(vis = editor_new(screen.w, screen.h, TABWIDTH, EXPANDTAB)))
>> die("Could not allocate editor core\n");
>> if (!editor_syntax_load(vis, syntaxes, colors))
>> die("Could not load syntax highlighting definitions\n");
>> --
>> 2.2.1
>>
>>
>
Received on Sun Jan 04 2015 - 17:46:03 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 04 2015 - 17:48:13 CET