annotate lisp/webjump.el @ 17988:2e732d9d5b79

(dired-find-file): Likewise.
author Kenichi Handa <handa@m17n.org>
date Wed, 28 May 1997 03:35:42 +0000
parents 52395fdffffe
children c18511c53797
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15986
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; webjump.el --- programmable Web hotlist
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1996 Free Software Foundation
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Neil W. Van Dyke <nwv@acm.org>
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Created: Fri 09 Aug 1996
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: comm www
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; X-URL: http://www.cs.brown.edu/people/nwv/
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; WebJump provides a sort of ``programmable hotlist'' of Web sites that can
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; quickly be invoked in your Web browser. Each Web site in the hotlist has a
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; name, and you select the desired site name via a completing string prompt in
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; the minibuffer. The URL for each Web site is defined as a static string or
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; a built-in or custom function, allowing interactive prompting for
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; site-specific queries and options.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; Note that WebJump was originally intended to complement your conventional
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; browser-based hotlist, not replace it. (Though there's no reason you
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; couldn't use WebJump for your entire hotlist if you were so inclined.)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; The `webjump-sites' variable, which defines the hotlist, defaults to some
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; example sites. You'll probably want to override it with your own favorite
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; sites. The documentation for the variable describes the syntax.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; You may wish to add something like the following to your `.emacs' file:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;;
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; (load "webjump")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; (global-set-key "\C-cj" 'webjump)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; (setq webjump-sites
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; (append '(
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; ("My Home Page" . "www.someisp.net/users/joebobjr/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; ("Pop's Site" . "www.joebob-and-son.com/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; )
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; webjump-sample-sites))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;;
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; The above loads this package, binds `C-c j' to invoke WebJump, and adds
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; your personal favorite sites to the hotlist.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; The `webjump-sample-sites' constant mostly contains sites that are expected
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; to be generally useful to Emacs users or that have some sort of query which
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; can be coded in WebJump. There are two main goals of this sample site list:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; (1) demonstrate WebJump capabilities and usage; (2) provide definitions for
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; many popular sites so that people don't have to reinvent the wheel. A few
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; assorted other sites have been thrown in on a whim. No commercial sites are
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; included unless they provide a free, generally-useful service. Inclusion of
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; a site does not represent an endorsement. Please contact the maintainer
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; with change requests.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; The `browse-url' package is used to submit URLs to the browser, so any
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; browser-specific configuration should be done there.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; WebJump inherits a small amount code from my `altavista.el' package, and is
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; intended to obsolete that package.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;;; Code:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;;-------------------------------------------------------- Package Dependencies
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (require 'browse-url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;;------------------------------------------------------------------- Constants
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81
15991
ae72a4c02f31 (webjump-sample-sites): Define with defvar.
Richard M. Stallman <rms@gnu.org>
parents: 15986
diff changeset
82 (defvar webjump-sample-sites
15986
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 '(("AltaVista" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 [simple-query
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 "www.altavista.digital.com"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 "www.altavista.digital.com/cgi-bin/query?pg=aq&what=web&fmt=.&q="
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 "&r=&d0=&d1="])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ("Archie" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 [simple-query "http://hoohoo.ncsa.uiuc.edu/cgi-bin/AA.pl"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 "http://hoohoo.ncsa.uiuc.edu/cgi-bin/AA.pl?query=" ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ("Bastard Operator from Hell" . "www.replay.com/bofh/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ("Computer Professionals for Social Responsibility" . "www.cpsr.org/dox/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ("Electronic Frontier Foundation" . "www.eff.org")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ("Emacs Lisp Archive" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 "ftp://archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive/")
17910
f74cdb2aa9cc (webjump-to-javaapi): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents: 15991
diff changeset
96 ("GNU Project" . "www.gnu.ai.mit.edu")
15986
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ("GNU FTP Archive". [mirrors
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 "ftp://prep.ai.mit.edu/pub/gnu/"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; ASIA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 "ftp://ftp.cs.titech.ac.jp"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 "ftp://tron.um.u-tokyo.ac.jp/pub/GNU/prep"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 "ftp://cair-archive.kaist.ac.kr/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 "ftp://ftp.nectec.or.th/pub/mirrors/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; AUSTRALIA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 "ftp://archie.au/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 "ftp://archie.oz/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 "ftp://archie.oz.au/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; AFRICA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 "ftp://ftp.sun.ac.za/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; MIDDLE-EAST:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 "ftp://ftp.technion.ac.il/pub/unsupported/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;; EUROPE:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 "ftp://irisa.irisa.fr/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 "ftp://ftp.univ-lyon1.fr/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 "ftp://ftp.mcc.ac.uk"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 "ftp://unix.hensa.ac.uk/mirrors/uunet/systems/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 "ftp://src.doc.ic.ac.uk/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 "ftp://ftp.ieunet.ie/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 "ftp://ftp.eunet.ch"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 "ftp://nic.switch.ch/mirror/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 "ftp://ftp.informatik.rwth-aachen.de/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 "ftp://ftp.informatik.tu-muenchen.de"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 "ftp://ftp.win.tue.nl/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 "ftp://ftp.nl.net"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 "ftp://ftp.etsimo.uniovi.es/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 "ftp://ftp.funet.fi/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 "ftp://ftp.denet.dk"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 "ftp://ftp.stacken.kth.se"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 "ftp://isy.liu.se"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 "ftp://ftp.luth.se/pub/unix/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 "ftp://ftp.sunet.se/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 "ftp://archive.eu.net"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; SOUTH AMERICA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 "ftp://ftp.inf.utfsm.cl/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 "ftp://ftp.unicamp.br/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; WESTERN CANADA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 "ftp://ftp.cs.ubc.ca/mirror2/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; USA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 "ftp://wuarchive.wustl.edu/systems/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 "ftp://labrea.stanford.edu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 "ftp://ftp.digex.net/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 "ftp://ftp.kpc.com/pub/mirror/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 "ftp://f.ms.uky.edu/pub3/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 "ftp://jaguar.utah.edu/gnustuff"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 "ftp://ftp.hawaii.edu/mirrors/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 "ftp://uiarchive.cso.uiuc.edu/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "ftp://ftp.cs.columbia.edu/archives/gnu/prep"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 "ftp://gatekeeper.dec.com/pub/GNU"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 "ftp://ftp.uu.net/systems/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ("Interactive Weather Information Network" . webjump-to-iwin)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ("Lycos" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 [simple-query "www.lycos.com" "www.lycos.com/cgi-bin/pursuit?query=" ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ("Usenet FAQs" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 [simple-query "www.cis.ohio-state.edu/hypertext/faq/usenet/FAQ-List.html"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 "www.cis.ohio-state.edu/htbin/search-usenet-faqs/form?find="
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ("Risks Digest" . webjump-to-risks)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ("RTFM Usenet FAQs by Group" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 "ftp://rtfm.mit.edu/pub/usenet-by-group/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ("RTFM Usenet FAQs by Hierachy" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 "ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ("X Consortium Archive". "ftp.x.org")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ("Yahoo" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 [simple-query "www.yahoo.com" "search.yahoo.com/bin/search?p=" ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ("Yahoo Reference" "www.yahoo.com/Reference/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 )
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 "Sample hotlist for WebJump.")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
15991
ae72a4c02f31 (webjump-sample-sites): Define with defvar.
Richard M. Stallman <rms@gnu.org>
parents: 15986
diff changeset
170 (defvar webjump-state-to-postal-alist
15986
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 '(("Alabama" . "al") ("Alaska" . "ak") ("Arizona" . "az") ("Arkansas" . "ar")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ("California" . "ca") ("Colorado" . "co") ("Connecticut" . "ct")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ("Delaware" . "de") ("Florida" . "fl") ("Georgia" . "ga") ("Hawaii" . "hi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 ("Idaho" . "id") ("Illinois" . "il") ("Indiana" . "in") ("Iowa" . "ia")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ("Kansas" . "ks") ("Kentucky" . "ky") ("Louisiana" . "la") ("Maine" . "me")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 ("Maryland" . "md") ("Massachusetts" . "ma") ("Michigan" . "mi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 ("Minnesota" . "mn") ("Mississippi" . "ms") ("Missouri" . "mo")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 ("Montana" . "mt") ("Nebraska" . "ne") ("Nevada" . "nv")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ("New Hampshire" . "nh") ("New Jersey" . "nj") ("New Mexico" . "nm")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ("New York" . "ny") ("North Carolina" . "nc") ("North Dakota" . "nd")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ("Ohio" . "oh") ("Oklahoma" . "ok") ("Oregon" . "or")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ("Pennsylvania" . "pa") ("Rhode Island" . "ri") ("South Carolina" . "sc")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ("South Dakota" . "sd") ("Tennessee" . "tn") ("Texas" . "tx")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ("Utah" . "ut") ("Vermont" . "vt") ("Virginia" . "va")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ("Washington" . "wa") ("West Virginia" . "wv") ("Wisconsin" . "wi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ("Wyoming" . "wy")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;;------------------------------------------------------------ Option Variables
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (defvar webjump-sites
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 webjump-sample-sites
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 "*Hotlist for WebJump.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 The hotlist is represented as an association list, with the CAR of each cell
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 being the name of the Web site, and the CDR being the definition for the URL of
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 that site. The URL definition can be a string (the URL), a vector (specifying
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 a special \"builtin\" which returns a URL), a symbol (name of a function which
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 returns a URL), or a list (which when `eval'ed yields a URL).
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 If the URL definition is a vector, then a \"builtin\" is used. A builtin has a
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 Lisp-like syntax, with the name as the first element of the vector, and any
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 arguments as the following elements. The three current builtins are `name',
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 which returns the name of the site as the URL, `simple-query', which
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 returns a URL that is a function of a query entered by the user, and `mirrors',
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 which allows the user to select from among multiple mirror sites for the same
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 content.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 The first argument to the `simple-query' builtin is a static URL to use if the
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 user enters a blank query. The second and third arguments are the prefix and
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 suffix, respectively, to add to the encoded query the user enters. This
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 builtin covers Web sites that have single-string searches with the query
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 embedded in the URL.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 The arguments to the `mirrors' builtin are URLs of mirror sites.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 If the symbol of a function is given, then the function will be called with the
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 Web site name (the one you specified in the CAR of the alist cell) as a
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 parameter. This might come in handy for various kludges.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 For convenience, if the `http://', `ftp://', or `file://' prefix is missing
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 from a URL, WebJump will make a guess at what you wanted and prepend it before
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 submitting the URL.")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 ;;------------------------------------------------------- Sample Site Functions
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (defun webjump-to-iwin (name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (let ((prefix "http://iwin.nws.noaa.gov/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (state (webjump-read-choice name "state"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (append '(("Puerto Rico" . "pr"))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 webjump-state-to-postal-alist))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (if state
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (concat prefix "iwin/" state "/"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (webjump-read-choice name "option"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 '(("Hourly Report" . "hourly")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 ("State Forecast" . "state")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 ("Local Forecast" . "local")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 ("Zone Forecast" . "zone")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 ("Short-Term Forecast" . "shortterm")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 ("Weather Summary" . "summary")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 ("Public Information" . "public")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 ("Climatic Data" . "climate")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ("Aviation Products" . "aviation")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 ("Hydro Products" . "hydro")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 ("Special Weather" . "special")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ("Watches and Warnings" . "warnings"))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 "zone")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 ".html")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 prefix)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (defun webjump-to-risks (name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (let (issue volume)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (if (and (setq volume (webjump-read-number (concat name " volume")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (setq issue (webjump-read-number (concat name " issue"))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (format "catless.ncl.ac.uk/Risks/%d.%02d.html" volume issue)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 "catless.ncl.ac.uk/Risks/")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 ;;-------------------------------------------------------------- Core Functions
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 ;;;###autoload
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (defun webjump ()
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 "Jumps to a Web site from a programmable hotlist.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 See the documentation for the `webjump-sites' variable for how to customize the
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 hotlist.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 Feedback on WebJump can be sent to the author, Neil W. Van Dyke <nwv@acm.org>,
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 or submitted via `\\[webjump-submit-bug-report]'. The latest version can be
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 gotten from `http://www.cs.brown.edu/people/nwv/'."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (interactive)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (let* ((completion-ignore-case t)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (item (assoc (completing-read "WebJump to site: " webjump-sites nil t)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 webjump-sites))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (name (car item))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (expr (cdr item)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (funcall browse-url-browser-function
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (webjump-url-fix
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (cond ((not expr) "")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 ((stringp expr) expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ((vectorp expr) (webjump-builtin expr name))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 ((listp expr) (eval expr))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 ((symbolp expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (if (fboundp expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (funcall expr name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (error "WebJump URL function \"%s\" undefined." expr)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (t (error "WebJump URL expression for \"%s\" invalid."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 name)))))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (defun webjump-builtin (expr name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (if (< (length expr) 1)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (error "WebJump URL builtin for \"%s\" empty." name))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (let ((builtin (aref expr 0)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (cond
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 ((eq builtin 'mirrors)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (if (= (length expr) 1)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (error
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 "WebJump URL builtin \"mirrors\" for \"%s\" needs at least 1 arg."))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (webjump-choose-mirror name (cdr (append expr nil))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 ((eq builtin 'name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 ((eq builtin 'simple-query)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (webjump-builtin-check-args expr name 3)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (webjump-do-simple-query name (aref expr 1) (aref expr 2) (aref expr 3)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (t (error "WebJump URL builtin \"%s\" for \"%s\" invalid."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 builtin name)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (defun webjump-builtin-check-args (expr name count)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (or (= (length expr) (1+ count))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (error "WebJump URL builtin \"%s\" for \"%s\" needs %d args."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (aref expr 0) name count)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (defun webjump-choose-mirror (name urls)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (webjump-read-url-choice (concat name " mirror")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 urls
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (webjump-mirror-default urls)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (defun webjump-do-simple-query (name noquery-url query-prefix query-suffix)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (let ((query (webjump-read-string (concat name " query"))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (if query
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (concat query-prefix (webjump-url-encode query) query-suffix)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 noquery-url)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (defun webjump-mirror-default (urls)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 ;; Note: This should be modified to apply some simple kludges/heuristics to
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 ;; pick a site which is likely "close". As a tie-breaker among candidates
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 ;; judged equally desirable, randomness should be used.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (car urls))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (defun webjump-read-choice (name what choices &optional default)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (let* ((completion-ignore-case t)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (choice (completing-read (concat name " " what ": ") choices nil t)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (if (webjump-null-or-blank-string-p choice)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 default
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (cdr (assoc choice choices)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (defun webjump-read-number (prompt)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 ;; Note: I should make this more robust someday.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (let ((input (webjump-read-string prompt)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (if input (string-to-number input))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (defun webjump-read-string (prompt)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (let ((input (read-string (concat prompt ": "))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (if (webjump-null-or-blank-string-p input) nil input)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (defun webjump-read-url-choice (what urls &optional default)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 ;; Note: Convert this to use `webjump-read-choice' someday.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (let* ((completions (mapcar (function (lambda (n) (cons n n)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 urls))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (input (completing-read (concat what
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 ;;(if default " (RET for default)" "")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 ": ")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 completions
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 nil
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 t)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (if (webjump-null-or-blank-string-p input)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 default
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (car (assoc input completions)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (defun webjump-null-or-blank-string-p (str)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (or (null str) (string-match "^[ \t]*$" str)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (defun webjump-url-encode (str)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (mapconcat '(lambda (c)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (cond ((= c 32) "+")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 ((or (and (>= c ?a) (<= c ?z))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (and (>= c ?A) (<= c ?Z))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (and (>= c ?0) (<= c ?9)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (char-to-string c))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (t (upcase (format "%%%02x" c)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 str
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 ""))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (defun webjump-url-fix (url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (if (webjump-null-or-blank-string-p url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 ""
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (webjump-url-fix-trailing-slash
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (cond
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 ((string-match "^[a-zA-Z]+:" url) url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 ((string-match "^/" url) (concat "file://" url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 ((string-match "^\\([^\\./]+\\)" url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (concat (if (string= (downcase (match-string 1 url)) "ftp")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 "ftp"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 "http")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 "://"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (t url)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (defun webjump-url-fix-trailing-slash (url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (if (string-match "^[a-zA-Z]+://[^/]+$" url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (concat url "/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 ;;-----------------------------------------------------------------------------
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (provide 'webjump)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 ;; webjump.el ends here