From 5c5377fbaa7290909dbd3c53d0a487d40752428c Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 11 May 2024 00:17:18 +0200 Subject: 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 --- src/local/pager.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/local') 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: -- cgit 1.4.1-2-gfad0