1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29\input mtxcontextcommon.tex
30
31\setupbodyfont
32 [dejavu]
33
34\unexpanded\def\ShowMeaning#1
35 {\ctxlua{logs.pushtarget("both")}
36 \writestatus{meaning}{\strippedcsname#1}
37 \writestring{}
38 \writestring{\expandafter\meaning\begincsname#1\endcsname}
39 \ctxlua{logs.poptarget()}}
40
41\unexpanded\def\ShowTokens#1
42 {\ctxlua{logs.pushtarget("both")}
43 \writestatus{tokens}{\strippedcsname#1}
44 \writestring{}
45 \ifcase\contextlmtxmode
46 \writestring{only supported in lmtx}
47 \else
48 \expandafter\showluatokens\begincsname#1\endcsname
49 \fi
50 \ctxlua{logs.poptarget()}}
51
52\starttext
53
54\usemodule[setupsmacros]
55
56\startluacode
57 local h = tex.hashtokens()
58 local t = environment.arguments.tokens
59
60 local function showmeaning(str)
61 local h = interfaces.macros.collect(str)
62 context("pattern: ")
63 context.type(str)
64 context.blank()
65 for i=1,#h do
66 local hi = h[i]
67 context.type(hi)
68 context.par()
69 if t then
70 context.ShowTokens(hi)
71 else
72 context.ShowMeaning(hi)
73 end
74 end
75 context.page()
76 end
77
78 local done = false
79 local pattern = document.arguments.pattern
80
81 if pattern then
82 pattern = { pattern}
83 else
84 pattern = document.files
85 end
86
87 if type(pattern) == "table" then
88 table.sort(pattern)
89 for i=1,#pattern do
90 local p = pattern[i]
91 if not string.find(p,"^mtx%-context%-") then
92 done = true
93 showmeaning(p)
94 end
95 end
96 end
97
98 if not done then
99 context("no search pattern given")
100 end
101\stopluacode
102
103\stoptext
104 |