]>
Commit | Line | Data |
---|---|---|
56292c79 RBR |
1 | ------------------------------------------------------------------------------- |
2 | -- Tools to deal with the learning file | |
3 | ------------------------------------------------------------------------------- | |
503d09fc RBR |
4 | local Learning = {} |
5 | ||
6 | local Configuration = require('configuration') | |
7 | local Util = require('util') | |
8 | ------------------------------------------------------------------------------- | |
9 | -- Internal Functions | |
10 | ------------------------------------------------------------------------------- | |
56292c79 RBR |
11 | ------------------------------------------------------------------------------- |
12 | -- Public Interface | |
13 | ------------------------------------------------------------------------------- | |
14 | ||
15 | --- Opens the learning file | |
503d09fc RBR |
16 | function Learning.open() |
17 | local learning_path = Configuration.path_for(Configuration.configuration.learning.learning_file) | |
18 | local learning_parent = Util.directory_name(learning_path) | |
19 | Util.ensure_directory_exists(learning_parent) | |
20 | vim.cmd('edit ' .. learning_path) | |
56292c79 RBR |
21 | end |
22 | ||
23 | --- Capture a learning entry | |
503d09fc RBR |
24 | function Learning.capture() |
25 | local prefix = os.date(Configuration.configuration.learning.prefix) | |
26 | Learning.open() | |
27 | vim.cmd('normal! ggO'..prefix) | |
28 | vim.cmd('startinsert!') | |
56292c79 RBR |
29 | end |
30 | ||
503d09fc | 31 | return Learning |