mirror of
https://github.com/NixOS/nix
synced 2025-06-27 04:21:16 +02:00
Split out CmdRepl
and editorFor
The REPL itself and the `nix repl` CLI are conceptually different things, and thus deserve to be in different files.
This commit is contained in:
parent
57a2e46ee0
commit
1bd03ad100
9 changed files with 198 additions and 123 deletions
20
src/libcmd/editor-for.cc
Normal file
20
src/libcmd/editor-for.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "util.hh"
|
||||
#include "editor-for.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
Strings editorFor(const Path & file, uint32_t line)
|
||||
{
|
||||
auto editor = getEnv("EDITOR").value_or("cat");
|
||||
auto args = tokenizeString<Strings>(editor);
|
||||
if (line > 0 && (
|
||||
editor.find("emacs") != std::string::npos ||
|
||||
editor.find("nano") != std::string::npos ||
|
||||
editor.find("vim") != std::string::npos ||
|
||||
editor.find("kak") != std::string::npos))
|
||||
args.push_back(fmt("+%d", line));
|
||||
args.push_back(file);
|
||||
return args;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue