Make quoting opt-in by using $kak_quoted_...
This commit is contained in:
parent
8b2906a14d
commit
4b7b5d077c
|
@ -399,7 +399,7 @@ define-command -hidden c-family-alternative-file %{
|
|||
dir=$(dirname "${kak_buffile}")
|
||||
|
||||
# Set $@ to alt_dirs
|
||||
eval "set -- ${kak_opt_alt_dirs}"
|
||||
eval "set -- ${kak_quoted_opt_alt_dirs}"
|
||||
|
||||
case ${file} in
|
||||
*.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m)
|
||||
|
|
|
@ -92,7 +92,7 @@ provide-module crystal %🐈
|
|||
|
||||
evaluate-commands %sh[
|
||||
# Keywords
|
||||
eval "set -- $kak_opt_crystal_keywords"
|
||||
eval "set -- $kak_quoted_opt_crystal_keywords"
|
||||
regex="\\b(?:\\Q$1\\E"
|
||||
shift
|
||||
for keyword do
|
||||
|
@ -102,7 +102,7 @@ provide-module crystal %🐈
|
|||
printf 'add-highlighter shared/crystal/code/keywords regex %s 0:keyword\n' "$regex"
|
||||
|
||||
# Attributes
|
||||
eval "set -- $kak_opt_crystal_attributes"
|
||||
eval "set -- $kak_quoted_opt_crystal_attributes"
|
||||
regex="\\b(?:\\Q$1\\E"
|
||||
shift
|
||||
for attribute do
|
||||
|
@ -112,7 +112,7 @@ provide-module crystal %🐈
|
|||
printf 'add-highlighter shared/crystal/code/attributes regex %s 0:attribute\n' "$regex"
|
||||
|
||||
# Symbols
|
||||
eval "set -- $kak_opt_crystal_operators"
|
||||
eval "set -- $kak_quoted_opt_crystal_operators"
|
||||
# Avoid to match modules
|
||||
regex="(?<!:):(?:\\w+[?!]?"
|
||||
for operator do
|
||||
|
@ -122,7 +122,7 @@ provide-module crystal %🐈
|
|||
printf 'add-highlighter shared/crystal/code/symbols regex %%(%s) 0:value\n' "$regex"
|
||||
|
||||
# Objects
|
||||
eval "set -- $kak_opt_crystal_objects"
|
||||
eval "set -- $kak_quoted_opt_crystal_objects"
|
||||
regex="\\b(?:\\Q$1\\E"
|
||||
shift
|
||||
for object do
|
||||
|
|
|
@ -139,7 +139,7 @@ define-command clang-disable-autocomplete -docstring "Disable automatic clang co
|
|||
define-command -hidden clang-show-error-info %{
|
||||
update-option buffer clang_errors # Ensure we are up to date with buffer changes
|
||||
evaluate-commands %sh{
|
||||
eval "set -- ${kak_opt_clang_errors}"
|
||||
eval "set -- ${kak_quoted_opt_clang_errors}"
|
||||
shift # skip timestamp
|
||||
desc=$(for error in "$@"; do
|
||||
if [ "${error%%|*}" = "$kak_cursor_line" ]; then
|
||||
|
@ -168,7 +168,7 @@ define-command clang-disable-diagnostics -docstring "Disable automatic error rep
|
|||
define-command clang-diagnostics-next -docstring "Jump to the next line that contains an error" %{
|
||||
update-option buffer clang_errors # Ensure we are up to date with buffer changes
|
||||
evaluate-commands %sh{
|
||||
eval "set -- ${kak_opt_clang_errors}"
|
||||
eval "set -- ${kak_quoted_opt_clang_errors}"
|
||||
shift # skip timestamp
|
||||
for error in "$@"; do
|
||||
candidate=${error%%|*}
|
||||
|
|
|
@ -15,7 +15,7 @@ declare-option -docstring "shell command to run" str readtagscmd "readtags"
|
|||
define-command -params ..1 \
|
||||
-shell-script-candidates %{
|
||||
realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) }
|
||||
eval "set -- $kak_opt_ctagsfiles"
|
||||
eval "set -- $kak_quoted_opt_ctagsfiles"
|
||||
for candidate in "$@"; do
|
||||
[ -f "$candidate" ] && realpath "$candidate"
|
||||
done | awk '!x[$0]++' | # remove duplicates
|
||||
|
@ -32,7 +32,7 @@ If no symbol is passed then the current selection is used as symbol name} \
|
|||
%[ evaluate-commands %sh[
|
||||
realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) }
|
||||
export tagname="${1:-${kak_selection}}"
|
||||
eval "set -- $kak_opt_ctagsfiles"
|
||||
eval "set -- $kak_quoted_opt_ctagsfiles"
|
||||
for candidate in "$@"; do
|
||||
[ -f "$candidate" ] && realpath "$candidate"
|
||||
done | awk '!x[$0]++' | # remove duplicates
|
||||
|
@ -68,7 +68,7 @@ define-command ctags-complete -docstring "Complete the current selection" %{
|
|||
(
|
||||
header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}"
|
||||
compl=$(
|
||||
eval "set -- $kak_opt_ctagsfiles"
|
||||
eval "set -- $kak_quoted_opt_ctagsfiles"
|
||||
for ctagsfile in "$@"; do
|
||||
${kak_opt_readtagscmd} -p -t "$ctagsfile" ${kak_selection}
|
||||
done | awk '{ uniq[$1]++ } END { for (elem in uniq) printf " %1$s||%1$s", elem }'
|
||||
|
|
|
@ -13,7 +13,7 @@ define-command -hidden -params 4 doc-render-regex %{
|
|||
execute-keys "%arg{3}"
|
||||
evaluate-commands %sh{
|
||||
face="$4"
|
||||
eval "set -- $kak_selections_desc"
|
||||
eval "set -- $kak_quoted_selections_desc"
|
||||
for desc in "$@"; do ranges="$ranges '$desc|$face'"; done
|
||||
echo "update-option buffer doc_render_ranges"
|
||||
echo "set-option -add buffer doc_render_ranges $ranges"
|
||||
|
@ -58,7 +58,7 @@ define-command doc-jump-to-anchor -params 1 %{
|
|||
update-option buffer doc_anchors
|
||||
evaluate-commands %sh{
|
||||
anchor="$1"
|
||||
eval "set -- $kak_opt_doc_anchors"
|
||||
eval "set -- $kak_quoted_opt_doc_anchors"
|
||||
|
||||
shift
|
||||
for range in "$@"; do
|
||||
|
@ -74,7 +74,7 @@ define-command doc-jump-to-anchor -params 1 %{
|
|||
define-command doc-follow-link %{
|
||||
update-option buffer doc_links
|
||||
evaluate-commands %sh{
|
||||
eval "set -- $kak_opt_doc_links"
|
||||
eval "set -- $kak_quoted_opt_doc_links"
|
||||
for link in "$@"; do
|
||||
printf '%s\n' "$link"
|
||||
done | awk -v FS='[.,|#]' '
|
||||
|
|
|
@ -85,7 +85,7 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{
|
|||
define-command -hidden lint-show %{
|
||||
update-option buffer lint_errors
|
||||
evaluate-commands %sh{
|
||||
eval "set -- ${kak_opt_lint_errors}"
|
||||
eval "set -- ${kak_quoted_opt_lint_errors}"
|
||||
shift
|
||||
|
||||
s=""
|
||||
|
@ -124,7 +124,7 @@ define-command lint-next-error -docstring "Jump to the next line that contains a
|
|||
update-option buffer lint_errors
|
||||
|
||||
evaluate-commands %sh{
|
||||
eval "set -- ${kak_opt_lint_errors}"
|
||||
eval "set -- ${kak_quoted_opt_lint_errors}"
|
||||
shift
|
||||
|
||||
for i in "$@"; do
|
||||
|
@ -148,7 +148,7 @@ define-command lint-previous-error -docstring "Jump to the previous line that co
|
|||
update-option buffer lint_errors
|
||||
|
||||
evaluate-commands %sh{
|
||||
eval "set -- ${kak_opt_lint_errors}"
|
||||
eval "set -- ${kak_quoted_opt_lint_errors}"
|
||||
shift
|
||||
|
||||
for i in "$@"; do
|
||||
|
|
|
@ -134,12 +134,13 @@ pid_t spawn_shell(const char* shell, StringView cmdline,
|
|||
|
||||
Vector<String> generate_env(StringView cmdline, const Context& context, const ShellContext& shell_context)
|
||||
{
|
||||
static const Regex re(R"(\bkak_(\w+)\b)");
|
||||
static const Regex re(R"(\bkak_(quoted_)?(\w+)\b)");
|
||||
|
||||
Vector<String> kak_env;
|
||||
for (auto&& match : RegexIterator{cmdline.begin(), cmdline.end(), re})
|
||||
{
|
||||
StringView name{match[1].first, match[1].second};
|
||||
StringView name{match[2].first, match[2].second};
|
||||
Quoting quoting = match[1].matched ? Quoting::Shell : Quoting::Raw;
|
||||
|
||||
auto match_name = [&](const String& s) {
|
||||
return s.substr(0_byte, name.length()) == name and
|
||||
|
@ -152,9 +153,10 @@ Vector<String> generate_env(StringView cmdline, const Context& context, const Sh
|
|||
try
|
||||
{
|
||||
const String& value = var_it != shell_context.env_vars.end() ?
|
||||
var_it->value : ShellManager::instance().get_val(name, context, Quoting::Shell);
|
||||
var_it->value : ShellManager::instance().get_val(name, context, quoting);
|
||||
|
||||
kak_env.push_back(format("kak_{}={}", name, value));
|
||||
StringView quoted{match[1].first, match[1].second};
|
||||
kak_env.push_back(format("kak_{}{}={}", quoted, name, value));
|
||||
} catch (runtime_error&) {}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user