annotate lisp/webjump.el @ 21910:702383d93b75

(Info-up): New arg SAME-FILE: don't move to different file. (Info-next-preorder): Pass new arg to Info-up. (Info-last-preorder): Likewise. (Info-last-preorder): Don't follow the Prev if it's same as the Up. Instead, follow it as the Up.
author Richard M. Stallman <rms@gnu.org>
date Sun, 03 May 1998 00:02:10 +0000
parents f270e8ad8276
children 0049f95b12a7
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
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
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>
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
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; 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
13 ;; the Free Software Foundation; either version 2, or (at your option)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; 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
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; WebJump provides a sort of ``programmable hotlist'' of Web sites that can
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; 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
30 ;; 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
31 ;; 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
32 ;; a built-in or custom function, allowing interactive prompting for
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; site-specific queries and options.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; Note that WebJump was originally intended to complement your conventional
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; browser-based hotlist, not replace it. (Though there's no reason you
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; 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
38
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; The `webjump-sites' variable, which defines the hotlist, defaults to some
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; 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
41 ;; sites. The documentation for the variable describes the syntax.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; 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
44 ;;
18169
c18511c53797 (webjump-sample-sites): Change the hot list.
Richard M. Stallman <rms@gnu.org>
parents: 17973
diff changeset
45 ;; (require 'webjump)
15986
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; (global-set-key "\C-cj" 'webjump)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; (setq webjump-sites
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; (append '(
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; ("My Home Page" . "www.someisp.net/users/joebobjr/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; ("Pop's Site" . "www.joebob-and-son.com/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; )
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; webjump-sample-sites))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; 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
62 ;; browser-specific configuration should be done there.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;;; Code:
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;-------------------------------------------------------- Package Dependencies
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 (require 'browse-url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;;------------------------------------------------------------------- Constants
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 [simple-query
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 "www.altavista.digital.com"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 "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
140 "&r=&d0=&d1="])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ("Interactive Weather Information Network" . webjump-to-iwin)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ("Usenet FAQs" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 [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
154 "www.cis.ohio-state.edu/htbin/search-usenet-faqs/form?find="
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ""])
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ("RTFM Usenet FAQs by Group" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 "ftp://rtfm.mit.edu/pub/usenet-by-group/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ("RTFM Usenet FAQs by Hierachy" .
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 '(("Alabama" . "al") ("Alaska" . "ak") ("Arizona" . "az") ("Arkansas" . "ar")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ("California" . "ca") ("Colorado" . "co") ("Connecticut" . "ct")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ("Delaware" . "de") ("Florida" . "fl") ("Georgia" . "ga") ("Hawaii" . "hi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ("Idaho" . "id") ("Illinois" . "il") ("Indiana" . "in") ("Iowa" . "ia")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ("Kansas" . "ks") ("Kentucky" . "ky") ("Louisiana" . "la") ("Maine" . "me")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ("Maryland" . "md") ("Massachusetts" . "ma") ("Michigan" . "mi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ("Minnesota" . "mn") ("Mississippi" . "ms") ("Missouri" . "mo")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ("Montana" . "mt") ("Nebraska" . "ne") ("Nevada" . "nv")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ("New Hampshire" . "nh") ("New Jersey" . "nj") ("New Mexico" . "nm")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ("New York" . "ny") ("North Carolina" . "nc") ("North Dakota" . "nd")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ("Ohio" . "oh") ("Oklahoma" . "ok") ("Oregon" . "or")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ("Pennsylvania" . "pa") ("Rhode Island" . "ri") ("South Carolina" . "sc")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ("South Dakota" . "sd") ("Tennessee" . "tn") ("Texas" . "tx")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 ("Utah" . "ut") ("Vermont" . "vt") ("Virginia" . "va")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ("Washington" . "wa") ("West Virginia" . "wv") ("Wisconsin" . "wi")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ("Wyoming" . "wy")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 ;;------------------------------------------------------------ Option Variables
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (defvar webjump-sites
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 webjump-sample-sites
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 "*Hotlist for WebJump.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 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
202 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
203 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
204 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
205 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
206
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 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
208 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
209 arguments as the following elements. The three current builtins are `name',
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 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
211 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
212 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
213 content.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 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
216 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
217 suffix, respectively, to add to the encoded query the user enters. This
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 builtin covers Web sites that have single-string searches with the query
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 embedded in the URL.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 The arguments to the `mirrors' builtin are URLs of mirror sites.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 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
224 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
225 parameter. This might come in handy for various kludges.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 For convenience, if the `http://', `ftp://', or `file://' prefix is missing
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 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
229 submitting 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 ;;------------------------------------------------------- Sample Site Functions
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 (defun webjump-to-iwin (name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (let ((prefix "http://iwin.nws.noaa.gov/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (state (webjump-read-choice name "state"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (append '(("Puerto Rico" . "pr"))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 webjump-state-to-postal-alist))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (if state
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (concat prefix "iwin/" state "/"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (webjump-read-choice name "option"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 '(("Hourly Report" . "hourly")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ("State Forecast" . "state")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 ("Local Forecast" . "local")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 ("Zone Forecast" . "zone")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ("Short-Term Forecast" . "shortterm")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 ("Weather Summary" . "summary")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 ("Public Information" . "public")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 ("Climatic Data" . "climate")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 ("Aviation Products" . "aviation")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 ("Hydro Products" . "hydro")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 ("Special Weather" . "special")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 ("Watches and Warnings" . "warnings"))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 "zone")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 ".html")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 prefix)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (defun webjump-to-risks (name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (let (issue volume)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (if (and (setq volume (webjump-read-number (concat name " volume")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (setq issue (webjump-read-number (concat name " issue"))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (format "catless.ncl.ac.uk/Risks/%d.%02d.html" volume issue)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 "catless.ncl.ac.uk/Risks/")))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 ;;-------------------------------------------------------------- Core Functions
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 ;;;###autoload
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (defun webjump ()
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 "Jumps to a Web site from a programmable hotlist.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 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
271 hotlist.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (interactive)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (name (car item))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (expr (cdr item)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (funcall browse-url-browser-function
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (webjump-url-fix
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (cond ((not expr) "")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 ((stringp expr) expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 ((vectorp expr) (webjump-builtin expr name))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 ((listp expr) (eval expr))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 ((symbolp expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (if (fboundp expr)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (funcall expr name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (error "WebJump URL function \"%s\" undefined." expr)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (t (error "WebJump URL expression for \"%s\" invalid."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 name)))))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (defun webjump-builtin (expr name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (if (< (length expr) 1)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (error "WebJump URL builtin for \"%s\" empty." name))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (let ((builtin (aref expr 0)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (cond
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 ((eq builtin 'mirrors)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (if (= (length expr) 1)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (error
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 "WebJump URL builtin \"mirrors\" for \"%s\" needs at least 1 arg."))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (webjump-choose-mirror name (cdr (append expr nil))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 ((eq builtin 'name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 name)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 ((eq builtin 'simple-query)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (webjump-builtin-check-args expr name 3)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (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
310 (t (error "WebJump URL builtin \"%s\" for \"%s\" invalid."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 builtin name)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (defun webjump-builtin-check-args (expr name count)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (or (= (length expr) (1+ count))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (error "WebJump URL builtin \"%s\" for \"%s\" needs %d args."
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (aref expr 0) name count)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (defun webjump-choose-mirror (name urls)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (webjump-read-url-choice (concat name " mirror")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 urls
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (webjump-mirror-default urls)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (defun webjump-do-simple-query (name noquery-url query-prefix query-suffix)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (let ((query (webjump-read-string (concat name " query"))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (if query
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (concat query-prefix (webjump-url-encode query) query-suffix)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 noquery-url)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (defun webjump-mirror-default (urls)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 ;; Note: This should be modified to apply some simple kludges/heuristics to
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (car urls))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (defun webjump-read-choice (name what choices &optional default)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (let* ((completion-ignore-case t)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (choice (completing-read (concat name " " what ": ") choices nil t)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (if (webjump-null-or-blank-string-p choice)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 default
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (cdr (assoc choice choices)))))
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-read-number (prompt)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 ;; Note: I should make this more robust someday.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (let ((input (webjump-read-string prompt)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (if input (string-to-number input))))
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-read-string (prompt)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (let ((input (read-string (concat prompt ": "))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (if (webjump-null-or-blank-string-p input) nil input)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (defun webjump-read-url-choice (what urls &optional default)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 ;; Note: Convert this to use `webjump-read-choice' someday.
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (let* ((completions (mapcar (function (lambda (n) (cons n n)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 urls))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (input (completing-read (concat what
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 ;;(if default " (RET for default)" "")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 ": ")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 completions
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 nil
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 t)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (if (webjump-null-or-blank-string-p input)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 default
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (car (assoc input completions)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (defun webjump-null-or-blank-string-p (str)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (or (null str) (string-match "^[ \t]*$" str)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (defun webjump-url-encode (str)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (mapconcat '(lambda (c)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (cond ((= c 32) "+")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 ((or (and (>= c ?a) (<= c ?z))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (and (>= c ?A) (<= c ?Z))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (and (>= c ?0) (<= c ?9)))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (char-to-string c))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (t (upcase (format "%%%02x" c)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 str
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 ""))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (defun webjump-url-fix (url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (if (webjump-null-or-blank-string-p url)
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 (webjump-url-fix-trailing-slash
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (cond
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 ((string-match "^[a-zA-Z]+:" url) url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 ((string-match "^/" url) (concat "file://" url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 ((string-match "^\\([^\\./]+\\)" url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (concat (if (string= (downcase (match-string 1 url)) "ftp")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 "ftp"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 "http")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 "://"
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (t url)))))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (defun webjump-url-fix-trailing-slash (url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (if (string-match "^[a-zA-Z]+://[^/]+$" url)
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (concat url "/")
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 url))
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 ;;-----------------------------------------------------------------------------
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
f94decd9a48a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (provide 'webjump)
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 ;; webjump.el ends here