Skip to content

Commit d7c917e

Browse files
committed
vis: add #defines to ease overriding of utility names
This should ease packaging for systems with an existing vis(1) binary.
1 parent 55be869 commit d7c917e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

register.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include "util.h"
77
#include "register.h"
88

9+
#ifndef VIS_CLIPBOARD
10+
#define VIS_CLIPBOARD "vis-clipboard"
11+
#endif
12+
913
static ssize_t read_buffer(void *context, char *data, size_t len) {
1014
buffer_append(context, data, len);
1115
return len;
@@ -30,7 +34,7 @@ const char *register_get(Vis *vis, Register *reg, size_t *len) {
3034
buffer_clear(&reg->buf);
3135

3236
int status = vis_pipe(vis, &(Filerange){ .start = 0, .end = 0 },
33-
(const char*[]){ "vis-clipboard", "--paste", NULL },
37+
(const char*[]){ VIS_CLIPBOARD, "--paste", NULL },
3438
&reg->buf, read_buffer, &buferr, read_buffer);
3539

3640
if (status != 0)
@@ -70,7 +74,7 @@ bool register_put_range(Vis *vis, Register *reg, Text *txt, Filerange *range) {
7074
Buffer buferr;
7175
buffer_init(&buferr);
7276

73-
int status = vis_pipe(vis, range, (const char*[]){ "vis-clipboard", "--copy", NULL },
77+
int status = vis_pipe(vis, range, (const char*[]){ VIS_CLIPBOARD, "--copy", NULL },
7478
NULL, NULL, &buferr, read_buffer);
7579

7680
if (status != 0)

vis-cmds.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/* this file is included from sam.c */
22

3+
#ifndef VIS_OPEN
4+
#define VIS_OPEN "vis-open"
5+
#endif
6+
37
static void windows_arrange(Vis *vis, enum UiLayout layout) {
48
vis->ui->arrange(vis->ui, layout);
59
}
@@ -262,7 +266,7 @@ static const char *file_open_dialog(Vis *vis, const char *pattern) {
262266
buffer_init(&bufout);
263267
buffer_init(&buferr);
264268

265-
if (!buffer_put0(&bufcmd, "vis-open ") || !buffer_append0(&bufcmd, pattern ? pattern : ""))
269+
if (!buffer_put0(&bufcmd, VIS_OPEN " ") || !buffer_append0(&bufcmd, pattern ? pattern : ""))
266270
return NULL;
267271

268272
Filerange empty = text_range_empty();

0 commit comments

Comments
 (0)