Mercurial > emacs
annotate lisp/webjump.el @ 25743:e6246adc8a35
(Vtemporary_file_directory): New variable.
(syms_of_filelock): Set up Lisp variable.
(get_boot_time): Make the temp name in the proper dir.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 16 Sep 1999 19:34:38 +0000 |
parents | 39bac3b71db1 |
children |
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" . |
24950
39bac3b71db1
(webjump-sample-sites): Update some URLs.
Karl Heuer <kwzh@gnu.org>
parents:
23601
diff
changeset
|
77 [mirrors "ftp://ftp.gnu.org/pub/gnu/" |
18169
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"]) |
24950
39bac3b71db1
(webjump-sample-sites): Update some URLs.
Karl Heuer <kwzh@gnu.org>
parents:
23601
diff
changeset
|
129 ("GNU Project Home Page" . "www.gnu.org") |
18169
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" . |
24950
39bac3b71db1
(webjump-sample-sites): Update some URLs.
Karl Heuer <kwzh@gnu.org>
parents:
23601
diff
changeset
|
133 "ftp://ftp.emacs.org/pub/") |
18169
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) | |
21361
f270e8ad8276
(webjump): Use assoc-ignore-case for locating the proper URL.
Richard M. Stallman <rms@gnu.org>
parents:
18169
diff
changeset
|
277 (item (assoc-ignore-case |
f270e8ad8276
(webjump): Use assoc-ignore-case for locating the proper URL.
Richard M. Stallman <rms@gnu.org>
parents:
18169
diff
changeset
|
278 (completing-read "WebJump to site: " webjump-sites nil t) |
f270e8ad8276
(webjump): Use assoc-ignore-case for locating the proper URL.
Richard M. Stallman <rms@gnu.org>
parents:
18169
diff
changeset
|
279 webjump-sites)) |
15986 | 280 (name (car item)) |
281 (expr (cdr item))) | |
23601
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
282 (browse-url (webjump-url-fix |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
283 (cond ((not expr) "") |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
284 ((stringp expr) expr) |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
285 ((vectorp expr) (webjump-builtin expr name)) |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
286 ((listp expr) (eval expr)) |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
287 ((symbolp expr) |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
288 (if (fboundp expr) |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
289 (funcall expr name) |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
290 (error "WebJump URL function \"%s\" undefined." |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
291 expr))) |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
292 (t (error "WebJump URL expression for \"%s\" invalid." |
0049f95b12a7
(webjump-sample-sites): Fix Lisp archive site.
Dave Love <fx@gnu.org>
parents:
21361
diff
changeset
|
293 name))))))) |
15986 | 294 |
295 (defun webjump-builtin (expr name) | |
296 (if (< (length expr) 1) | |
297 (error "WebJump URL builtin for \"%s\" empty." name)) | |
298 (let ((builtin (aref expr 0))) | |
299 (cond | |
300 ((eq builtin 'mirrors) | |
301 (if (= (length expr) 1) | |
302 (error | |
303 "WebJump URL builtin \"mirrors\" for \"%s\" needs at least 1 arg.")) | |
304 (webjump-choose-mirror name (cdr (append expr nil)))) | |
305 ((eq builtin 'name) | |
306 name) | |
307 ((eq builtin 'simple-query) | |
308 (webjump-builtin-check-args expr name 3) | |
309 (webjump-do-simple-query name (aref expr 1) (aref expr 2) (aref expr 3))) | |
310 (t (error "WebJump URL builtin \"%s\" for \"%s\" invalid." | |
311 builtin name))))) | |
312 | |
313 (defun webjump-builtin-check-args (expr name count) | |
314 (or (= (length expr) (1+ count)) | |
315 (error "WebJump URL builtin \"%s\" for \"%s\" needs %d args." | |
316 (aref expr 0) name count))) | |
317 | |
318 (defun webjump-choose-mirror (name urls) | |
319 (webjump-read-url-choice (concat name " mirror") | |
320 urls | |
321 (webjump-mirror-default urls))) | |
322 | |
323 (defun webjump-do-simple-query (name noquery-url query-prefix query-suffix) | |
324 (let ((query (webjump-read-string (concat name " query")))) | |
325 (if query | |
326 (concat query-prefix (webjump-url-encode query) query-suffix) | |
327 noquery-url))) | |
328 | |
329 (defun webjump-mirror-default (urls) | |
330 ;; Note: This should be modified to apply some simple kludges/heuristics to | |
331 ;; 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
|
332 ;; judged equally desirable, randomness might be used. |
15986 | 333 (car urls)) |
334 | |
335 (defun webjump-read-choice (name what choices &optional default) | |
336 (let* ((completion-ignore-case t) | |
337 (choice (completing-read (concat name " " what ": ") choices nil t))) | |
338 (if (webjump-null-or-blank-string-p choice) | |
339 default | |
340 (cdr (assoc choice choices))))) | |
341 | |
342 (defun webjump-read-number (prompt) | |
343 ;; Note: I should make this more robust someday. | |
344 (let ((input (webjump-read-string prompt))) | |
345 (if input (string-to-number input)))) | |
346 | |
347 (defun webjump-read-string (prompt) | |
348 (let ((input (read-string (concat prompt ": ")))) | |
349 (if (webjump-null-or-blank-string-p input) nil input))) | |
350 | |
351 (defun webjump-read-url-choice (what urls &optional default) | |
352 ;; Note: Convert this to use `webjump-read-choice' someday. | |
353 (let* ((completions (mapcar (function (lambda (n) (cons n n))) | |
354 urls)) | |
355 (input (completing-read (concat what | |
356 ;;(if default " (RET for default)" "") | |
357 ": ") | |
358 completions | |
359 nil | |
360 t))) | |
361 (if (webjump-null-or-blank-string-p input) | |
362 default | |
363 (car (assoc input completions))))) | |
364 | |
365 (defun webjump-null-or-blank-string-p (str) | |
366 (or (null str) (string-match "^[ \t]*$" str))) | |
367 | |
368 (defun webjump-url-encode (str) | |
369 (mapconcat '(lambda (c) | |
370 (cond ((= c 32) "+") | |
371 ((or (and (>= c ?a) (<= c ?z)) | |
372 (and (>= c ?A) (<= c ?Z)) | |
373 (and (>= c ?0) (<= c ?9))) | |
374 (char-to-string c)) | |
375 (t (upcase (format "%%%02x" c))))) | |
376 str | |
377 "")) | |
378 | |
379 (defun webjump-url-fix (url) | |
380 (if (webjump-null-or-blank-string-p url) | |
381 "" | |
382 (webjump-url-fix-trailing-slash | |
383 (cond | |
384 ((string-match "^[a-zA-Z]+:" url) url) | |
385 ((string-match "^/" url) (concat "file://" url)) | |
386 ((string-match "^\\([^\\./]+\\)" url) | |
387 (concat (if (string= (downcase (match-string 1 url)) "ftp") | |
388 "ftp" | |
389 "http") | |
390 "://" | |
391 url)) | |
392 (t url))))) | |
393 | |
394 (defun webjump-url-fix-trailing-slash (url) | |
395 (if (string-match "^[a-zA-Z]+://[^/]+$" url) | |
396 (concat url "/") | |
397 url)) | |
398 | |
399 ;;----------------------------------------------------------------------------- | |
400 | |
401 (provide 'webjump) | |
402 | |
403 ;; webjump.el ends here |