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