blob: 2ec66780eb5861f274b86c8b6c6d6e677625d816 (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
%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
% context --extra=meaning --once --noconsole --nostatistics setuplayout
% mtxrun --silent --script context --extra=meaning --once --noconsole --nostatistics setuplayout
% mtxrun --script interface --meaning setuplayout
%
% end help
\input mtx-context-common.tex
\setupbodyfont
[dejavu]
\unexpanded\def\ShowMeaning#1%
{\ctxlua{logs.pushtarget("both")}%
\writestatus{meaning}{\strippedcsname#1}%
\writestring{}%
\writestring{\expandafter\meaning\begincsname#1\endcsname}%
\ctxlua{logs.poptarget()}}
\unexpanded\def\ShowTokens#1%
{\ctxlua{logs.pushtarget("both")}%
\writestatus{tokens}{\strippedcsname#1}%
\writestring{}%
\ifcase\contextlmtxmode
\writestring{only supported in lmtx}%
\else
\expandafter\showluatokens\begincsname#1\endcsname
\fi
\ctxlua{logs.poptarget()}}
\starttext
\usemodule[setups-macros]
\startluacode
local h = tex.hashtokens()
local t = environment.arguments.tokens
local function showmeaning(str)
local h = interfaces.macros.collect(str)
context("pattern: ")
context.type(str)
context.blank()
for i=1,#h do
local hi = h[i]
context.type(hi)
context.par()
if t then
context.ShowTokens(hi)
else
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
|