From bcea9be689f10c4542bc7024439b1b380502e203 Mon Sep 17 00:00:00 2001 From: Mohammad Reza Karimi Date: Wed, 18 Dec 2024 17:25:40 +0100 Subject: [PATCH] fix(template): expandable variables in lua expr This fixes the order which the template is compiled. Previously, the expressions %() were compiled before expandable variables (such as %x). This made the example template in [1] to produce: * [[url][x]] instead of * [[url][end part of the url]] By doing the expression compilation after expandable ones, this issue is resolved. [1] https://github.com/nvim-orgmode/orgmode/wiki/Getting-Started#captures --- lua/orgmode/capture/template/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/orgmode/capture/template/init.lua b/lua/orgmode/capture/template/init.lua index d1fcf1c5f..372b3d927 100644 --- a/lua/orgmode/capture/template/init.lua +++ b/lua/orgmode/capture/template/init.lua @@ -250,7 +250,6 @@ end ---@return OrgPromise function Template:_compile(content, content_type) content = self:_compile_dates(content) - content = self:_compile_expressions(content) if self._compile_hooks then for _, hook in ipairs(self._compile_hooks) do content = hook(content, content_type) --[[@as string]] @@ -267,6 +266,7 @@ function Template:_compile(content, content_type) if not cnt then return nil end + cnt = self:_compile_expressions(cnt) return self:_compile_prompts(cnt) end) end)