1 ### vim:ft=zsh:foldmethod=marker
2 ## zsh mla search backend for lookup
3 ## Copyright: 2009, Frank Terbeck <ft@bewatermyfriend.org>
5 LOOKUP_guard || return 1
6 [[ -n ${lookup_describe} ]] &&
7 printf '%s' 'search interface for zsh'\''s ML archive' &&
13 lookup_context="$(LOOKUP_context)"
15 LOOKUP_guard -fd LOOKUP_help_${backend} ||
16 function LOOKUP_help_${backend}() {
17 LOOKUP_guard || return 1
18 printf 'usage: %s [-{n,u,w}] [-{l,y} <arg>] <query>\n' ${backend}
19 printf ' -n search the archives for keywords ('\''normal'\'' mode)\n'
20 printf ' -u search user archive by X-Seq: header\n'
21 printf ' -w search workers archive by X-Seq: header\n'
22 printf ' -l <list> limit search to a specific list\n'
23 printf ' -y <year> limit search to a specific year\n'
24 printf '\n Query zsh[1]'\''s Mailing List Arhive[2].'
25 printf '\n The normal keyword search is done via google'\''s '\''site:'\'' feature.\n'
26 printf ' In X-Seq modes (-u and -w), all non-digits are stripped from query.\n'
27 printf '\n The default mode is '\''normal'\'', which can be modified via the\n'
28 printf ' '\''default-mode'\'' style in this context: %s\n' ${lookup_context}
29 printf ' Valid values are: normal, users, workers\n'
30 printf '\nExamples:\n'
31 printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-mode users\n' ${backend}
32 printf ' %% lookup %s released\n' ${backend}
33 printf ' %% lookup %s -u 12345\n' ${backend}
34 printf ' %% lookup %s -w 12345\n' ${backend}
35 printf '\n[1] <http://zsh.sourceforge.net>\n'
36 printf '[2] <http://www.zsh.org/mla/>\n'
38 LOOKUP_help && return 0
40 if [[ -n ${lookup_complete} ]] ; then
42 '-u[users x-seq search]:users\: X-Seq header number:'
43 '-w[workers x-seq search]:workers\: X-Seq header number:'
44 '-l[limit search to a specific list]:list name:(users workers "*")'
45 '-y[limit search to a specific year]:year - "*" means all years:'
46 '*:zsh mla search:true'
49 _arguments -s -w -A '-*' ${comp_args} && return 0
50 _message 'zsh mla search'
67 LOOKUP_parseopts "$@" || return 1
68 [[ ${opts[-u]} == 'yes' ]] && mode='users'
69 [[ ${opts[-w]} == 'yes' ]] && mode='workers'
70 [[ ${opts[-n]} == 'yes' ]] && mode='normal'
71 [[ -n ${opts[-l]} ]] && list="${opts[-l]}"
72 [[ -n ${opts[-y]} ]] && year="${opts[-y]}"
74 if [[ -z ${mode} ]] ; then
75 zstyle -s "${lookup_context}" default-mode mode || mode='normal'
79 LOOKUP_query_handler || return 1
80 if [[ -z ${QUERY} ]] ; then
87 QUERY="${QUERY//[^0-9]/}"
88 if [[ ${mode} == 'users' ]] ; then
89 LOOKUP_browser "http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=${QUERY}"
92 LOOKUP_browser "http://www.zsh.org/cgi-bin/mla/redirect?WORKERNUMBER=${QUERY}"
98 LOOKUP_browser "http://www.google.com/search?q=site:www.zsh.org/mla/${list}/${year}/+${QUERY}"