summaryrefslogtreecommitdiff
path: root/scripts/context/lua/mtx-interface.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-01-17 13:51:05 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-01-17 13:51:05 +0100
commit84591a31c39887dbf582df5d535f1de1a115fd62 (patch)
tree1c4613a1c79db3cdfb41b977c64e993492fbdd88 /scripts/context/lua/mtx-interface.lua
parenta16cd078a5cc00d7c789093b5209b6f8d2dfdb1a (diff)
downloadcontext-84591a31c39887dbf582df5d535f1de1a115fd62.tar.gz
2018-01-17 13:16:00
Diffstat (limited to 'scripts/context/lua/mtx-interface.lua')
-rw-r--r--scripts/context/lua/mtx-interface.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/context/lua/mtx-interface.lua b/scripts/context/lua/mtx-interface.lua
index 7ffdd924e..85ccb3ca0 100644
--- a/scripts/context/lua/mtx-interface.lua
+++ b/scripts/context/lua/mtx-interface.lua
@@ -35,6 +35,7 @@ local helpinfo = [[
<flag name="text"><short>create text files for commands and environments</short></flag>
<flag name="raw"><short>report commands to the console</short></flag>
<flag name="check"><short>generate check file</short></flag>
+ <flag name="meaning"><short>report the mening of commands</short></flag>
</subcategory>
<subcategory>
<flag name="toutf"><short>replace named characters by utf</short></flag>
@@ -44,6 +45,9 @@ local helpinfo = [[
<flag name="suffix"><short>use given suffix for output files</short></flag>
<flag name="force"><short>force action even when in doubt</short></flag>
</subcategory>
+ <subcategory>
+ <flag name="pattern"><short>a pattern for meaning lookups</short></flag>
+ </subcategory>
</category>
</flags>
</application>
@@ -666,12 +670,34 @@ function scripts.interface.toutf()
end
end
+function scripts.interface.meaning()
+ local runner = "mtxrun --silent --script context --extra=meaning --once --noconsole --nostatistics"
+ local pattern = environment.arguments.pattern
+ local files = environment.files
+ if type(pattern) == "string" then
+ runner = runner .. ' --pattern="' .. pattern .. '"'
+ elseif files and #files > 0 then
+ for i=1,#files do
+ runner = runner .. ' "' .. files[i] .. '"'
+ end
+ else
+ return
+ end
+ local r = os.resultof(runner)
+ if type(r) == "string" then
+ r = gsub(r,"^.-(meaning%s+>)","\n%1")
+ print(r)
+ end
+end
+
local ea = environment.argument
if ea("mkii") then
scripts.interface.mkii()
elseif ea("preprocess") then
scripts.interface.preprocess()
+elseif ea("meaning") then
+ scripts.interface.meaning()
elseif ea("toutf") then
scripts.interface.toutf()
elseif ea("bidi") then