Skip to content

Commit 0de8252

Browse files
Support name metadata
1 parent 5e4752b commit 0de8252

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+201
-197
lines changed

src/algorithm_mnemonics_emacs/core.clj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
["-h" "--help"]])
1313

1414
(defn- parse [s]
15-
(xml/parse
16-
(java.io.ByteArrayInputStream. (.getBytes s))))
15+
(xml/parse (java.io.ByteArrayInputStream. (.getBytes s))))
1716

1817
(defn- snippet-name [mnemonic]
18+
"Name of the mnemonic"
19+
(get-in mnemonic [:attrs :en]))
20+
21+
(defn- snippet-key [mnemonic]
1922
"Name of the mnemonic"
2023
(get-in mnemonic [:attrs :n]))
2124

@@ -29,10 +32,10 @@
2932
(println "Writting snippet in " path)
3033
(spit path snippet)))
3134

32-
(defn- snippet-data [name code]
35+
(defn- snippet-data [name key code]
3336
(str "# -*- mode: snippet -*-\n"
3437
"# name: " name "\n"
35-
"# key: " name "\n"
38+
"# key: " key "\n"
3639
"# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>\n"
3740
"# --"
3841
code
@@ -60,10 +63,11 @@
6063

6164
(defn- snippet [mnemonic directory]
6265
(let [name (snippet-name mnemonic)
66+
key (snippet-key mnemonic)
6367
code (-> (snippet-code mnemonic)
6468
sanitize
6569
convert-placeholders)]
66-
(snippet-write name (snippet-data name code) directory)))
70+
(snippet-write key (snippet-data name key code) directory)))
6771

6872
(defn- do-it [path file]
6973
(let [raw-mnemonics (parse (slurp file))

test/acl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- mode: snippet -*-
2-
# name: acl
2+
# name: accumulate
33
# key: acl
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
auto sum = std::accumulate(begin(${1:container}), end($1), 0, [](int total, $2) {
6+
auto sum = std::accumulate(std::begin(${1:container}), std::end($1), 0, [](int total, $2) {
77
$3
88
});
99
$0

test/acm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- mode: snippet -*-
2-
# name: acm
2+
# name: accumulate
33
# key: acm
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
auto sum = std::accumulate(begin(${1:container}), end($1), 0);
6+
auto sum = std::accumulate(std::begin(${1:container}), std::end($1), 0);
77
$0

test/ajf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- mode: snippet -*-
2-
# name: ajf
2+
# name: adjacent_find
33
# key: ajf
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
auto pos = std::adjacent_find(begin(${1:container}), end($1));
7-
if (pos != end($1)) {
8-
$2
6+
auto pos = std::adjacent_find(std::begin(${1:container}), std::end($1));
7+
if (pos != std::end($1)) {
8+
$2
99
}
1010
$0

test/alo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- mode: snippet -*-
2-
# name: alo
2+
# name: all_of
33
# key: alo
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
if (std::all_of(begin(${1:container}), end($1), []($2) {
6+
if (std::all_of(std::begin(${1:container}), std::end($1), []($2) {
77
$3
88
})) {
99
$4

test/ano

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- mode: snippet -*-
2-
# name: ano
2+
# name: any_of
33
# key: ano
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
if (std::any_of(begin(${1:container}), end($1), []($2) {
6+
if (std::any_of(std::begin(${1:container}), std::end($1), []($2) {
77
$3
88
})) {
99
$4

test/cni

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- mode: snippet -*-
2-
# name: cni
2+
# name: count_if
33
# key: cni
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
auto n = std::count_if(begin(${1:container}), end($1), []($2) {
6+
auto n = std::count_if(std::begin(${1:container}), std::end($1), []($2) {
77
$3
88
});
99
$0

test/cnt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- mode: snippet -*-
2-
# name: cnt
2+
# name: count
33
# key: cnt
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
auto n = std::count(begin(${1:container}), end($1), $2);
6+
auto n = std::count(std::begin(${1:container}), std::end($1), $2);
77
$0

test/cpb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- mode: snippet -*-
2-
# name: cpb
2+
# name: copy_backward
33
# key: cpb
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
std::copy_backward(begin(${1:container}), end($1), end($1));
6+
std::copy_backward(std::begin(${1:container}), std::end($1), std::end($1));
77
$0

test/cpi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- mode: snippet -*-
2-
# name: cpi
2+
# name: copy_if
33
# key: cpi
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <ludwig@lud.cc>
55
# --
6-
std::copy_if(begin(${1:container}), end($1), begin($2),
6+
std::copy_if(std::begin(${1:container}), std::end($1), std::begin($2),
77
[]($3) {
8-
$4
8+
$4
99
});
1010
$0

0 commit comments

Comments
 (0)