+## p : string -> unit
+p() {
+ awk \
+ -v _s="$1" \
+ '
+ BEGIN {_s = tolower(_s)}
+
+ /^[a-zA-Z]/ && tolower($1) ~ _s && NF >= 2 {
+ n++
+ s = $1
+ p = $NF
+ if (NF == 2) {
+ e = ""
+ u = ""
+ } else if (NF == 3) {
+ e = $2
+ u = ""
+ } else {
+ e = $2
+ u = $3
+ } # TODO What would NF > 4 mean?
+
+ printf("%d [O] s:\"%s\", e:\"%s\", u:\"%s\"\n", n, s, e, u) > "/dev/stderr"
+ if (match(u, "@")) {
+ tmp = e
+ e = u
+ u = tmp
+ printf("%d [C] s:\"%s\", e:\"%s\", u:\"%s\"\n", n, s, e, u) > "/dev/stderr"
+ }
+
+ printf "%s", p # XXX Intentionally avoiding newline in the result.
+ }
+ ' \
+ ~/._p/p \
+ | xsel -i -b -t 30000
+}
+
+## web search
+## ws : string -> unit
+ws() {
+ local line search_string0 search_string
+
+ search_string0="$*"
+ case "$search_string0" in
+ '')
+ while read -r line; do
+ search_string="${search_string} ${line}"
+ done;;
+ *)
+ search_string="$search_string0";;
+ esac
+
+ firefox --search "$search_string"
+}
+
+
+## dictionary
+## d : string -> string list