From 008ba2cbab928b5f4ea50b450a683c1f570eee14 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 6 Oct 2014 19:32:25 +0100 Subject: [PATCH] Use ',' instead of '|' as tuple option fields separators --- rc/git-tools.kak | 11 ++++++----- src/option_types.hh | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/rc/git-tools.kak b/rc/git-tools.kak index ddb1d490..602b73c4 100644 --- a/rc/git-tools.kak +++ b/rc/git-tools.kak @@ -63,9 +63,10 @@ def -shell-params \ if (line == "") { return; } text=substr(sha,1,8) " " dates[sha] " " authors[sha] gsub(":", "\\:", text) - flag=line "|black|" text + gsub(",", "\\,", text) + flag=line ",black," text for ( i=1; i < count; i++ ) { - flag=flag ":" line+i "|black|" text + flag=flag ":" line+i ",black," text } cmd = "kak -p " ENVIRON["kak_session"] print "set -add buffer=" ENVIRON["kak_bufname"] " git_blame_flags %{" flag "}" | cmd @@ -90,7 +91,7 @@ def -shell-params \ git diff -U0 $kak_buffile | awk -e ' BEGIN { line=0 - flags="0|red|." + flags="0,red,." } /^---.*/ {} /^@@ -[0-9]+(,[0-9]+)? \+[0-9]+(,[0-9]+)? @@.*/ { @@ -101,10 +102,10 @@ def -shell-params \ } } /^\+/ { - flags=flags ":" line "|green|+" + flags=flags ":" line ",green,+" line++ } - /^\-/ { flags=flags ":" line "|red|-" } + /^\-/ { flags=flags ":" line ",red,-" } END { print "set buffer git_diff_flags ", flags } ' } diff --git a/src/option_types.hh b/src/option_types.hh index e68ddc30..7b0ebbf1 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -99,7 +99,7 @@ bool option_add(std::unordered_set& opt, const std::unordered_set& set) return not set.empty(); } -constexpr Codepoint tuple_separator = '|'; +constexpr Codepoint tuple_separator = ','; template struct TupleOptionDetail @@ -175,9 +175,9 @@ bool option_add(T&, const T&) template inline void option_from_string(const String& str, LineAndColumn& opt) { - auto vals = split(str, '|'); + auto vals = split(str, tuple_separator); if (vals.size() != 2) - throw runtime_error("expected |"); + throw runtime_error("expected "_str + tuple_separator + ""); opt.line = str_to_int(vals[0]); opt.column = str_to_int(vals[1]); } @@ -185,7 +185,7 @@ inline void option_from_string(const String& str, LineAndColumn inline String option_to_string(const LineAndColumn& opt) { - return to_string(opt.line) + '|' + to_string(opt.column); + return to_string(opt.line) + tuple_separator + to_string(opt.column); } enum YesNoAsk