about summary refs log tree commit diff stats
path: root/src/local
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-05-11 00:17:18 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-11 00:20:40 +0200
commit5c5377fbaa7290909dbd3c53d0a487d40752428c (patch)
tree7384246f2b135f55b871cb4bbe229f76560da572 /src/local
parentb02d940cfc20e67ee866bf47b02612aed6bcf24d (diff)
downloadchawan-5c5377fbaa7290909dbd3c53d0a487d40752428c.tar.gz
pager: take $EDITOR from env
* use EDITOR environment variable in default config, fix line number
  ordering in fallback
* autodetect vi-like editors and add line number
Diffstat (limited to 'src/local')
-rw-r--r--src/local/pager.nim10
1 files changed, 5 insertions, 5 deletions
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: