mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-26 04:52:53 +03:00
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}")
|
dir=$(dirname "${kak_buffile}")
|
||||||
|
|
||||||
# Set $@ to alt_dirs
|
# Set $@ to alt_dirs
|
||||||
eval "set -- ${kak_opt_alt_dirs}"
|
eval "set -- ${kak_quoted_opt_alt_dirs}"
|
||||||
|
|
||||||
case ${file} in
|
case ${file} in
|
||||||
*.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m)
|
*.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m)
|
||||||
|
@ -92,7 +92,7 @@ provide-module crystal %🐈
|
|||||||
|
|
||||||
evaluate-commands %sh[
|
evaluate-commands %sh[
|
||||||
# Keywords
|
# Keywords
|
||||||
eval "set -- $kak_opt_crystal_keywords"
|
eval "set -- $kak_quoted_opt_crystal_keywords"
|
||||||
regex="\\b(?:\\Q$1\\E"
|
regex="\\b(?:\\Q$1\\E"
|
||||||
shift
|
shift
|
||||||
for keyword do
|
for keyword do
|
||||||
@ -102,7 +102,7 @@ provide-module crystal %🐈
|
|||||||
printf 'add-highlighter shared/crystal/code/keywords regex %s 0:keyword\n' "$regex"
|
printf 'add-highlighter shared/crystal/code/keywords regex %s 0:keyword\n' "$regex"
|
||||||
|
|
||||||
# Attributes
|
# Attributes
|
||||||
eval "set -- $kak_opt_crystal_attributes"
|
eval "set -- $kak_quoted_opt_crystal_attributes"
|
||||||
regex="\\b(?:\\Q$1\\E"
|
regex="\\b(?:\\Q$1\\E"
|
||||||
shift
|
shift
|
||||||
for attribute do
|
for attribute do
|
||||||
@ -112,7 +112,7 @@ provide-module crystal %🐈
|
|||||||
printf 'add-highlighter shared/crystal/code/attributes regex %s 0:attribute\n' "$regex"
|
printf 'add-highlighter shared/crystal/code/attributes regex %s 0:attribute\n' "$regex"
|
||||||
|
|
||||||
# Symbols
|
# Symbols
|
||||||
eval "set -- $kak_opt_crystal_operators"
|
eval "set -- $kak_quoted_opt_crystal_operators"
|
||||||
# Avoid to match modules
|
# Avoid to match modules
|
||||||
regex="(?<!:):(?:\\w+[?!]?"
|
regex="(?<!:):(?:\\w+[?!]?"
|
||||||
for operator do
|
for operator do
|
||||||
@ -122,7 +122,7 @@ provide-module crystal %🐈
|
|||||||
printf 'add-highlighter shared/crystal/code/symbols regex %%(%s) 0:value\n' "$regex"
|
printf 'add-highlighter shared/crystal/code/symbols regex %%(%s) 0:value\n' "$regex"
|
||||||
|
|
||||||
# Objects
|
# Objects
|
||||||
eval "set -- $kak_opt_crystal_objects"
|
eval "set -- $kak_quoted_opt_crystal_objects"
|
||||||
regex="\\b(?:\\Q$1\\E"
|
regex="\\b(?:\\Q$1\\E"
|
||||||
shift
|
shift
|
||||||
for object do
|
for object do
|
||||||
|
@ -139,7 +139,7 @@ define-command clang-disable-autocomplete -docstring "Disable automatic clang co
|
|||||||
define-command -hidden clang-show-error-info %{
|
define-command -hidden clang-show-error-info %{
|
||||||
update-option buffer clang_errors # Ensure we are up to date with buffer changes
|
update-option buffer clang_errors # Ensure we are up to date with buffer changes
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
eval "set -- ${kak_opt_clang_errors}"
|
eval "set -- ${kak_quoted_opt_clang_errors}"
|
||||||
shift # skip timestamp
|
shift # skip timestamp
|
||||||
desc=$(for error in "$@"; do
|
desc=$(for error in "$@"; do
|
||||||
if [ "${error%%|*}" = "$kak_cursor_line" ]; then
|
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" %{
|
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
|
update-option buffer clang_errors # Ensure we are up to date with buffer changes
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
eval "set -- ${kak_opt_clang_errors}"
|
eval "set -- ${kak_quoted_opt_clang_errors}"
|
||||||
shift # skip timestamp
|
shift # skip timestamp
|
||||||
for error in "$@"; do
|
for error in "$@"; do
|
||||||
candidate=${error%%|*}
|
candidate=${error%%|*}
|
||||||
|
@ -15,7 +15,7 @@ declare-option -docstring "shell command to run" str readtagscmd "readtags"
|
|||||||
define-command -params ..1 \
|
define-command -params ..1 \
|
||||||
-shell-script-candidates %{
|
-shell-script-candidates %{
|
||||||
realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) }
|
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
|
for candidate in "$@"; do
|
||||||
[ -f "$candidate" ] && realpath "$candidate"
|
[ -f "$candidate" ] && realpath "$candidate"
|
||||||
done | awk '!x[$0]++' | # remove duplicates
|
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[
|
%[ evaluate-commands %sh[
|
||||||
realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) }
|
realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) }
|
||||||
export tagname="${1:-${kak_selection}}"
|
export tagname="${1:-${kak_selection}}"
|
||||||
eval "set -- $kak_opt_ctagsfiles"
|
eval "set -- $kak_quoted_opt_ctagsfiles"
|
||||||
for candidate in "$@"; do
|
for candidate in "$@"; do
|
||||||
[ -f "$candidate" ] && realpath "$candidate"
|
[ -f "$candidate" ] && realpath "$candidate"
|
||||||
done | awk '!x[$0]++' | # remove duplicates
|
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}"
|
header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}"
|
||||||
compl=$(
|
compl=$(
|
||||||
eval "set -- $kak_opt_ctagsfiles"
|
eval "set -- $kak_quoted_opt_ctagsfiles"
|
||||||
for ctagsfile in "$@"; do
|
for ctagsfile in "$@"; do
|
||||||
${kak_opt_readtagscmd} -p -t "$ctagsfile" ${kak_selection}
|
${kak_opt_readtagscmd} -p -t "$ctagsfile" ${kak_selection}
|
||||||
done | awk '{ uniq[$1]++ } END { for (elem in uniq) printf " %1$s||%1$s", elem }'
|
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}"
|
execute-keys "%arg{3}"
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
face="$4"
|
face="$4"
|
||||||
eval "set -- $kak_selections_desc"
|
eval "set -- $kak_quoted_selections_desc"
|
||||||
for desc in "$@"; do ranges="$ranges '$desc|$face'"; done
|
for desc in "$@"; do ranges="$ranges '$desc|$face'"; done
|
||||||
echo "update-option buffer doc_render_ranges"
|
echo "update-option buffer doc_render_ranges"
|
||||||
echo "set-option -add buffer doc_render_ranges $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
|
update-option buffer doc_anchors
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
anchor="$1"
|
anchor="$1"
|
||||||
eval "set -- $kak_opt_doc_anchors"
|
eval "set -- $kak_quoted_opt_doc_anchors"
|
||||||
|
|
||||||
shift
|
shift
|
||||||
for range in "$@"; do
|
for range in "$@"; do
|
||||||
@ -74,7 +74,7 @@ define-command doc-jump-to-anchor -params 1 %{
|
|||||||
define-command doc-follow-link %{
|
define-command doc-follow-link %{
|
||||||
update-option buffer doc_links
|
update-option buffer doc_links
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
eval "set -- $kak_opt_doc_links"
|
eval "set -- $kak_quoted_opt_doc_links"
|
||||||
for link in "$@"; do
|
for link in "$@"; do
|
||||||
printf '%s\n' "$link"
|
printf '%s\n' "$link"
|
||||||
done | awk -v FS='[.,|#]' '
|
done | awk -v FS='[.,|#]' '
|
||||||
|
@ -85,7 +85,7 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{
|
|||||||
define-command -hidden lint-show %{
|
define-command -hidden lint-show %{
|
||||||
update-option buffer lint_errors
|
update-option buffer lint_errors
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
eval "set -- ${kak_opt_lint_errors}"
|
eval "set -- ${kak_quoted_opt_lint_errors}"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
s=""
|
s=""
|
||||||
@ -124,7 +124,7 @@ define-command lint-next-error -docstring "Jump to the next line that contains a
|
|||||||
update-option buffer lint_errors
|
update-option buffer lint_errors
|
||||||
|
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
eval "set -- ${kak_opt_lint_errors}"
|
eval "set -- ${kak_quoted_opt_lint_errors}"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
for i in "$@"; do
|
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
|
update-option buffer lint_errors
|
||||||
|
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
eval "set -- ${kak_opt_lint_errors}"
|
eval "set -- ${kak_quoted_opt_lint_errors}"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
for i in "$@"; do
|
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)
|
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;
|
Vector<String> kak_env;
|
||||||
for (auto&& match : RegexIterator{cmdline.begin(), cmdline.end(), re})
|
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) {
|
auto match_name = [&](const String& s) {
|
||||||
return s.substr(0_byte, name.length()) == name and
|
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
|
try
|
||||||
{
|
{
|
||||||
const String& value = var_it != shell_context.env_vars.end() ?
|
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&) {}
|
} catch (runtime_error&) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user