summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2024-07-31 17:30:48 +0200
committerMaxime Coste <mawww@kakoune.org>2024-08-05 19:14:48 +1000
commitef18d3cbfbd8960df287423d888e2d0f10eae42d (patch)
tree28c1ac7c97421ae18fee4bec54e52f12937a4fc0
parent8a5f449c180d76566eb3eefdb3efb3c7a0116531 (diff)
rc make/grep: evaluate makecmd in calling context, use eval semantics again
I configured :make to use a special makecmd for files called test.cpp. hook global BufCreate .*/test.cpp %{ set-option buffer makecmd "g++ %val{buffile} && ./a.out" } Commit c93cb5c4d (Add a `fifo` helper command and refactor `make` and `grep` to use it, 2024-06-07) made :make evaluate makecmd in the toolsclient context instead of the calling context, so my buffer-local override no longer applies. I'm not sure if this is something we want to guarantee but it doesn't seem unreasonable, and we can fix it a no cost I think. Additionally, it changed eval "${kak_opt_makecmd}" "$@"; to $kak_opt_makecmd "$@" meaning that the "&&" in my makecmd will no longer be evaluated. Instead it will be passed as argument to g++, effectively g++ %val{buffile} '&&' ./a.out which I don't think is a reasonable expectation (unless we change makecmd to be str-list options). Essentially, the above only applies word splitting to makecmd; it seems simpler and less surprising to treat them as raw shell commands. Expand makecmd in the calling client again, and insert it verbatim into the shell script. grep hasn't needed it so far but keep it consistent.
-rw-r--r--rc/tools/grep.kak4
-rw-r--r--rc/tools/make.kak8
2 files changed, 6 insertions, 6 deletions
diff --git a/rc/tools/grep.kak b/rc/tools/grep.kak
index 3847b67b..9d97ffdd 100644
--- a/rc/tools/grep.kak
+++ b/rc/tools/grep.kak
@@ -12,7 +12,7 @@ define-command -params .. -docstring %{
Passing no argument will perform a literal-string grep for the current selection
} grep %{
evaluate-commands -try-client %opt{toolsclient} %{
- fifo -name *grep* -script %{
+ fifo -name *grep* -script %exp{
trap - INT QUIT
if [ $# -eq 0 ]; then
case "$kak_opt_grepcmd" in
@@ -27,7 +27,7 @@ define-command -params .. -docstring %{
;;
esac
fi
- $kak_opt_grepcmd "$@" 2>&1 | tr -d '\r'
+ %opt{grepcmd} "$@" 2>&1 | tr -d '\r'
} -- %arg{@}
set-option buffer filetype grep
set-option buffer jump_current_line 0
diff --git a/rc/tools/make.kak b/rc/tools/make.kak
index 7f161e77..4e148547 100644
--- a/rc/tools/make.kak
+++ b/rc/tools/make.kak
@@ -12,11 +12,11 @@ define-command -params .. -docstring %{
make [<arguments>]: make utility wrapper
All the optional arguments are forwarded to the make utility
} make %{
- evaluate-commands -try-client %opt{toolsclient} %{
- fifo -scroll -name *make* -script %{
+ evaluate-commands -try-client %opt{toolsclient} %exp{
+ fifo -scroll -name *make* -script %%{
trap - INT QUIT
- $kak_opt_makecmd "$@"
- } -- %arg{@}
+ %opt{makecmd} "$@"
+ } -- %%arg{@}
set-option buffer filetype make
set-option buffer jump_current_line 0
}