annotate lisp/net/webjump.el @ 51545:75844077a68b

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