Add keyboard shortcuts

Also, add macro support
This commit is contained in:
Tienson Qin
2020-07-20 15:45:17 +08:00
parent 16a7c7dacc
commit 78907790ce
12 changed files with 235 additions and 17 deletions

View File

@@ -271,6 +271,18 @@
prefix (if pre-heading? "" (str (apply str (repeat level pattern)) " "))]
(str prefix (string/triml text))))
(defn macro-subs
[macro-content arguments]
(loop [s macro-content
args arguments
n 1]
(if (seq args)
(recur
(string/replace s (str "$" n) (first args))
(rest args)
(inc n))
s)))
(comment
(defn sort-tasks
[headings]

View File

@@ -49,6 +49,20 @@
[(keyword (string/lower-case k))
v]))
(into {}))
macro-directives (filter (fn [x] (= :macro (first x))) directives)
macros (if (seq macro-directives)
(->>
(map
(fn [[_ v]]
(let [[k v] (util/split-first " " v)]
(mapv
string/trim
[k v])))
macro-directives)
(into {}))
{})
directives (->> (remove (fn [x] (= :macro (first x))) directives)
(into {}))
directives (if (seq directives)
(let [directives (->
(cond-> directives
@@ -63,6 +77,7 @@
(update :alias sep-by-quote-or-space)
(update :tags sep-by-quote-or-space)))
directives)
directives (assoc directives :macros macros)
other-ast (drop-while directive? ast)]
(if (seq directives)
(cons ["Directives" directives] other-ast)