diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-01-14 17:29:49 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2018-01-14 17:29:49 +0100 |
commit | a16cd078a5cc00d7c789093b5209b6f8d2dfdb1a (patch) | |
tree | 3385cd79be0c9b3b66ed3c465b03eefc92001b21 /tex/context/base/mkiv/mtx-context-meaning.tex | |
parent | 52c5102fab837626fe9bb359b3eda6066e1a968e (diff) | |
download | context-a16cd078a5cc00d7c789093b5209b6f8d2dfdb1a.tar.gz |
2018-01-14 16:05:00
Diffstat (limited to 'tex/context/base/mkiv/mtx-context-meaning.tex')
-rw-r--r-- | tex/context/base/mkiv/mtx-context-meaning.tex | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/mtx-context-meaning.tex b/tex/context/base/mkiv/mtx-context-meaning.tex new file mode 100644 index 000000000..88ca21759 --- /dev/null +++ b/tex/context/base/mkiv/mtx-context-meaning.tex @@ -0,0 +1,83 @@ +%D \module +%D [ file=mtx-context-meaning, +%D version=2018.01.12, +%D title=\CONTEXT\ Extra Trickry, +%D subtitle=Show Meanings, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% begin help +% +% usage: context --extra=meaning [options] list-of-commands +% +% --pattern : match given pattern +% +% example: context --extra=meaning --pattern=*paper* +% context --extra=meaning setuplayout +% context --extra=meaning setup_layout +% +% end help + +\input mtx-context-common.tex + +\setupbodyfont + [dejavu] + +\def\showmeaning#1% + {\writestatus{meaning}{\strippedcsname#1}% + \writestring{}% + \writestring{\expandafter\meaning\begincsname#1\endcsname}} + +\starttext + +\startluacode + local h = tex.hashtokens() + + local function showmeaning(str) + local s = string.gsub(str,"^\\","") + local p = "^" .. string.topattern(s) .. "$" + context("pattern: ") + context.type(s) + context.blank() + for i=1,#h do + local hi = h[i] + if string.find(h[i],p) then + context.type(hi) + context.par() + context.showmeaning(hi) + end + end + context.page() + end + + local done = false + local pattern = document.arguments.pattern + + if pattern then + pattern = { pattern} + else + pattern = document.files + end + + if type(pattern) == "table" then + table.sort(pattern) + for i=1,#pattern do + local p = pattern[i] + if not string.find(p,"^mtx%-context%-") then + done = true + showmeaning(p) + end + end + end + + if not done then + context("no search pattern given") + end +\stopluacode + +\stoptext |