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 <[email protected]>\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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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

test/cpn

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

test/cpy

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

test/eql

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

test/erm

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

test/ffo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- mode: snippet -*-
2-
# name: ffo
2+
# name: find_first_of
33
# key: ffo
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <[email protected]>
55
# --
6-
auto pos = std::find_first_of(begin(${1:container}), end($1),
7-
begin($2), end($3));
8-
if (pos != end($1)) {
6+
auto pos = std::find_first_of(std::begin(${1:container}), std::end($1),
7+
std::begin($2), std::end($3));
8+
if (pos != std::end($1)) {
99
$4
1010
}
1111
$0

test/fil

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

test/fin

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- mode: snippet -*-
2-
# name: fin
2+
# name: find_if_not
33
# key: fin
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <[email protected]>
55
# --
6-
auto pos = std::find_if_not(begin(${1:container}), end($1),[]($2) {
6+
auto pos = std::find_if_not(std::begin(${1:container}), std::end($1),[]($2) {
77
$3
88
});
9-
if (pos != end($1)) {
9+
if (pos != std::end($1)) {
1010
$4
1111
}
1212
$0

test/fln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- mode: snippet -*-
2-
# name: fln
2+
# name: fill_n
33
# key: fln
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <[email protected]>
55
# --
6-
std::fill_n(begin(${1:container}), $2, $3);
6+
std::fill_n(std::begin(${1:container}), $2, $3);
77
$0

test/fnd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- mode: snippet -*-
2-
# name: fnd
2+
# name: find
33
# key: fnd
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <[email protected]>
55
# --
6-
auto pos = std::find(begin(${1:container}), end($1), $2);
7-
if (pos != end($1)) {
6+
auto pos = std::find(std::begin(${1:container}), std::end($1), $2);
7+
if (pos != std::end($1)) {
88
$3
99
}
1010
$0

test/fne

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- mode: snippet -*-
2-
# name: fne
2+
# name: find_end
33
# key: fne
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <[email protected]>
55
# --
6-
auto pos = std::find_end(begin(${1:container}), end($1),
7-
begin($2), end($3));
8-
if (pos != end($1)) {
6+
auto pos = std::find_std::end(std::begin(${1:container}), std::end($1),
7+
std::begin($2), std::end($3));
8+
if (pos != std::end($1)) {
99
$4
1010
}
1111
$0

test/fni

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- mode: snippet -*-
2-
# name: fni
2+
# name: find_if
33
# key: fni
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <[email protected]>
55
# --
6-
auto pos = std::find_if(begin(${1:container}), end($1), []($2) {
6+
auto pos = std::find_if(std::begin(${1:container}), std::end($1), []($2) {
77
$3
88
});
9-
if (pos != end($1)) {
9+
if (pos != std::end($1)) {
1010
$4
1111
}
1212
$0

test/fre

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

test/gnn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- mode: snippet -*-
2-
# name: gnn
2+
# name: generate_n
33
# key: gnn
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <[email protected]>
55
# --
6-
std::generate_n(begin(${1:container}), $2, []($3) {
6+
std::generate_n(std::begin(${1:container}), $2, []($3) {
77
$4
88
});
99
$0

test/gnr

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

test/ihp

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

test/ihu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- mode: snippet -*-
2-
# name: ihu
2+
# name: is_heap_until
33
# key: ihu
44
# contributor: Tommy BENNETT and Ludwig PACIFICI <[email protected]>
55
# --
6-
auto pos = std::is_heap_until(begin(${1:container}), end($1));
7-
if (pos != end($1)) {
6+
auto pos = std::is_heap_until(std::begin(${1:container}), std::end($1));
7+
if (pos != std::end($1)) {
88
$2
99
}
1010
$0

test/ipr

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

test/ipt

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

test/iss

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

0 commit comments

Comments
 (0)