1(import mpd2 [protocol [commands]]3 [protocol.util :as util])4(require [hy.contrib.walk [let]]5 [hy.extra.anaphoric [*]])67;; TODO: tagtypes code could use sets instead of lists.89(defn list-tagtypes [ctx]10 (reduce (fn [lst key]11 (if (and (not (in key util.MPD-BASIC-TAGS))12 (not (in key ctx.disabled-tags)))13 (.append lst (.format "tagtype: {}" key)))14 lst)15 (.values util.MPD-TAG-NAMES) []))1617(defn disable-tagtypes [ctx tags]18 (ctx.disabled-tags.extend19 (filter (fn [tag]20 (and (not (in tag util.MPD-BASIC-TAGS))21 (not (in tag ctx.disabled-tags))))22 tags)))2324(defn enable-tagtypes [ctx tags]25 (ap-each tags26 (if (in it (. ctx disabled-tags))27 (.remove (. ctx disabled-tags) it))))2829(defn clear-tagtypes [ctx]30 (ctx.disabled-tags.extend31 (filter (fn [tag] (not (in tag util.MPD-BASIC-TAGS)))32 (.values util.MPD-TAG-NAMES))))3334(defn all-tagtypes [ctx]35 (.clear ctx.disabled-tags))3637(with-decorator (commands.add "tagtypes")38 (defn tagtypes [ctx args]39 (if (not args)40 (list-tagtypes ctx)41 (cond42 [(= "disable" (first args))43 (disable-tagtypes ctx (list (rest args)))]44 [(= "enable" (first args))45 (enable-tagtypes ctx (list (rest args)))]46 [(= "clear" (first args))47 (clear-tagtypes ctx)]48 [(= "all" (first args))49 (all-tagtypes ctx)]50 [True (raise NotImplementedError)]))))