annotate lisp/webjump.el @ 16470:b050d980c422

(set-visited-file-name): Doc fix. (write-file): Use CONFIRM when calling set-visited-file-name.
author Richard M. Stallman <rms@gnu.org>
date Sat, 26 Oct 1996 18:12:01 +0000
parents ae72a4c02f31
children f74cdb2aa9cc
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 ("Brown University" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 [simple-query "www.brown.edu" "www.brown.edu/cgi-local/bsearch?" ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ("Computer Professionals for Social Responsibility" . "www.cpsr.org/dox/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ("Digital Espresso" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 [simple-query "www.io.org/~mentor/DigitalEspresso.html"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 "www.jars.com/cgi-bin/aglimpse/01?query="
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 "&case=on&whole=on&errors=0&maxfiles=100&maxlines=30"])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ("Dilbert" . "www.unitedmedia.com/comics/dilbert/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ("Electronic Frontier Foundation" . "www.eff.org")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ("Emacs Lisp Archive" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 "ftp://archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ("Free Software Foundation" . "www.fsf.org")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ("GNU FTP Archive". [mirrors
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 "ftp://prep.ai.mit.edu/pub/gnu/"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; ASIA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 "ftp://ftp.cs.titech.ac.jp"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 "ftp://tron.um.u-tokyo.ac.jp/pub/GNU/prep"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 "ftp://cair-archive.kaist.ac.kr/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 "ftp://ftp.nectec.or.th/pub/mirrors/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;; AUSTRALIA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 "ftp://archie.au/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 "ftp://archie.oz/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 "ftp://archie.oz.au/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;; AFRICA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 "ftp://ftp.sun.ac.za/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; MIDDLE-EAST:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 "ftp://ftp.technion.ac.il/pub/unsupported/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; EUROPE:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 "ftp://irisa.irisa.fr/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 "ftp://ftp.univ-lyon1.fr/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 "ftp://ftp.mcc.ac.uk"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 "ftp://unix.hensa.ac.uk/mirrors/uunet/systems/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 "ftp://src.doc.ic.ac.uk/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 "ftp://ftp.ieunet.ie/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 "ftp://ftp.eunet.ch"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 "ftp://nic.switch.ch/mirror/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 "ftp://ftp.informatik.rwth-aachen.de/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 "ftp://ftp.informatik.tu-muenchen.de"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 "ftp://ftp.win.tue.nl/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 "ftp://ftp.nl.net"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 "ftp://ftp.etsimo.uniovi.es/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 "ftp://ftp.funet.fi/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 "ftp://ftp.denet.dk"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 "ftp://ftp.stacken.kth.se"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 "ftp://isy.liu.se"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 "ftp://ftp.luth.se/pub/unix/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 "ftp://ftp.sunet.se/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 "ftp://archive.eu.net"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; SOUTH AMERICA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 "ftp://ftp.inf.utfsm.cl/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 "ftp://ftp.unicamp.br/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; WESTERN CANADA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 "ftp://ftp.cs.ubc.ca/mirror2/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; USA:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 "ftp://wuarchive.wustl.edu/systems/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "ftp://labrea.stanford.edu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 "ftp://ftp.digex.net/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 "ftp://ftp.kpc.com/pub/mirror/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 "ftp://f.ms.uky.edu/pub3/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 "ftp://jaguar.utah.edu/gnustuff"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 "ftp://ftp.hawaii.edu/mirrors/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 "ftp://uiarchive.cso.uiuc.edu/pub/gnu"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 "ftp://ftp.cs.columbia.edu/archives/gnu/prep"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 "ftp://gatekeeper.dec.com/pub/GNU"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 "ftp://ftp.uu.net/systems/gnu"
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 ("Insidious Big Brother Database" . "home.netscape.com/people/jwz/bbdb/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ("Interactive Weather Information Network" . webjump-to-iwin)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 ("Java API" . webjump-to-javaapi)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ("Lycos" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 [simple-query "www.lycos.com" "www.lycos.com/cgi-bin/pursuit?query=" ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ("Mailcrypt" . "cag-www.lcs.mit.edu/mailcrypt/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ("Pretty Good Privacy" . "web.mit.edu/network/pgp.html")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ("Playboy" . (if (webjump-adult-p) "www.playboy.com" "www.whitehouse.gov"))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ("Usenet FAQs" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 [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
168 "www.cis.ohio-state.edu/htbin/search-usenet-faqs/form?find="
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ("Risks Digest" . webjump-to-risks)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ("RTFM Usenet FAQs by Group" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 "ftp://rtfm.mit.edu/pub/usenet-by-group/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ("RTFM Usenet FAQs by Hierachy" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 "ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ("Webster" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 [simple-query "c.gp.cs.cmu.edu:5103/prog/webster"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 "gs213.sp.cs.cmu.edu/prog/webster?" ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 ("X Consortium Archive". "ftp.x.org")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ("Yahoo" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 [simple-query "www.yahoo.com" "search.yahoo.com/bin/search?p=" ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ("Yahoo Emacs" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 "www.yahoo.com/Computers_and_Internet/Software/Editors/Emacs/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ("Yahoo Reference" "www.yahoo.com/Reference/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 )
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 "Sample hotlist for WebJump.")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
15991
ae72a4c02f31 (webjump-sample-sites): Define with defvar.
Richard M. Stallman <rms@gnu.org>
parents: 15986
diff changeset
187 (defvar webjump-state-to-postal-alist
15986
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 '(("Alabama" . "al") ("Alaska" . "ak") ("Arizona" . "az") ("Arkansas" . "ar")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ("California" . "ca") ("Colorado" . "co") ("Connecticut" . "ct")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ("Delaware" . "de") ("Florida" . "fl") ("Georgia" . "ga") ("Hawaii" . "hi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 ("Idaho" . "id") ("Illinois" . "il") ("Indiana" . "in") ("Iowa" . "ia")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ("Kansas" . "ks") ("Kentucky" . "ky") ("Louisiana" . "la") ("Maine" . "me")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ("Maryland" . "md") ("Massachusetts" . "ma") ("Michigan" . "mi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 ("Minnesota" . "mn") ("Mississippi" . "ms") ("Missouri" . "mo")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 ("Montana" . "mt") ("Nebraska" . "ne") ("Nevada" . "nv")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ("New Hampshire" . "nh") ("New Jersey" . "nj") ("New Mexico" . "nm")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 ("New York" . "ny") ("North Carolina" . "nc") ("North Dakota" . "nd")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 ("Ohio" . "oh") ("Oklahoma" . "ok") ("Oregon" . "or")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 ("Pennsylvania" . "pa") ("Rhode Island" . "ri") ("South Carolina" . "sc")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ("South Dakota" . "sd") ("Tennessee" . "tn") ("Texas" . "tx")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 ("Utah" . "ut") ("Vermont" . "vt") ("Virginia" . "va")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 ("Washington" . "wa") ("West Virginia" . "wv") ("Wisconsin" . "wi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 ("Wyoming" . "wy")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 ;;------------------------------------------------------------ Option Variables
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (defvar webjump-sites
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 webjump-sample-sites
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 "*Hotlist for WebJump.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 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
212 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
213 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
214 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
215 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
216
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 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
218 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
219 arguments as the following elements. The three current builtins are `name',
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 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
221 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
222 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
223 content.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 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
226 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
227 suffix, respectively, to add to the encoded query the user enters. This
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 builtin covers Web sites that have single-string searches with the query
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 embedded in the URL.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 The arguments to the `mirrors' builtin are URLs of mirror sites.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 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
234 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
235 parameter. This might come in handy for various kludges.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 For convenience, if the `http://', `ftp://', or `file://' prefix is missing
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 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
239 submitting the URL.")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 ;;------------------------------------------------------- Sample Site Functions
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (defun webjump-to-iwin (name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (let ((prefix "http://iwin.nws.noaa.gov/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (state (webjump-read-choice name "state"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (append '(("Puerto Rico" . "pr"))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 webjump-state-to-postal-alist))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (if state
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (concat prefix "iwin/" state "/"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (webjump-read-choice name "option"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 '(("Hourly Report" . "hourly")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 ("State Forecast" . "state")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 ("Local Forecast" . "local")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 ("Zone Forecast" . "zone")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 ("Short-Term Forecast" . "shortterm")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 ("Weather Summary" . "summary")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 ("Public Information" . "public")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 ("Climatic Data" . "climate")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 ("Aviation Products" . "aviation")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 ("Hydro Products" . "hydro")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 ("Special Weather" . "special")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 ("Watches and Warnings" . "warnings"))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 "zone")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 ".html")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 prefix)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (defun webjump-to-javaapi (name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (let* ((prefix "http://www.javasoft.com/products/JDK/CurrentRelease/api/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (packages '(("java.applet") ("java.awt") ("java.awt.image")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ("java.awt.peer") ("java.io") ("java.lang") ("java.net")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 ("java.util") ("sun.tools.debug")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (completion-ignore-case t)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (package (completing-read (concat name " package: ") packages nil t)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (if (webjump-null-or-blank-string-p package)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (concat prefix "packages.html")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (concat prefix "Package-" package ".html"))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (defun webjump-to-risks (name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (let (issue volume)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (if (and (setq volume (webjump-read-number (concat name " volume")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (setq issue (webjump-read-number (concat name " issue"))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (format "catless.ncl.ac.uk/Risks/%d.%02d.html" volume issue)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 "catless.ncl.ac.uk/Risks/")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 ;;-------------------------------------------------------------- Core Functions
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 ;;;###autoload
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (defun webjump ()
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 "Jumps to a Web site from a programmable hotlist.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 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
292 hotlist.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 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
295 or submitted via `\\[webjump-submit-bug-report]'. The latest version can be
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 gotten from `http://www.cs.brown.edu/people/nwv/'."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (interactive)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (let* ((completion-ignore-case t)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (item (assoc (completing-read "WebJump to site: " webjump-sites nil t)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 webjump-sites))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (name (car item))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (expr (cdr item)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (funcall browse-url-browser-function
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (webjump-url-fix
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (cond ((not expr) "")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 ((stringp expr) expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 ((vectorp expr) (webjump-builtin expr name))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ((listp expr) (eval expr))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 ((symbolp expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (if (fboundp expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (funcall expr name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (error "WebJump URL function \"%s\" undefined." expr)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (t (error "WebJump URL expression for \"%s\" invalid."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 name)))))))
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-adult-p ()
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (and (boundp 'age) (integerp age) (>= age 21)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (defun webjump-builtin (expr name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (if (< (length expr) 1)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (error "WebJump URL builtin for \"%s\" empty." name))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (let ((builtin (aref expr 0)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (cond
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 ((eq builtin 'mirrors)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (if (= (length expr) 1)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (error
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 "WebJump URL builtin \"mirrors\" for \"%s\" needs at least 1 arg."))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (webjump-choose-mirror name (cdr (append expr nil))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 ((eq builtin 'name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 ((eq builtin 'simple-query)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (webjump-builtin-check-args expr name 3)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (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
334 (t (error "WebJump URL builtin \"%s\" for \"%s\" invalid."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 builtin name)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (defun webjump-builtin-check-args (expr name count)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (or (= (length expr) (1+ count))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (error "WebJump URL builtin \"%s\" for \"%s\" needs %d args."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (aref expr 0) name count)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (defun webjump-choose-mirror (name urls)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (webjump-read-url-choice (concat name " mirror")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 urls
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (webjump-mirror-default urls)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (defun webjump-do-simple-query (name noquery-url query-prefix query-suffix)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (let ((query (webjump-read-string (concat name " query"))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (if query
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (concat query-prefix (webjump-url-encode query) query-suffix)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 noquery-url)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (defun webjump-mirror-default (urls)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 ;; Note: This should be modified to apply some simple kludges/heuristics to
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 ;; 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
356 ;; judged equally desirable, randomness should be used.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (car urls))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (defun webjump-read-choice (name what choices &optional default)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (let* ((completion-ignore-case t)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (choice (completing-read (concat name " " what ": ") choices nil t)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (if (webjump-null-or-blank-string-p choice)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 default
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (cdr (assoc choice choices)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (defun webjump-read-number (prompt)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 ;; Note: I should make this more robust someday.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (let ((input (webjump-read-string prompt)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (if input (string-to-number input))))
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 (defun webjump-read-string (prompt)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (let ((input (read-string (concat prompt ": "))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (if (webjump-null-or-blank-string-p input) nil input)))
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 (defun webjump-read-url-choice (what urls &optional default)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 ;; Note: Convert this to use `webjump-read-choice' someday.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (let* ((completions (mapcar (function (lambda (n) (cons n n)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 urls))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (input (completing-read (concat what
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 ;;(if default " (RET for default)" "")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 ": ")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 completions
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 nil
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 t)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (if (webjump-null-or-blank-string-p input)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 default
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (car (assoc input completions)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (defun webjump-null-or-blank-string-p (str)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (or (null str) (string-match "^[ \t]*$" str)))
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 (defun webjump-url-encode (str)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (mapconcat '(lambda (c)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (cond ((= c 32) "+")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 ((or (and (>= c ?a) (<= c ?z))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (and (>= c ?A) (<= c ?Z))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (and (>= c ?0) (<= c ?9)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (char-to-string c))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (t (upcase (format "%%%02x" c)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 str
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 ""))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (defun webjump-url-fix (url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (if (webjump-null-or-blank-string-p url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ""
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (webjump-url-fix-trailing-slash
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (cond
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 ((string-match "^[a-zA-Z]+:" url) url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 ((string-match "^/" url) (concat "file://" url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 ((string-match "^\\([^\\./]+\\)" url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (concat (if (string= (downcase (match-string 1 url)) "ftp")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 "ftp"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 "http")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 "://"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (t url)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (defun webjump-url-fix-trailing-slash (url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (if (string-match "^[a-zA-Z]+://[^/]+$" url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (concat url "/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 ;;-----------------------------------------------------------------------------
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (provide 'webjump)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 ;; webjump.el ends here