cmp.utils
apply-to-map-values
(apply-to-map-values f m)Applies function f to the values of the map m.
compl-main-path
(compl-main-path s)Completes the main path by padding a mpd- in case it is missing.
(u/compl-main-path "aaa")
;; "mpd-aaa"
(u/compl-main-path "mpd-aaa")
;; "mpd-aaa"
doc->safe-doc
(doc->safe-doc doc)Replaces all of the @-signs (if followed by letters 1) by a %-sign because :%kw is a valid keyword but :@kw not (or at least problematic).
1) There are devices annotating channeles by (@101:105). This should remain as it is.
ensure-int
(ensure-int i)Ensures i to be integer. Returns 0 as default.
(u/ensure-int 100)
;; 100
(u/ensure-int "w")
;; 0
(u/ensure-int "00")
;; 0
(u/ensure-int "10")
;; 10
(u/ensure-int true)
;; 0
extr-main-path
(extr-main-path s)Extracts the main path. Should work on mpd-aaa-bbb as well as on aaa-bbb.
(u/extr-main-path "aa")
;; "aa"
(u/extr-main-path "aa-bbb")
;; "aa-bbb"
(u/extr-main-path "aa-bbb-lll")
;; "aa-bbb-lll"
lp
(lp i)(lp i n)Left pad the given number if it is not a string. Default is (cfg/key-pad-length (cfg/config)).
Example:
(u/lp 2)
;; "002"
(u/lp "02")
;; "002"
(u/lp 2)
;; "002"
(u/lp true)
;; "000"
(u/lp "003")
;; "003"
(u/lp "000003")
;; "003"
next-ctrl-cmd
(next-ctrl-cmd s)Extracts next command.
#TODO: Enable kind of programming like provided in ssmp:
load;run;stop–>[load, run, stop]load;2:run,stop–>[load, run, stop, run, stop]
pad-ok?
(pad-ok? i)(pad-ok? i n)Checks if the padding of i is ok. "*" serves pattern matching.
short-string
(short-string s)(short-string s n)Short a string s to n or 45 chars. Returns nil is s is not a string.