# Kakoune needs a real scripting language

**URL:** <https://discuss.kakoune.com/t/kakoune-needs-a-real-scripting-language/575>\
**Category:** Complaints & Improvements\
**Created:** [May 16, 2019, 6:35pm UTC](https://discuss.kakoune.com/t/kakoune-needs-a-real-scripting-language/575 "2019-05-16T18:35:17Z")\
**Posts on this page:** 1\
**Showing post:** 45

<div class="post-metadata">

**Author:** ![TeddyDD](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/teddydd/32/21_2.png) [@TeddyDD](https://discuss.kakoune.com/u/TeddyDD)\
**Post date:** [May 10, 2020, 8:28pm UTC](https://discuss.kakoune.com/t/kakoune-needs-a-real-scripting-language/575/45 "2020-05-10T20:28:09Z")

</div>

[luar](https://discuss.kakoune.com/t/a-lua-command-for-kakoune/1003) plugin by @gustavo-hms got me thinking about custom expansions idea proposed by @bugabinga

```auto
declare-expansion lua '/usr/bin/lua'

evaluate-commands %lua{ print("set-option makecmd '" .. os.getenv'kak_buffile' .. "'") }

```

I’d like to share some thoughts on this:

- expansion behave like functions with single parameter and single return value, therefore custom expansions could be more that simple shorthand for `%sh{!#/usr/bin/lua ...},`
- currently pattern `%sh{!#/usr/bin/lua ...},` cannot be abstracted because there is no way to return anything from command. For example - in luar plugin there is `:lua` command. To return anything from lua code we have to set variable in Kakoune.

Maybe custom expansion should not point directly to some executable, instead they could behave like commands with ability to return single value:

```auto
define-expansion lua %{
    return %sh{ lua -e '$@' }
}
echo %lua{ print "foo" } # evaluates to echo foo

```

---

_[View the full topic](https://discuss.kakoune.com/t/kakoune-needs-a-real-scripting-language/575)._
