mirror of
https://github.com/NixOS/nix
synced 2025-07-02 21:51:50 +02:00
Merge branch 'nix-repl-e' of https://github.com/zimbatm/nix
This commit is contained in:
commit
852554bb16
6 changed files with 88 additions and 34 deletions
|
@ -178,6 +178,19 @@ Strings argvToStrings(int argc, char * * argv)
|
|||
return args;
|
||||
}
|
||||
|
||||
Strings editorFor(Pos pos)
|
||||
{
|
||||
auto editor = getEnv("EDITOR", "cat");
|
||||
auto args = tokenizeString<Strings>(editor);
|
||||
if (pos.line > 0 && (
|
||||
editor.find("emacs") != std::string::npos ||
|
||||
editor.find("nano") != std::string::npos ||
|
||||
editor.find("vim") != std::string::npos))
|
||||
args.push_back(fmt("+%d", pos.line));
|
||||
args.push_back(pos.file);
|
||||
return args;
|
||||
}
|
||||
|
||||
std::string renderLabels(const Strings & labels)
|
||||
{
|
||||
std::string res;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include "util.hh"
|
||||
#include "nixexpr.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
@ -190,6 +191,9 @@ public:
|
|||
|
||||
Strings argvToStrings(int argc, char * * argv);
|
||||
|
||||
/* Helper function to generate args that invoke $EDITOR on filename:lineno */
|
||||
Strings editorFor(Pos pos);
|
||||
|
||||
/* Helper function for rendering argument labels. */
|
||||
std::string renderLabels(const Strings & labels);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue