login

<     >

2017-09-28 21:37:47 (UTC+02:00)

Klemens Nanni <kl3@posteo.org>

Prefer VISUAL to EDITOR

VISUAL is useed on many systems these days without EDITOR being set, see
the manual pages for various shells or other documentation.

This patch makes rover respect VISUAL being set in the environment and
prefer it to EDITOR.

diff --git a/README.md b/README.md
index 7b84d6b..40c09ed 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ Quick Start
      0-9 - change tab
   RETURN - open $SHELL on the current directory
    SPACE - open $PAGER with the selected file
-       e - open $EDITOR with the selected file
+       e - open $VISUAL or $EDITOR with the selected file
        / - start incremental search (RETURN to finish)
      n/N - create new file/directory
        R - rename selected file or directory
@@ -65,13 +65,13 @@ editing the file `config.h` and rebuilding the binary.
  Note that the external programs executed by some Rover commands may be changed
 via the appropriate environment variables. For example, to specify an editor:
  ```
- $ EDITOR=vi rover
+ $ VISUAL=vi rover
  ```
 
  Rover will first check for variables prefixed  with ROVER_. This can be used to
 change Rover behavior without interfering with the global environment:
  ```
- $ ROVER_EDITOR=vi rover
+ $ ROVER_VISUAL=vi rover
  ```
 
  Please read rover(1) for more information.

diff --git a/rover.1 b/rover.1
index 43b33b6..82a6e88 100644
--- a/rover.1
+++ b/rover.1
@@ -115,7 +115,7 @@ Open \fB$SHELL\fR on the current directory.
 Open \fB$PAGER\fR with the selected file.
 .TP
 .B e
-Open \fB$EDITOR\fR with the selected file.
+Open \fB$VISUAL\fR or \fB$EDITOR\fR with the selected file.
 .TP
 .B o
 Open \fB$OPEN\fR with the selected file.
@@ -194,8 +194,11 @@ Name of shell program (e.g. \fI/bin/sh\fP).
 .B PAGER
 Name of pager program (e.g. \fIless\fP).
 .TP
+.B VISUAL
+Name of visual editor program (e.g. \fIvim\fP or \fIemacs\fP).
+.TP
 .B EDITOR
-Name of editor program (e.g. \fIvim\fP or \fIemacs\fP).
+Name of line editor program (e.g. \fIed\fP or \fIex\fP).
 .TP
 .B CLIP
 Path of clipboard file (e.g. \fI/tmp/clipboard\fP).
@@ -212,9 +215,9 @@ typing something like \fBgrep abc "$RVSEL"\fR.
 This variable can be set to a command accepting a single argument: a filename.
 The command is supposed to open the given file with an appropriate program.
 .TP
-.B ROVER_SHELL, ROVER_PAGER, ROVER_EDITOR, ROVER_OPEN
+.B ROVER_SHELL, ROVER_PAGER, ROVER_VISUAL, ROVER_EDITOR, ROVER_OPEN
 If any of these variables are set, they override \fBSHELL\fR, \fBPAGER\fR,
-\fBEDITOR\fR and \fBOPEN\fR, respectivelly.
+\fBVISUAL\fR, \fBEDITOR\fR and \fBOPEN\fR, respectively.
 .SH CONFIGURATION
 .PP
 If you want to change Rover key bindings or colors, you can edit the

diff --git a/rover.c b/rover.c
index 723c11a..6db7dd9 100644
--- a/rover.c
+++ b/rover.c
@@ -328,7 +328,9 @@ get_user_programs()
 {
     ROVER_ENV(user_shell, SHELL)
     ROVER_ENV(user_pager, PAGER)
-    ROVER_ENV(user_editor, EDITOR)
+    ROVER_ENV(user_editor, VISUAL)
+    if (!user_editor)
+        ROVER_ENV(user_editor, EDITOR)
     ROVER_ENV(user_open, OPEN)
 }