aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-11-28 03:40:49 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-11-28 03:45:57 +0530
commitc0b9703831a39593e99a7849f8caf6df40c2c208 (patch)
tree2cbb59594a387bbe8293a266ca56bc72ddbd5de8 /src
parent0a21d90ad5c8e5cc4eb52a454b7aa32e642c431d (diff)
downloadnnn-c0b9703831a39593e99a7849f8caf6df40c2c208.tar.gz
Fix #147: support one argument to editor
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/nnn.c b/src/nnn.c
index c673c55..f76a68d 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -290,7 +290,7 @@ static int ndents, cur, total_dents = ENTRY_INCR;
static uint idle;
static uint idletimeout, copybufpos, copybuflen;
static char *copier;
-static char *editor;
+static char *editor, *editor_arg;
static blkcnt_t ent_blocks;
static blkcnt_t dir_blocks;
static ulong num_files;
@@ -2638,12 +2638,10 @@ nochange:
if (cfg.nonavopen && sel == SEL_NAV_IN)
continue;
- /* If NNN_USE_EDITOR is set,
- * open text in EDITOR
- */
+ /* If NNN_USE_EDITOR is set, open text in EDITOR */
if (editor) {
if (getmime(dents[cur].name)) {
- spawn(editor, newpath, NULL, path, F_NORMAL);
+ spawn(editor, editor_arg, newpath, path, F_NORMAL);
continue;
}
@@ -2654,7 +2652,7 @@ nochange:
continue;
if (strstr(g_buf, "text/") == g_buf) {
- spawn(editor, newpath, NULL, path, F_NORMAL);
+ spawn(editor, editor_arg, newpath, path, F_NORMAL);
continue;
}
}
@@ -3545,6 +3543,18 @@ int main(int argc, char *argv[])
editor = xgetenv("VISUAL", NULL);
if (!editor)
editor = xgetenv("EDITOR", "vi");
+ if (editor) {
+ /* copier used as a temp var */
+ copier = editor;
+ while (*copier) {
+ if (*copier == ' ') {
+ *copier = '\0';
+ editor_arg = ++copier;
+ break;
+ }
+ ++copier;
+ }
+ }
}
/* Get locker wait time, if set; copier used as tmp var */