-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathalgo-snippets.sty
43 lines (37 loc) · 1.43 KB
/
algo-snippets.sty
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
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\ProvidesExplPackage{algo-snippets}{2025-04-18}{2.4.2}{Snippets that are Commonly used in Algo}
% Package Made by Ruben Deisenroth, 2022
\RequirePackage{l3keys2e}
\RequirePackage{algo-common}
\ExplSyntaxOn
\seq_gclear_new:N \g_algo_snippets_visible_seq
% seq: name, description, params, snippet, visible
%% Command that is used to declare snippets
% #1: starred or not - starred snippets are not included in the list of snippets
% #2: name of the snippet
% #3: description
% #4: snippet
\DeclareDocumentCommand{\DeclareSnippet}{smm+m}{
\exp_args:Nc \DeclareDocumentCommand{__algo_snipets_snippet_#2}{m} {
#4
}
\seq_gclear_new:c {l_algo_snippets_curr_snipet_#2_seq}
\seq_gput_right:cn {l_algo_snippets_curr_snipet_#2_seq} {#2}
\seq_gput_right:cn {l_algo_snippets_curr_snipet_#2_seq} {#3}
\seq_gput_right:cn {l_algo_snippets_curr_snipet_#2_seq} {#4}
\seq_gput_right:cn {l_algo_snippets_curr_snipet_#2_seq} {#1}
\exp_args:Nnf \seq_gput_right:cn {g_algo_snippets_visible_seq} {\use:c {l_algo_snippets_curr_snipet_#2_seq}}
}
%% Command that is used to declare snippets
% #1: starred or not - starred snippets are not included in the list of snippets
% #2: name of the snippet
% #3: arguments
\DeclareDocumentCommand{\UseSnippet}{smo}{
\use:c{__algo_snipets_snippet_#2}{#3}
}
\IfFileExists{snippets.def}{
\ExplSyntaxOff
\input{snippets.def}
\ExplSyntaxOn
}{}