about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--res/config.toml2
-rw-r--r--src/local/pager.nim10
2 files changed, 6 insertions, 6 deletions
diff --git a/res/config.toml b/res/config.toml
index c7d54aed..3ace21bd 100644
--- a/res/config.toml
+++ b/res/config.toml
@@ -238,7 +238,7 @@ urimethodmap = [
 	"/usr/local/etc/w3m/urimethodmap"
 ]
 tmpdir = "/tmp/cha"
-editor = "vi %s +%d"
+editor = "${EDITOR:-vi +%d %s}"
 cgi-dir = "${%CHA_LIBEXEC_DIR}/cgi-bin"
 download-dir = "/tmp/"
 w3m-cgi-compat = false
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 8b25e075..93bf562c 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -11,6 +11,7 @@ import std/unicode
 
 import bindings/libregexp
 import bindings/quickjs
+import config/chapath
 import config/config
 import config/mailcap
 import io/bufreader
@@ -826,12 +827,11 @@ proc toggleSource(pager: Pager) {.jsfunc.} =
       pager.container.sourcepair = container
       pager.addContainer(container)
 
-func getEditorCommand(pager: Pager; file: string; line = 1): string {.jsfunc.} =
+proc getEditorCommand(pager: Pager; file: string; line = 1): string {.jsfunc.} =
   var editor = pager.config.external.editor
-  if editor == "":
-    editor = getEnv("EDITOR")
-    if editor == "":
-      editor = "vi %s +%d"
+  if (let uqEditor = ChaPath(editor).unquote(); uqEditor.isSome):
+    if uqEditor.get in ["vi", "nvi", "vim", "nvim"]:
+      editor &= " +%d"
   var canpipe = false
   var s = unquoteCommand(editor, "", file, nil, canpipe, line)
   if canpipe: