Compare commits

..

2 Commits

Author SHA1 Message Date
ad9a4b25d5 Add zero-indexed register 2023-10-11 19:36:16 +02:00
f94e8e49ed Add flake files 2023-10-11 19:35:55 +02:00
5 changed files with 115 additions and 0 deletions

59
flake.lock Normal file
View File

@ -0,0 +1,59 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1696757521,
"narHash": "sha256-cfgtLNCBLFx2qOzRLI6DHfqTdfWI+UbvsKYa3b3fvaA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2646b294a146df2781b1ca49092450e8a32814e1",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

43
flake.nix Normal file
View File

@ -0,0 +1,43 @@
{
description = "kakoune (patch)";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (sys:
let
pkgs = nixpkgs.legacyPackages.${sys};
kak = pkgs.stdenv.mkDerivation rec {
pname = "kakoune";
version = "2022.10.31";
src = ./. ;
makeFlags = [ "debug=no" "PREFIX=${placeholder "out"}" ];
preConfigure = ''
export version="v${version}"
'';
enableParallelBuilding = true;
doInstallCheck = true;
installCheckPhase = ''
$out/bin/kak -ui json -e "kill 0"
'';
postInstall = ''
# make share/kak/autoload a directory, so we can use symlinkJoin with plugins
cd "$out/share/kak"
autoload_target=$(readlink autoload)
rm autoload
mkdir autoload
ln -s --relative "$autoload_target" autoload
'';
};
in rec {
packages.kak = kak;
packages.default = packages.kak;
}
);
}

View File

@ -198,6 +198,7 @@ constexpr StringView register_doc =
"%: buffer name\n"
".: selection contents\n"
"#: selection index\n"
"$: selection index (zero-indexed)\n"
"_: null register\n"
"\": default yank/paste register\n"
"@: default macro register\n"

View File

@ -436,6 +436,17 @@ void register_registers()
return res;
}));
register_manager.add_register('$', make_dyn_reg(
"$",
[](const Context& context) {
const size_t count = context.selections().size();
StringList res;
res.reserve(count);
for (size_t i = 0; i < count; ++i)
res.push_back(to_string((int)i));
return res;
}));
for (size_t i = 0; i < 10; ++i)
{
register_manager.add_register('0'+i, make_dyn_reg(

View File

@ -67,6 +67,7 @@ static const HashMap<StringView, Codepoint> reg_names {
{ "percent", '%' },
{ "dot", '.' },
{ "hash", '#' },
{ "dollar", '$' },
{ "underscore", '_' },
{ "colon", ':' }
};