annotate lisp/w3/w3.el @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents 859a2309aef8
children 441bb1e64a06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; w3.el --- Main functions for emacs-w3 on all platforms/versions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
3 ;; Created: 1997/02/13 23:05:56
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
4 ;; Version: 1.77
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: faces, help, comm, news, mail, processes, mouse, hypermedia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry (wmperry@cs.indiana.edu)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
11 ;;; This file is part of GNU Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; This is a major mode for browsing documents written in Hypertext Markup ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Language (HTML). These documents are typicallly part of the World Wide ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Web (WWW), a project to create a global information net in hypertext ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; format. ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; first start by making sure the load path is properly set. This code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; is mostly taken from calc-2.02b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; this allows you to put the following in your .emacs file, instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; having to know what the load-path for the w3 files is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; (autoload 'w3 "w3/w3" "WWW Browser" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; If w3 files exist on the load-path, we're all set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (let ((name (and (fboundp 'w3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (eq (car-safe (symbol-function 'w3)) 'autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (nth 1 (symbol-function 'w3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (p load-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (while (and p (not (file-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (expand-file-name "w3-vars.elc" (car p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (or p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; If w3 is autoloaded using a path name, look there for w3 files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; This works for both relative ("w3/w3.elc") and absolute paths.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (and name (file-name-directory name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (let ((p2 load-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (name2 (concat (file-name-directory name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 "w3-vars.elc")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (while (and p2 (not (file-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (expand-file-name name2 (car p2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (setq p2 (cdr p2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (if p2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (setq load-path (nconc load-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (directory-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 name (car p2)))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
72 (require 'w3-sysdp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
73 (require 'mule-sysdp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
74
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (or (featurep 'efs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (featurep 'efs-auto)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (require 'ange-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (require 'cl)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
82 (require 'css)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (require 'w3-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (eval-and-compile
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
85 (require 'w3-display))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; Code for printing out roman numerals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defun w3-decimal-to-roman (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; Convert from decimal to roman numerals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (let ((curmod 1000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (str "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (j 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 i2 k curcnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (while (>= curmod 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (if (>= n curmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (setq curcnt (/ n curmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 n (- n (* curcnt curmod)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (if (= 4 (% curcnt 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (setq i2 (+ j (if (> curcnt 5) 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 str (format "%s%c%c" str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (aref w3-roman-characters (1- j))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (aref w3-roman-characters i2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (>= curcnt 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (setq str (format "%s%c" str (aref w3-roman-characters j))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 curcnt (- curcnt 5)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq k 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (while (< k curcnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq str (format "%s%c" str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (aref w3-roman-characters (1- j)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 k (1+ k)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (setq curmod (/ curmod 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 j (- j 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defun w3-decimal-to-alpha (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; Convert from decimal to alphabetical (a, b, c, ..., aa, ab,...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ((< n 1) (char-to-string ?Z))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ((<= n 26) (char-to-string (+ ?A (1- n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (t (concat (char-to-string (+ ?A (1- (/ n 27))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (w3-decimal-to-alpha (% n 26))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;; Functions to pass files off to external viewers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defun w3-start-viewer (fname cmd &optional view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 "Start a subprocess, named FNAME, executing CMD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 If third arg VIEW is non-nil, show the output in a buffer when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 the subprocess exits."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (if view (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (set-buffer (get-buffer-create view))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (let ((proc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (start-process fname view (or shell-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (getenv "ESHELL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (getenv "SHELL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "/bin/sh") "-c" cmd)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defun w3-viewer-filter (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; A process filter for asynchronous external viewers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (let ((buff (get-buffer-create (url-generate-new-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (symbol-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (read (nth 2 (process-command proc))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (set-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (set-process-buffer proc buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (set-process-filter proc nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (defun w3-viewer-sentinel (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; Delete any temp files left from a viewer process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (let ((fname (process-name proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (buffr (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (status (process-exit-status proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (if buffr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (w3-notify-when-ready buffr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (and (/= 0 status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (funcall url-confirmation-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (format "Viewer for %s failed... save to disk? " fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (copy-file fname (read-file-name "Save as: ") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (if (and (file-exists-p fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (file-writable-p fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (delete-file fname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defun w3-notify-when-ready (buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Notify the user when BUFF is ready.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 See the variable `w3-notify' for the different notification behaviors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (if (stringp buff) (setq buff (get-buffer buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ((null buff) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ((eq w3-notify 'newframe)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; Since we run asynchronously, perhaps while Emacs is waiting for input,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; we must not leave a different buffer current.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; We can't rely on the editor command loop to reselect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; the selected window's buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (set-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (make-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ((eq w3-notify 'bully)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (pop-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (delete-other-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ((eq w3-notify 'semibully)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (switch-to-buffer buff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ((eq w3-notify 'aggressive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (pop-to-buffer buff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ((eq w3-notify 'friendly)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (display-buffer buff 'not-this-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ((eq w3-notify 'polite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (message "W3 buffer %s is ready." (buffer-name buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ((eq w3-notify 'quiet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (message "W3 buffer %s is ready." (buffer-name buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (t (message ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (defun w3-pass-to-viewer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; Pass a w3 buffer to a viewer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (let* ((info url-current-mime-viewer) ; All the MIME viewer info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (view (cdr-safe (assoc "viewer" info))) ; How to view this file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (url (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (fmt (cdr-safe (assoc "nametemplate" info)))) ; Template for name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (fmt nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ((cdr-safe (assoc "type" info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (setq fmt (mm-type-to-file (cdr-safe (assoc "type" info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (if fmt (setq fmt (concat "%s" (car fmt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (setq fmt (concat "%s" (url-file-extension url-current-file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (if (null view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (setq view 'indented-text-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ((symbolp view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (if (not (memq view '(w3-prepare-buffer w3-print w3-source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 w3-default-local-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 mm-multipart-viewer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (let ((bufnam (url-generate-new-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (file-name-nondirectory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (or url-current-file "Unknown")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if (string= bufnam "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (setq bufnam (url-generate-new-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (url-view-url t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (rename-buffer bufnam)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; Make the URL show in list-buffers output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (make-local-variable 'list-buffers-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (setq list-buffers-directory (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (buffer-enable-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (funcall view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (w3-notify-when-ready bufnam))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (funcall view)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ((stringp view)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
239 (let ((fname (url-generate-unique-filename fmt))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
240 (proc nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (if (url-file-directly-accessible-p (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (make-symbolic-link url-current-file fname t)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
243 (mule-write-region-no-coding-system (point-min) (point-max) fname))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (get-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (kill-buffer url-working-buffer))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
246 (setq view (mm-viewer-unescape view fname url))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (message "Passing to viewer %s " view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (setq proc (w3-start-viewer fname view))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (set-process-filter proc 'w3-viewer-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (set-process-sentinel proc 'w3-viewer-sentinel)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ((listp view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (buffer-enable-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (eval view))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (message "Unknown viewer specified: %s" view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (w3-notify-when-ready url-working-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (defun w3-save-binary-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 "Save a buffer to disk - this is used when `w3-dump-to-disk' is non-nil"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
261 ;; Ok, this is truly fucked. In XEmacs, if you use the mouse to select
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
262 ;; a URL that gets saved via this function, read-file-name will pop up a
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
263 ;; dialog box for file selection. For some reason which buffer we are in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
264 ;; gets royally screwed (even with save-excursions and the whole nine
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
265 ;; yards). SO, we just keep the old buffer name around and away we go.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
266 (let ((old-buff (current-buffer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
267 (file (read-file-name "Filename to save as: "
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
268 (or mm-download-directory "~/")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
269 (url-remove-compressed-extensions
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
270 (file-name-nondirectory (url-view-url t)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
271 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
272 (url-remove-compressed-extensions
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
273 (file-name-nondirectory (url-view-url t)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
274 (require-final-newline nil))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
275 (set-buffer old-buff)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
276 (mule-write-region-no-coding-system (point-min) (point-max) file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
277 (kill-buffer (current-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defun w3-build-url (protocol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "Build a url for PROTOCOL, return it as a string"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (interactive (list (cdr (assoc (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "Protocol: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 w3-acceptable-protocols-alist nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 w3-acceptable-protocols-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (let (user host port file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ((null protocol) (error "Protocol is unknown to me!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ((string= protocol "news")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (setq host (read-string "Enter news server name, or blank for default: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 port (read-string "Enter port number, or blank for default: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 file (read-string "Newgroup name or Message-ID: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ((string= protocol "mailto") (setq file (read-string "E-mail address: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ((string= protocol "http")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (setq host (read-string "Enter server name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 port (read-string "Enter port number, or blank for default: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 file (read-string "Remote file: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (and (string= "" port) (setq port nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (and (string= "" host) (error "Must specify a remote machine!")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ((string= protocol "file")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (if (funcall url-confirmation-func "Local file?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (setq file (read-file-name "Local File: " nil nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (setq user (read-string "Login as user (blank=anonymous): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 host (read-string "Remote machine name: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (and (string= user "") (setq user "anonymous"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (and (string= host "") (error "Must specify a remote machine!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (setq file (read-file-name "File: " (format "/%s@%s:" user host)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 file (substring file (length (format "/%s@%s:" user host))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ((or (string= protocol "telnet")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (string= protocol "tn3270"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (setq user (read-string "Login as user (blank=none): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 host (read-string "Remote machine name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 port (read-string "Port number (blank=23): "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (and (string= "" port) (setq port nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (and (string= "" user) (setq user nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (and (string= "" host) (error "Must specify a host machine!")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ((string= protocol "gopher")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (setq host (read-string "Enter server name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 port (read-string "Enter port number, or blank for default: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 file (read-string "Remote file: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (and (string= "" port) (setq port nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (and (string= "" host) (error "Must specify a remote machine!"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (message "%s:%s%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (if (null host) "" (concat "//" host
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (if (null port) "" (concat ":" port))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (if (= ?/ (string-to-char file)) file (concat "/" file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defun w3-open-local (fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 "Find a local file, and interpret it as a hypertext document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 It will prompt for an existing file or directory, and retrieve it as a
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
333 hypertext document."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (interactive "FLocal file: ")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
335 (setq fname (expand-file-name fname))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if (not w3-setup-done) (w3-do-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (w3-fetch (concat "file:" fname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (defun w3-find-file (fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 "Find a local file, and interpret it as a hypertext document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 It will prompt for an existing file or directory, and retrieve it as a
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
343 hypertext document."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (interactive "FLocal file: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (w3-open-local fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (defun w3-fetch-other-frame (&optional url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 "Attempt to follow the hypertext reference under point in a new frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 With prefix-arg P, ignore viewers and dump the link straight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 to disk."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (interactive (list (w3-read-url-with-default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ((and (fboundp 'make-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (fboundp 'select-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (not (eq (device-type) 'tty)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (let ((frm (make-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (select-frame frm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (w3-fetch url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (t (w3-fetch url))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defun w3-fetch-other-window (&optional url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Attempt to follow the hypertext reference under point in a new window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 With prefix-arg P, ignore viewers and dump the link straight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 to disk."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (interactive (list (w3-read-url-with-default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (split-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (w3-fetch url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
371 ;; Ripped off from red gnus
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
372 (defun w3-find-etc-directory (package &optional file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
373 "Go through the path and find the \".../etc/PACKAGE\" directory.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
374 If FILE, find the \".../etc/PACKAGE\" file instead."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
375 (let ((path load-path)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
376 dir result)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
377 ;; We try to find the dir by looking at the load path,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
378 ;; stripping away the last component and adding "etc/".
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
379 (while path
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
380 (if (and (car path)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
381 (file-exists-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
382 (setq dir (concat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
383 (file-name-directory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
384 (directory-file-name (car path)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
385 "etc/" package
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
386 (if file "" "/"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
387 (or file (file-directory-p dir)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
388 (setq result dir
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
389 path nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
390 (setq path (cdr path))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
391 result))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
392
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defun w3-url-completion-function (string predicate function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (if (not w3-setup-done) (w3-do-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (cond
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
396 ((eq function nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
397 (let ((list nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
398 (cl-maphash (function (lambda (key val)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
399 (setq list (cons (cons key val)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
400 list))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
401 url-global-history-hash-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
402 (try-completion string (nreverse list) predicate)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ((eq function t)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
404 (let ((stub (concat "^" (regexp-quote string)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
405 (retval nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
406 (cl-maphash
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
407 (function
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
408 (lambda (url time)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
409 (if (string-match stub url)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
410 (setq retval (cons url retval)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
411 url-global-history-hash-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
412 retval))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ((eq function 'lambda)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
414 (and url-global-history-hash-table
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
415 (cl-gethash string url-global-history-hash-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
416 t))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
417 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
418 (error "w3-url-completion-function very confused."))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (defun w3-read-url-with-default ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (url-do-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (let* ((completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (default
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
424 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
425 ((null w3-fetch-with-default) nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
426 ((eq major-mode 'w3-mode)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
427 (or (and current-prefix-arg (w3-view-this-url t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
428 (url-view-url t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
429 ((url-get-url-at-point)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
430 (url-get-url-at-point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
431 (t "http://www.")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (url nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (setq url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (completing-read "URL: " 'w3-url-completion-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 nil nil default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (if (string= url "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (setq url (if (eq major-mode 'w3-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (if (and current-prefix-arg (w3-view-this-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (w3-view-this-url t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (url-get-url-at-point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (defun w3-fetch (&optional url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 "Retrieve a document over the World Wide Web.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
447 Defaults to URL of the current document, if any.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
448 With prefix argument, use the URL of the hyperlink under point instead."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (interactive (list (w3-read-url-with-default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (if (not w3-setup-done) (w3-do-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (if (boundp 'w3-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (setq w3-working-buffer url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if (and (boundp 'command-line-args-left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 command-line-args-left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (string-match url-nonrelative-link (car command-line-args-left)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (setq url (car command-line-args-left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 command-line-args-left (cdr command-line-args-left)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (equal url "") (error "No document specified!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;; legal use for relative URLs ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (if (string-match "^www:[^/].*" url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (setq url (concat (file-name-directory url-current-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (substring url 4))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ;; In the common case, this is probably cheaper than searching.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (while (= (string-to-char url) ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (setq url (substring url 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ((= (string-to-char url) ?#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (w3-relative-link url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ((or (and (interactive-p) current-prefix-arg) w3-dump-to-disk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (w3-download-url url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (let ((x (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (lastbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (buf (url-buffer-visiting url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (and x (or (string= "file:nil" x) (string= "" x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (setq x nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (if (or (not buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ((not (equal (downcase (or url-request-method "GET")) "get")) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ((memq w3-reuse-buffers '(no never reload)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ((memq w3-reuse-buffers '(yes reuse always)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (if (and w3-reuse-buffers (not (eq w3-reuse-buffers 'ask)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 "Warning: Invalid value for variable w3-reuse-buffers: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (prin1-to-string w3-reuse-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (sit-for 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (not (funcall url-confirmation-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (format "Reuse URL in buffer %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (buffer-name buf)))))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
493 (let* ((status (url-retrieve url))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
494 (cached (car status))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
495 (url-working-buffer (cdr status)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (if w3-track-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (setq w3-last-buffer (get-buffer url-working-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (if (get-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (cond
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
500 ((and url-be-asynchronous
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (not cached))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (if x
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
505 (w3-history-push x (url-view-url t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq w3-current-last-buffer lastbuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (t
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
508 (w3-history-push x url)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
509 (w3-sentinel lastbuf)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
510 (if (string-match "#\\(.*\\)" url)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
511 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
512 (push-mark (point) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
513 (w3-find-specific-link (match-string 1 url))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (if w3-track-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (setq w3-last-buffer buf))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
516 (let ((w3-notify (if (memq w3-notify '(newframe bully
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
517 semibully aggressive))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 w3-notify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 'aggressive)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (w3-notify-when-ready buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (if (string-match "#\\(.*\\)" url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (push-mark (point) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (w3-find-specific-link (url-match url 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (message "Reusing URL. To reload, type %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (substitute-command-keys "\\[w3-reload-document]")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;;; History for forward/back buttons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
532 (defvar w3-history-stack nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
533 "History stack viewing history.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
534 This is an assoc list, with the oldest items first.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
535 Each element is a cons cell of (url . timeobj), where URL
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
536 is the normalized URL (default ports removed, etc), and TIMEOBJ is
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
537 a standard Emacs time. See the `current-time' function documentation
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
538 for information on this format.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
540 (defun w3-history-find-url-internal (url)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
541 "Search in the history list for URL.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
542 Returns a cons cell, where the car is the 'back' node, and
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
543 the cdr is the 'next' node."
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
544 (let* ((node (assoc url w3-history-stack))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
545 (next (cadr (memq node w3-history-stack)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
546 (last nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
547 (temp nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
548 (todo w3-history-stack))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
549 ;; Last node is a little harder to find without using back links
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
550 (while (and (not last) todo)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
551 (if (string= (caar todo) url)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
552 (setq last (or temp 'none))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
553 (setq temp (pop todo))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
554 (cons (if (not (symbolp last)) last)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
555 next)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
557 (defun w3-history-forward ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 "Go forward in the history from this page"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (interactive)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
560 (let ((next (cadr (w3-history-find-url-internal (url-view-url t))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
561 (w3-reuse-buffers 'yes))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
562 (if next
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
563 (w3-fetch next))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
565 (defun w3-history-backward ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 "Go backward in the history from this page"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (interactive)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
568 (let ((last (caar (w3-history-find-url-internal (url-view-url t))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
569 (w3-reuse-buffers 'yes))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
570 (if last
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
571 (w3-fetch last))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
573 (defun w3-history-push (referer url)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 "REFERER is the url we followed this link from. URL is the link we got to."
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
575 (if (not referer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
576 (setq w3-history-stack (list (cons url (current-time))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
577 (let ((node (memq (assoc referer w3-history-stack) w3-history-stack)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
578 (if node
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
579 (setcdr node (list (cons url (current-time))))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
580
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
581 (defalias 'w3-add-urls-to-history 'w3-history-push)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
582 (defalias 'w3-backward-in-history 'w3-history-backward)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
583 (defalias 'w3-forward-in-history 'w3-history-forward)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;;; Miscellaneous functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (defun w3-describe-entities ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 "Show an DTD fragment listing all the entities currently defined."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (switch-to-buffer (get-buffer-create "W3 Entities"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (let ((buffer-file-name (concat (make-temp-name "entities") ".dtd")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (set-auto-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (let (entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (mapatoms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (setq entity (get x 'html-entity-expansion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (if entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (insert (format "<!entity %s %s \"%s\">\n" x (car entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (cdr entity))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (defun w3-executable-exists-in-path (exec &optional path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (let ((paths (if (consp path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (mm-string-to-tokens (or path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (getenv "PATH")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 "/usr/bin:/bin:/usr/local/bin:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 "/usr/bin/X11:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (expand-file-name "~/bin"))) ?:)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (while (and paths (not done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (if (file-exists-p (expand-file-name exec (car paths)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (setq done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (setq paths (cdr paths)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (defun w3-document-information (&optional buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 "Display information on the document in buffer BUFF"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (let ((w3-notify 'friendly))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (if (get-buffer "Document Information")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (kill-buffer (get-buffer "Document Information")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (w3-fetch "about:document"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (setq buff (or buff (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (set-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (let* ((url (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (cur-links w3-current-links)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (title (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (lastmod (or (cdr-safe (assoc "last-modified"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 url-current-mime-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (and (member url-current-type '("file" "ftp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (nth 5 (url-file-attributes url)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
640 (hdrs url-current-mime-headers)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
641 (info w3-current-metainfo))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (setq url-current-can-be-cached nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 url-current-type "about"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 url-current-file "document")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ((stringp lastmod) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ((equal '(0 . 0) lastmod) (setq lastmod nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ((consp lastmod) (setq lastmod (current-time-string lastmod)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (t (setq lastmod nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (insert "<html>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 " <head>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 " <title>Document Information</title>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 " </head>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 " <body\n"
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
657 " <table border>\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
658 " <tr><th colspan=2>Document Information</th></tr>\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
659 " <tr><td>Title:</td><td>" title "</td></tr>\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
660 " <tr><td>Location:</td><td>" url "</td></tr>\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
661 " <tr><td>Last Modified:</td><td>" (or lastmod "None Given")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
662 "</td></tr>\n")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (if hdrs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (let* ((maxlength (car (sort (mapcar (function (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (length (car x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 hdrs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 '>)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
668 (fmtstring (format " <tr><td align=right>%%%ds:</td><td>%%s</td></tr>" maxlength)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
669 (insert " <tr><th>MetaInformation</th></tr>\n"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (if (/= (length (car x)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (format fmtstring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (capitalize (car x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (if (numberp (cdr x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (int-to-string (cdr x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (cdr x))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (sort hdrs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (lambda (x y) (string-lessp (car x) (car y)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
682 "\n"))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
683
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
684 ;; FIXME!!! Need to reimplement showing rel/rev links for the new
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
685 ;; storage format.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
686
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
687 (if info
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
688 (let* ((maxlength (car (sort (mapcar (function (lambda (x)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
689 (length (car x))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
690 info)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
691 '>)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
692 (fmtstring (format " <tr><td>%%%ds:</td><td>%%s</td></tr>" maxlength)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
693 (insert " <tr><th>Miscellaneous Variables</th></tr>\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
694 (while info
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
695 (insert (format fmtstring (capitalize (caar info))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
696 (cdar info)) "\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
697 (setq info (cdr info))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
698 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
699 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
700 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
701 (insert " </table>\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
702 " </body>\n"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 "</html>\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (defun w3-truncate-menu-item (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (if (<= (length string) w3-max-menu-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (concat (substring string 0 w3-max-menu-width) "$")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (defun w3-insert-formatted-url (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 "Insert a formatted url into a buffer. With prefix arg, insert the url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 under point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (let (buff str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (setq p (widget-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (or p (error "No url under point"))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
719 (setq str (format "<a href=\"%s\">%s</a>" (widget-get p 'href)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (read-string "Link text: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (buffer-substring
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
722 (widget-get p :from)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
723 (widget-get p :to))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (t
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
725 (setq str (format "<a href=\"%s\">%s</a>" (url-view-url t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (read-string "Link text: " (buffer-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (setq buff (read-buffer "Insert into buffer: " nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (if buff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (set-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (insert str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (message "Cancelled."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (defun w3-first-n-items (l n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 "Return the first N items from list L"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (let ((x 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (if (> n (length l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (setq y l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (while (< x n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (setq y (nconc y (list (nth x l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 x (1+ x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (defun w3-widget-button-press ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (if (widget-at (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (widget-button-press (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (defun w3-widget-button-click (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (interactive "@e")
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
752 (cond
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
753 ((and (event-point e)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
754 (widget-at (event-point e)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
755 (widget-button-click e))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
756 ((and (fboundp 'event-glyph)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
757 (event-glyph e)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
758 (glyph-property (event-glyph e) 'widget))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
759 (widget-button-click e))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (defun w3-breakup-menu (menu-desc max-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (if (> (length menu-desc) max-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (cons (cons "More..." (w3-first-n-items menu-desc max-len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (w3-breakup-menu (nthcdr max-len menu-desc) max-len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 menu-desc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (defun w3-maybe-follow-link-mouse (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 "Maybe follow a hypertext link under point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 If there is no link under point, this will try using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 url-get-url-at-point"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (mouse-set-point e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (w3-maybe-follow-link)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (defun w3-maybe-follow-link ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 "Maybe follow a hypertext link under point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 If there is no link under point, this will try using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 url-get-url-at-point"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (require 'w3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (if (not w3-setup-done) (w3-do-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (let* ((widget (widget-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (url1 (and widget (widget-get widget 'href)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (url2 (url-get-url-at-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (url1 (w3-follow-link))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 ((and url2 (string-match url-nonrelative-link url2)) (w3-fetch url2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (t (message "No URL could be found!")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defun w3-follow-url-at-point-other-frame (&optional pt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 "Follow the URL under PT, defaults to link under (point)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (interactive "d")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (let ((url (url-get-url-at-point pt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (and url (w3-fetch-other-frame url))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (defun w3-follow-url-at-point (&optional pt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 "Follow the URL under PT, defaults to link under (point)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (interactive "d")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (let ((url (url-get-url-at-point pt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (and url (w3-fetch url))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (defun w3-batch-fetch ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 "Fetch all the URLs on the command line and save them to files in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 the current directory. The first argument after the -f w3-batch-fetch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 on the command line should be a string specifying how to save the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 information retrieved. If it is \"html\", then the page will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 unformatted when it is written to disk. If it is \"text\", then the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 page will be formatted before it is written to disk. If it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 \"binary\" it will not mess with the file extensions, and just save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 the data in raw binary format. If none of those, the default is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 \"text\", and the first argument is treated as a normal URL."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (if (not w3-setup-done) (w3-do-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (if (not noninteractive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (error "`w3-batch-fetch' is to be used only with -batch"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (let ((fname "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (curname "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (x 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (args command-line-args-left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (w3-strict-width 80)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (retrieval-function 'w3-fetch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (file-format "text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (header "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (file-extn ".txt"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (setq file-format (downcase (car args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ((string= file-format "html")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (message "Saving all text as raw HTML...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (setq retrieval-function 'url-retrieve
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 file-extn ".html"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 header "<BASE HREF=\"%s\">"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 args (cdr args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ((string= file-format "binary")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (message "Saving as raw binary...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (setq retrieval-function 'url-retrieve
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 file-extn ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 args (cdr args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ((string= file-format "text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (setq header "Text from: %s\n---------------\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (message "Saving all text as formatted...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (setq args (cdr args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (setq header "Text from: %s\n---------------\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (message "Going with default, saving all text as formatted...")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (funcall retrieval-function (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (if buffer-read-only (toggle-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (insert (format header (car args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (setq fname (url-basepath url-current-file t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (if (string= file-extn "") nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (setq fname (url-file-extension fname t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (if (string= (url-strip-leading-spaces fname) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (setq fname "root"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (setq curname fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (while (file-exists-p (concat curname file-extn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (setq curname (concat fname x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 x (1+ x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (setq fname (concat curname file-extn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (write-region (point-min) (point-max) fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (setq args (cdr args)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (defun w3-fix-spaces (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 "Remove spaces/tabs at the beginning of a string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 and convert newlines into spaces."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (url-convert-newlines-to-spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (url-strip-leading-spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (url-eat-trailing-space x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (defun w3-reload-all-files ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 "Reload all w3 files"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (setq w3-setup-done nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 url-setup-done nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 w3-hotlist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 url-mime-accept-string nil)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
882 (let ((x '(w3 mule-sysdp w3-e19 mm url w3-xemac w3-toolbar font)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (while x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (setq features (delq (car x) features)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 x (cdr x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (require 'w3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (w3-do-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (url-do-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (defun w3-source-document-at-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 "View source to the document pointed at by link under point"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (w3-source-document t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (defun w3-my-safe-copy-face (old new locale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (let ((fore (face-foreground old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (back (face-background old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (bpxm (face-background-pixmap old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (font (face-font old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (font-spec (get old 'font-specification)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (if (color-specifier-p fore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (setq fore (color-name fore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (if (color-specifier-p back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (setq back (color-name back)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (if (font-specifier-p font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (setq font (font-name font)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (and fore (set-face-foreground new fore locale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (and back (set-face-background new back locale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (and bpxm (set-face-background-pixmap new bpxm locale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (and (or font-spec font) (set-face-font new (or font-spec font) locale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (defun w3-source-document (under)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 "View this document's source"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (let* ((url (if under (w3-view-this-url) (url-view-url t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (fil (if under nil url-current-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (src
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (cond
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
921 ((null url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
922 (error "No URL found!"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ((and under (null url)) (error "No link at point!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ((and (not under) (equal url-current-mime-type "text/plain"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ((and (not under) w3-current-source) w3-current-source)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (prog2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (url-retrieve url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (buffer-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (setq fil (or fil url-current-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (tmp (url-generate-new-buffer-name url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (if (and url (get-buffer url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ((memq w3-reuse-buffers '(no never reload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (kill-buffer url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 ((memq w3-reuse-buffers '(yes reuse always))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (w3-notify-when-ready (get-buffer url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (setq url nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ((funcall url-confirmation-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (concat "Source for " url " found, reuse? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (w3-notify-when-ready (get-buffer url)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (if (not url) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (set-buffer (get-buffer-create tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (insert src)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (put-text-property (point-min) (point-max) 'w3-base url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
949 (setq buffer-file-truename url
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
950 buffer-file-name url)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
951 ;; Null filename bugs `set-auto-mode' in Mule ...
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
952 (condition-case ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
953 (set-auto-mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
954 (error nil))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
955 (setq buffer-file-truename nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
956 buffer-file-name nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (buffer-enable-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (w3-notify-when-ready (get-buffer tmp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (run-hooks 'w3-source-file-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (defun w3-mail-document-under-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 "Mail the document pointed to by the hyperlink under point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (w3-mail-current-document t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (defun w3-mail-current-document (under &optional format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 "Mail the current-document to someone"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (let* ((completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (format (or format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 "Format: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 '(("HTML Source")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 ("Formatted Text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ("PostScript")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ("LaTeX Source")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (url (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ((stringp under) under)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (under (w3-view-this-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (t (url-view-url t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (content-type "text/plain; charset=iso-8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ((and (equal "HTML Source" format) under)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (setq content-type "text/html; charset=iso-8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (let ((url-source t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (url-retrieve url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ((equal "HTML Source" format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (setq content-type "text/html; charset=iso-8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (if w3-current-source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (let ((x w3-current-source))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (insert x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (url-retrieve url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ((and under (equal "PostScript" format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (setq content-type "application/postscript")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (w3-fetch url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (let ((ps-spool-buffer-name " *w3-temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (if (get-buffer ps-spool-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (kill-buffer ps-spool-buffer-name))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1006 (ps-spool-buffer-with-faces)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (set-buffer ps-spool-buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 ((equal "PostScript" format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (let ((ps-spool-buffer-name " *w3-temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (if (get-buffer ps-spool-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (kill-buffer ps-spool-buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (setq content-type "application/postscript")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1013 (ps-spool-buffer-with-faces)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (set-buffer ps-spool-buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 ((and under (equal "Formatted Text" format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (setq content-type "text/plain; charset=iso-8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (w3-fetch url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ((equal "Formatted Text" format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (setq content-type "text/plain; charset=iso-8859-1"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ((and under (equal "LaTeX Source" format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (let ((old-asynch url-be-asynchronous))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (setq content-type "application/x-latex; charset=iso-8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (setq-default url-be-asynchronous nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (url-retrieve url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (setq-default url-be-asynchronous old-asynch)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1026 (w3-parse-tree-to-latex (w3-parse-buffer (current-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ((equal "LaTeX Source" format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (setq content-type "application/x-latex; charset=iso-8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (w3-parse-tree-to-latex w3-current-parse url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (buffer-string))))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
1032 (funcall w3-mail-command)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (mail-subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (insert format " from URL " url "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 "Mime-Version: 1.0\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 "Content-transfer-encoding: 8bit\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 "Content-type: " content-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (re-search-forward mail-header-separator nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (insert (if (equal "HTML Source" format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (format "<BASE HREF=\"%s\">" url) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (mail-to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (defun w3-internal-use-history (hist-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 ;; Go to the link in the history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (let ((url (nth 0 hist-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (buf (nth 1 hist-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (pnt (nth 2 hist-item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 ((null buf) ; Find a buffer with same url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (let ((x (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (while (and x (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (set-buffer (car x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (setq found (string= (url-view-url t) url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (if (not found) (setq x (cdr x)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (switch-to-buffer (car x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (if (number-or-marker-p pnt) (goto-char pnt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (w3-fetch url)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 ((buffer-name buf) ; Reuse the old buffer if possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (switch-to-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (if (number-or-marker-p pnt) (goto-char pnt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (if (and url (= ?# (string-to-char url))) ; Destination link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (w3-find-specific-link (substring url 1 nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (url (url-maybe-relative url)) ; Get the link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (t (message "Couldn't understand whats in the history.")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (defun w3-relative-link (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (if (equal "#" (substring url 0 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (push-mark (point) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (w3-find-specific-link (substring url 1 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (w3-fetch (url-expand-file-name url))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (defun w3-maybe-eval ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 ;; Maybe evaluate a buffer of emacs lisp code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (if (funcall url-confirmation-func "This is emacs-lisp code, evaluate it?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (eval-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (emacs-lisp-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (defun w3-build-continuation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 ;; Build a series of functions to be run on this file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (let ((cont w3-default-continuation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (extn (url-file-extension url-current-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (if (assoc extn url-uncompressor-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (setq extn (url-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (substring url-current-file 0 (- (length extn))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (if w3-source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (setq url-current-mime-viewer '(("viewer" . w3-source))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (if (not url-current-mime-viewer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (setq url-current-mime-viewer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (mm-mime-info (or url-current-mime-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (mm-extension-to-mime extn)) nil 5)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (if url-current-mime-viewer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (setq cont (append cont '(w3-pass-to-viewer)))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
1106 (setq cont (append cont (list 'w3-prepare-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 cont)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (defun w3-use-links ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 "Select one of the <LINK> tags from this document and fetch it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (and (not w3-current-links)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (error "No links defined for this document."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (w3-fetch "about:document"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (defun w3-find-this-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 "Do a find-file on the currently viewed html document if it is a file: or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ftp: reference"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ((and (or (null url-current-type) (equal url-current-type "file"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (eq major-mode 'w3-mode))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
1123 (find-file url-current-file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 ((equal url-current-type "ftp")
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
1125 (find-file
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
1126 (format "/%s@%s:%s" url-current-user url-current-server
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
1127 url-current-file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (t (message "Sorry, I can't get that file so you can alter it."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (defun w3-insert-this-url (pref-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 "Insert the current url in another buffer, with prefix ARG,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 insert URL under point"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (let ((thebuf (get-buffer (read-buffer "Insert into buffer: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (oldbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (url (if pref-arg (w3-view-this-url t) (url-view-url t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (if (and url (not (equal "Not on a link!" url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (set-buffer thebuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (insert url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (set-buffer oldbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (message "Not on a link!"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (defun w3-show-hotlist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 "View the hotlist in hypertext form"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (if (not w3-setup-done) (w3-do-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (if (not w3-hotlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (error "Sorry, no hotlist is in memory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (let ((x (url-buffer-visiting "www:/auto/hotlist")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (while x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (kill-buffer x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (setq x (url-buffer-visiting "www:/auto/hotlist"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (w3-fetch "www://auto/hotlist")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (defun url-maybe-relative (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 "Take a url and either fetch it, or resolve relative refs, then fetch it"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 ((not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (string-match url-nonrelative-link url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (w3-relative-link url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (t (w3-fetch url))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (defun w3-in-assoc (elt list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 "Check to see if ELT matches any of the regexps in the car elements of LIST"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (let (rslt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (while (and list (not rslt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (and (car (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (stringp (car (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (not (string= (car (car list)) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (string-match (car (car list)) elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (setq rslt (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 rslt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (defun w3-goto-last-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 "Go to last WWW buffer visited"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (if w3-current-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (w3-notify-when-ready w3-current-last-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (message "No previous buffer found.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (fset 'w3-replace-regexp 'url-replace-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (defun w3-preview-this-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 "See what this buffer will look like when its formatted as HTML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 HTML is the HyperText Markup Language used by the World Wide Web to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 specify formatting for text. More information on HTML can be found at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 ftp.w3.org:/pub/www/doc."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (w3-fetch (concat "www://preview/" (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (defun w3-source ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 "Show the source of a file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (let ((tmp (buffer-name (generate-new-buffer "Document Source"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (kill-buffer tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (rename-buffer tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;; Make the URL show in list-buffers output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (make-local-variable 'list-buffers-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (setq list-buffers-directory (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (buffer-enable-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (w3-notify-when-ready (get-buffer tmp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1207 (defvar w3-mime-list-for-code-conversion
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1208 '("text/plain" "text/html")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1209 "List of MIME types that require Mules' code conversion.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1210
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1211 (defun w3-convert-code-for-mule (mmtype)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1212 "Convert current data into the appropriate coding system"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1213 (and (or (not mmtype)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1214 (member mmtype w3-mime-list-for-code-conversion))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1215 (mule-code-convert-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1216 (point-min) (point-max)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1217 (mule-detect-coding-version (point-min) (point-max)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1218
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (defun w3-sentinel (&optional proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (if (or (stringp proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (bufferp proc)) (setq w3-current-last-buffer proc))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1223 (remove-hook 'after-change-functions 'url-after-change-function)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (if url-be-asynchronous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (url-clean-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ((not (get-buffer url-working-buffer)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ((url-mime-response-p) (url-parse-mime-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (if (not url-current-mime-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (setq url-current-mime-type (or (mm-extension-to-mime
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (url-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 url-current-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 "text/html")))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1235 (if (not (string-match "^www:" (or (url-view-url t) "")))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1236 (w3-convert-code-for-mule url-current-mime-type))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1237
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1238 (let ((x (w3-build-continuation))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1239 (url (url-view-url t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (while x
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1241 (funcall (pop x)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (defun w3-show-history-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 "Format the url-history-list prettily and show it to the user"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (w3-fetch "www://auto/history"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (defun w3-save-as (&optional type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 "Save a document to the local disk"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (interactive)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1251 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1252 (let* ((completion-ignore-case t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1253 (format (or type (completing-read
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1254 "Format: "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1255 '(("HTML Source")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1256 ("Formatted Text")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1257 ("LaTeX Source")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1258 ("PostScript")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1259 ("Binary"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1260 nil t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1261 (fname (expand-file-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1262 (read-file-name "File name: " default-directory)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1263 (url (url-view-url t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1264 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1265 ((equal "Binary" format)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1266 (if (not w3-current-source)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1267 (let ((url-be-asynchronous nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1268 (url-retrieve url))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1269 ((equal "HTML Source" format)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1270 (if (not w3-current-source)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1271 (let ((url-be-asynchronous nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1272 (url-retrieve url)) ; Get the document if necessary
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1273 (let ((txt w3-current-source))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1274 (set-buffer (get-buffer-create url-working-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1275 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1276 (insert txt)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1277 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1278 (if (re-search-forward "<head>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1279 (insert "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1280 (insert (format "<BASE HREF=\"%s\">\n" url)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1281 ((or (equal "Formatted Text" format)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1282 (equal "" format))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1283 nil) ; Do nothing - we have the text already
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1284 ((equal "PostScript" format)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1285 (let ((ps-spool-buffer-name " *w3-temp*"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1286 (if (get-buffer ps-spool-buffer-name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1287 (kill-buffer ps-spool-buffer-name))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1288 (ps-spool-buffer-with-faces)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1289 (set-buffer ps-spool-buffer-name)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1290 ((equal "LaTeX Source" format)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1291 (w3-parse-tree-to-latex w3-current-parse url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1292 (insert-buffer url-working-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
1293 (write-region (point-min) (point-max) fname))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 ;;; Functions to parse out <A> tags and replace it with a hyperlink zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (defun w3-popup-image-info (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (let* ((glyph (cdr-safe (assoc url w3-graphics-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 image w h d info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (if (or (not glyph) (not (glyphp glyph)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (error "No information available."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (setq image (glyph-image-instance glyph))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (if (or (not image) (not (image-instance-p image)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (error "No information available."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (setq w (glyph-width glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 h (glyph-height glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 d (image-instance-depth image)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 info (url-popup-info url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (set-buffer (get-buffer-create "*Image Info*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 "Information for: " url "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (make-string (1- (window-width)) ?-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (format "\n%-20s: %s\n" "Type" (image-instance-type image))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (format "%-20s: %d x %d\n" "Dimensions" w h)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (format "%-20s: %d-bit\n" "Color" d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (make-string (1- (window-width)) ?-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (or info ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (display-buffer (current-buffer) t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (defun w3-popup-info (&optional url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 "Show information about the link under point. (All SGML attributes)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (interactive (list (w3-read-url-with-default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (let (dat widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (setq widget (widget-at (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 dat (and widget (widget-get widget 'attributes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (if url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (set-buffer (get-buffer-create "*Header Info*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (insert "URL: " url "\n" (make-string (1- (window-width)) ?-) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (if (and dat (listp dat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 "Link attributes:\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (make-string (1- (window-width)) ?-) "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (lambda (info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (format "%20s :== %s" (car info) (or (cdr info) "On"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 dat "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 "\n" (make-string (1- (window-width)) ?-) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (insert (save-excursion (url-popup-info url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (display-buffer (current-buffer) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (message "No URL to get information on!"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (fset 'w3-document-information-this-url 'w3-popup-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 ;;; Functions for logging of bad HTML
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (defun w3-reconstruct-tag (tagname desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (concat "<" tagname " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (function (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (if (cdr x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (concat (car x) "=\"" (cdr x) "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (car x)))) desc " ") ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (defun w3-debug-if-found (regexp type desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (and w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (if (re-search-forward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (w3-log-bad-html type desc)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (defun w3-log-bad-html (type desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 ;; Log bad HTML to the buffer specified by w3-debug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (if w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (set-buffer (get-buffer-create w3-debug-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (insert (make-string (1- (window-width)) w3-horizontal-rule-char) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 ((stringp type) (insert type "\n" desc "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 ((eq type 'bad-quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (insert "Unterminated quoting character in SGML attribute value.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 desc "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 ((eq type 'no-quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (insert "Unquoted SGML attribute value.\n" desc "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 ((eq type 'no-textarea-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (insert "Unterminated <textarea> tag.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (w3-reconstruct-tag "textarea" desc) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 ((eq type 'bad-link-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (insert "Must specify either REL or REV with a <link> tag.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (w3-reconstruct-tag "link" desc) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 ((eq type 'no-a-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (insert "Unterminated <a> tag.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (w3-reconstruct-tag "a" desc) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 ((eq type 'no-form-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (insert "Unterminated <form> tag.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (w3-reconstruct-tag "form" desc) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 ((eq type 'bad-base-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (insert "Malformed <base> tag.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (w3-reconstruct-tag "base" desc) "\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 ;;; Functions to handle formatting an html buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1411 (defun w3-add-delayed-graphic (widget)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;; Add a delayed image for the current buffer.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1413 (setq w3-delayed-images (cons widget w3-delayed-images)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (defun w3-load-flavors ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 ;; Load the correct zone/font info for each flavor of emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 ((and w3-running-xemacs (eq system-type 'ms-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (error "WinEmacs no longer supported."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (w3-running-xemacs (require 'w3-xemac))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (w3-running-FSF19 (require 'w3-e19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (error "Unable to determine the capabilities of this emacs.")))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1425 (if (featurep 'emacspeak)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1426 (condition-case ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1427 (progn
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1428 (require 'dtk-css-speech)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1429 (require 'w3-speak))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (require 'w3-site-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 ;;; Automatic bug submission. ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (defun w3-submit-bug ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 "Submit a bug on Emacs-w3"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (require 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (and (yes-or-no-p "Do you really want to submit a bug on Emacs-w3? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (let ((url (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (vars '(window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 window-system-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 system-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 ange-ftp-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 url-gateway-method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 efs-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 ange-ftp-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 url-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 url-be-asynchronous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (if (and url (string= url "file:nil")) (setq url nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (if (not (and (boundp x) (symbol-value x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (setq vars (delq x vars))))) vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (reporter-submit-bug-report w3-bug-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (concat "WWW v" w3-version-number " of "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 w3-version-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 "Description of Problem:"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1466 (defalias 'w3-bug 'w3-submit-bug)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1467
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 ;;; Support for searching ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (defun w3-nuke-spaces-in-search (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 "Remove spaces from search strings . . ."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (let ((new ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (while (not (equal x ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (setq new (concat new (if (= (string-to-char x) 32) "+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (substring x 0 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 x (substring x 1 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (defun w3-search ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 "Perform a search, if this is a searchable index."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (let* (querystring ; The string to send to the server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 ((null w3-current-isindex)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1487 (let ((rels (cdr-safe (assq 'rel w3-current-links)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1488 val cur)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (while rels
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1490 (setq cur (car rels)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1491 rels (cdr rels))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1492 (if (and (or (string-match "^isindex$" (car cur))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1493 (string-match "^index$" (car cur)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1494 (plist-get (cadr cur) 'href))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1495 (setq val (plist-get (cadr cur) 'href)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 rels nil))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1497 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1498 (if val
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1499 (cons val "Search on (+ separates keywords): "))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 ((eq w3-current-isindex t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (cons (url-view-url t) "Search on (+ separates keywords): "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 ((consp w3-current-isindex)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 w3-current-isindex)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (if (null data) (error "Not a searchable index!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (setq index (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (setq querystring (w3-nuke-spaces-in-search (read-string (cdr data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (if (string-match "\\(.*\\)\\?.*" index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (setq index (url-match index 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (w3-fetch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (concat index (if (= ?? (string-to-char (substring index -1 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 "" "?") querystring))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 ;;; Auto documentation, etc ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (defun w3-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 "Print documentation on w3 mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (w3-fetch "about:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (defun w3-version (&optional here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 "Show the version number of W3 in the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 If optional argument HERE is non-nil, insert info at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (let ((version-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (format "WWW %s, URL %s, MM %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 w3-version-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 url-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 mm-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (if here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (insert version-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (message "%s" version-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 version-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (defun w3 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 "Retrieve the default World Wide Web home page.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 The World Wide Web is a global hypertext system started by CERN in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 Switzerland in 1991.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 The home page is specified by the variable w3-default-homepage. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 document should be specified by its fully specified Uniform Resource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 Locator. The document will be parsed as HTML (if appropriate) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 displayed in a new buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (if (not w3-setup-done) (w3-do-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (if (and w3-track-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (bufferp w3-last-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (buffer-name w3-last-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (switch-to-buffer w3-last-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (message "Reusing buffer. To reload, type %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (substitute-command-keys "\\[w3-reload-document]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 ((null w3-default-homepage) (call-interactively 'w3-fetch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 ((not (stringp w3-default-homepage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (error "Invalid setting for w3-default-homepage: %S"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 w3-default-homepage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 ((not (string-match ".*:.*" w3-default-homepage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (w3-fetch (concat "file:" w3-default-homepage)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (w3-fetch w3-default-homepage)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 ;;; Leftover stuff that didn't quite fit into url.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (defun w3-generate-error (type data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 ;; Generate an HTML error buffer for error TYPE with data DATA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 ((equal type "nofile")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (let ((error (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (set-buffer (get-buffer-create " *url-error*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (if (string= "" error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (setq error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (format (concat "The file %s could not be found. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 "Either it does not exist, or it "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 "is unreadable.") data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (insert "<html>\n <head>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 " <title>Error</title>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 " </head>\n <body>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 " <h1>Error accessing " data "</h1>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 " <hr>\n <p>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 "\n </p>\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 ((equal type "nobuf")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (insert "<title>Error</title>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 "<H1>No buffer " data " found</h1>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 "<HR>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 "The buffer " data " could not be found. It has either\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 "been killed or renamed.\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 ((equal type "nohist")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (insert "<TITLE>Error</TITLE>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 "<H1>No history items found.</H1>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 "<HR>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 "There is no history list available at this time. Either\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 "you have not visited any nodes, or the variable <i>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 "url-keep-history</i> is nil.\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (insert "<hr>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 "If you feel this is a bug in Emacs-W3, <a href=\"mailto:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 w3-bug-address "\">send mail to " w3-bug-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 "</a>\n<hr>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (defun w3-generate-auto-html (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 ;; Generate one of several automatic html pages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (setq url-current-mime-type "text/html"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 url-current-mime-headers '(("content-type" . "text/html")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 ((equal type "hotlist")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (let ((tmp (reverse w3-hotlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (insert "<html>\n\t<head>\n\t\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 "<title> Hotlist </title>\n\t</head>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 "\t<body>\n\t\t<div>\n\t\t\t<h1>Hotlist from " w3-hotlist-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 "</h1>\n\t\t\t<ol>\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (while tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (insert "\t\t\t\t<li> <a href=\"" (car (cdr (car tmp)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1622 "\">" (url-insert-entities-in-string
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (car (car tmp))) "</a></li>\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (setq tmp (cdr tmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (insert "\n\t\t\t</ol>\n\t\t</div>\n\t</body>\n</html>\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ((equal type "history")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (if (not url-history-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (url-retrieve "www://error/nohist")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (insert "<html>\n\t<head>\n\t\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 "<title> History List For This Session of W3</title>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 "\n\t</head>\n\t<body>\n\t\t<div>\n\t\t\t<h1>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 "History List For This Session of W3</h1>\n\t\t\t<ol>\n")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1633 (cl-maphash
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (lambda (url desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (insert (format "\t\t\t\t<li> <a href=\"%s\">%s</a>\n"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1637 url (url-insert-entities-in-string desc)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 url-history-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (insert "\n\t\t\t</ol>\n\t\t</div>\n\t</body>\n</html>\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (defun w3-internal-handle-preview (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (setq buffer (get-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (let ((base (get-text-property (point-min) 'w3-base buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (if base
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (setq base (url-generic-parse-url base)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (insert-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (if (not base)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (setq url-current-type "file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 url-current-server nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 url-current-file (buffer-file-name buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (setq url-current-object base
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 url-current-type (url-type base)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 url-current-user (url-user base)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 url-current-port (url-port base)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 url-current-server (url-host base)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 url-current-file (url-filename base)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (defun w3-internal-url (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 ;; Handle internal urls (previewed buffers, etc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (if (not (string-match "www:/+\\([^/]+\\)/\\(.*\\)" url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (w3-fetch "www://error/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (let ((type (url-match url 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (data (url-match url 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (setq url-current-type "www"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 url-current-server type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 url-current-file data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 ((equal type "preview") ; Previewing a document
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (if (get-buffer data) ; Buffer still exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (w3-internal-handle-preview data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (url-retrieve (concat "www://error/nobuf/" data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 ((equal type "error") ; Error message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (if (string-match "\\([^/]+\\)/\\(.*\\)" data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (w3-generate-error (url-match data 1) (url-match data 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (w3-generate-error data "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 ((equal type "auto") ; Hotlist or help stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (w3-generate-auto-html data))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 ;;; Stuff for good local file handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (defun w3-ff (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 "Find a file in any window already displaying it, otherwise just as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 display-buffer, and using this function"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (if (not (eq 'tty (device-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (let ((f (window-frame (display-buffer (find-file-noselect file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (set-mouse-position f 1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (raise-frame f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (unfocus-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (display-buffer (find-file-noselect file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (defun w3-default-local-file()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 "Use find-file to open the local file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (w3-ff url-current-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 ;;; Mode definition ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (defun w3-search-forward (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (interactive "sSearch: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (setq w3-last-search-item string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (if (and (not (search-forward string nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (funcall url-confirmation-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 "End of document reached; continue from beginning? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (w3-search-forward string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (defun w3-search-again ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (if (and w3-last-search-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (stringp w3-last-search-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (if (and (not (search-forward w3-last-search-item nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (funcall url-confirmation-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 "End of document reached; continue from beginning? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (w3-search-again)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (defun w3-find-specific-link (link)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (let ((pos (assq (intern link) w3-id-positions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (if pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (goto-char (cdr pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (if (and (eolp) (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (error "Link #%s not found." link))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (defun w3-force-reload-document ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 "Reload the current document. Take it from the network, even if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 cached and in local mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (let ((url-standalone-mode nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (w3-reload-document)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (defun w3-reload-document ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 "Reload the current document"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (let ((tmp (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (pnt (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (window-start (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (move-to-window-line 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (url-request-extra-headers '(("Pragma" . "no-cache"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (w3-fetch tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (goto-char pnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (set-window-start (selected-window) (min window-start (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (defun w3-leave-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 "Bury this buffer, but don't kill it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (let ((x w3-current-last-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (bury-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (if (and (bufferp x) (buffer-name x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (w3-notify-when-ready x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (defun w3-quit (&optional mega)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 "Quit WWW mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (if mega
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (set-buffer (get-buffer x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (if (eq major-mode 'w3-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (w3-quit nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (let ((x w3-current-last-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (if (and (bufferp x) (buffer-name x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (w3-notify-when-ready x)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (defun w3-view-this-url (&optional no-show)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 "View the URL of the link under point"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (let* ((widget (widget-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (href (and widget (widget-get widget 'href))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 ((and no-show href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (href
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (message "%s" (url-truncate-url-for-viewing href)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (no-show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1787 (widget
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1788 (widget-echo-help (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (defun w3-load-delayed-images ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1793 "Load inlined images that were delayed, if any."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (interactive)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1795 (let ((w3-delay-image-loads nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1796 (todo w3-delayed-images))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1797 (setq w3-delayed-images nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1798 (while todo
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1799 (w3-maybe-start-image-download (car todo))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1800 (setq todo (cdr todo)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (defun w3-save-this-url ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 "Save url under point in the kill ring"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (w3-save-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (defun w3-save-url (under-pt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 "Save current url in the kill ring"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (let ((x (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 ((stringp under-pt) under-pt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (under-pt (w3-view-this-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (t (url-view-url t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (if x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (setq kill-ring (cons x kill-ring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (setq kill-ring-yank-pointer kill-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (message "Stored URL in kill-ring.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (if (fboundp 'w3-store-in-clipboard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (w3-store-in-clipboard x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (error "No URL to store."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (fset 'w3-end-of-document 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (fset 'w3-start-of-document 'beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (defun w3-scroll-up (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 "Scroll forward in View mode, or exit if end of text is visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 No arg means whole window full. Arg is number of lines to scroll."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (if (and (pos-visible-in-window-p (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 ;; Allow scrolling backward at the end of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (or (null lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (> lines 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (let ((view-lines (1- (window-height))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (setq lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (if lines (prefix-numeric-value lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 view-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (if (>= lines view-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (scroll-up nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (if (>= (- lines) view-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (scroll-down nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (scroll-up lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (cond ((pos-visible-in-window-p (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 (recenter -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (move-to-window-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (beginning-of-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (defun w3-mail-document-author ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 "Send mail to the author of this document, if possible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (let ((x w3-current-links)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (y nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (setq found (cdr-safe (assoc "reply-to" url-current-mime-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (if (and found (not (string-match url-nonrelative-link found)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1858 (setq found (list (concat "mailto:" found))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (while (and x (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (setq y (car x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 x (cdr x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 found (cdr-safe (assoc "made" y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (let ((possible nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (setq x (car found)) ; Fallback if no mail(to|server) found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (while found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (if (string-match "^mail[^:]+:" (car found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (setq possible (cons (car found) possible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (setq found (cdr found)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (case (length possible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (0 ; No mailto links found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (w3-fetch x)) ; fall back onto first 'made' link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (1 ; Only one found, get it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (w3-fetch (car possible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (w3-fetch (completing-read "Choose an address: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (mapcar 'list possible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 nil t (car possible))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (message "Could not automatically determine authors address, sorry.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (w3-fetch (concat "mailto:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (read-string "Email address: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (if url-current-server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (concat "@" url-current-server))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (defun w3-kill-emacs-func ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 "Routine called when exiting emacs. Do miscellaneous clean up."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (and (eq url-keep-history t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 url-global-history-hash-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (url-write-global-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (message "Cleaning up w3 storage...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (let ((x (nconc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (and (file-exists-p w3-temporary-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (directory-files w3-temporary-directory t "url-tmp.*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (and (file-exists-p url-temporary-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (directory-files url-temporary-directory t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (concat "url"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (user-real-uid)) ".*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (and (file-exists-p url-temporary-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (directory-files url-temporary-directory t "url-tmp.*")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (while x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (delete-file (car x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (setq x (cdr x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (message "Cleaning up w3 storage... done."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 ((fboundp 'display-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (fset 'w3-warn 'display-warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 ((fboundp 'warn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (defun w3-warn (class message &optional level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (if (and (eq class 'html)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (not w3-debug-html))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (warn "(%s/%s) %s" class (or level 'warning) message))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (defun w3-warn (class message &optional level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (if (and (eq class 'html)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (not w3-debug-html))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (set-buffer (get-buffer-create "*W3-WARNINGS*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (insert (format "(%s/%s) %s\n" class (or level 'warning) message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (display-buffer (current-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (defun w3-internal-expander (urlobj defobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 ;; URL Expansion routine for internally handled routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (url-identity-expander urlobj defobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (defun w3-map-links (function &optional buffer from to maparg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 "Map FUNCTION over the hypertext links which overlap region in BUFFER,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 starting at FROM and ending at TO. FUNCTION is called with the arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 WIDGET and MAPARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 The arguments FROM, TO, MAPARG, and BUFFER default to the beginning of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 BUFFER, the end of BUFFER, nil, and (current-buffer), respectively."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (let ((cur (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (widget nil)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1942 (parent nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (while (setq cur (next-single-property-change cur 'button))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1944 (setq widget (widget-at cur)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1945 parent (and widget (widget-get widget :parent)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 ;; Check to see if its a push widget, its got the correct callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 ;; and actually has a URL. Remember the url as a side-effect of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 ;; test for later use.
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1949 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1950 ((and widget (widget-get widget 'href))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1951 (funcall function widget maparg))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1952 ((and parent (widget-get parent 'href))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1953 (funcall function parent maparg))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1954 (t nil)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (defun w3-emit-image-warnings-if-necessary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (if (and (not w3-delay-image-loads)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (fboundp 'w3-insert-graphic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (or (not (featurep 'gif))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (not (featurep 'jpeg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (not (w3-executable-exists-in-path "ppmtoxpm"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (not (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (w3-executable-exists-in-path "pbmtoxbm")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (w3-executable-exists-in-path "ppmtoxbm"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (w3-warn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 'image
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 "Could not find some vital ppm utilities in exec-path.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 "This probably means that you will be unable to view any\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 "inlined images other than: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (if (featurep x) (concat (symbol-name x) ",\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 '(png jpg gif xpm xbm) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 "\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 "If you do not have the PPM utilities from either the PBMPLUS\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 "or NETPBM distributions installed on your machine, then\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 "please set the variable `w3-delay-image-loads' to t with a\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 "line like:\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 "\t(setq w3-delay-image-loads t)\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 "in your ~/.emacs file.\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 "You can find the NETPBM utilities in:\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 "\tftp://ftp.cs.indiana.edu/pub/elisp/w3/images/\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1987 (defun w3-refresh-stylesheets ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1988 "Reload all stylesheets."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1989 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1990 (setq w3-user-stylesheet nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1991 w3-face-cache nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1992 (w3-find-default-stylesheets)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
1993 )
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1994
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (defun w3-find-default-stylesheets ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (let* ((lightp (w3-color-light-p 'default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (longname (if lightp "stylesheet-light" "stylesheet-dark"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (shortname (if lightp "light.css" "dark.css"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (directories (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 data-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (concat data-directory "w3/")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2002 (expand-file-name "../../w3" data-directory)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (file-name-directory (locate-library "w3"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 w3-configuration-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (total-found 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (possible (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (apply
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (lambda (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (expand-file-name shortname dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (expand-file-name longname dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (expand-file-name "stylesheet" dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (expand-file-name "default.css" dir))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 directories))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (list w3-default-stylesheet)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (remember possible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (old-asynch (default-value 'url-be-asynchronous))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (found nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (cur nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (url nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (setq-default url-be-asynchronous nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 (while possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (setq cur (car possible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 possible (cdr possible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 found (and cur (file-exists-p cur) (file-readable-p cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (not (file-directory-p cur)) cur))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (setq total-found (1+ total-found)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2032 w3-user-stylesheet (css-parse (concat "file:" cur) nil
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2033 w3-user-stylesheet))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (setq-default url-be-asynchronous old-asynch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (if (= 0 total-found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (w3-warn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 'style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 "No stylesheets found! Check configuration! DANGER DANGER!\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 "Emacs-W3 checked for its stylesheet in the following places\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 "and did not find one. This means that some formatting will\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 "be wrong, and most colors and fonts will not be set up correctly.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 "------\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (mapconcat 'identity remember "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 "------")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (defun w3-do-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 "Do setup - this is to avoid conflict with user settings when W3 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 dumped with emacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (url-do-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (url-register-protocol 'about 'w3-about 'url-identity-expander)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (url-register-protocol 'www 'w3-internal-url 'w3-internal-expander)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (w3-load-flavors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (w3-setup-version-specifics)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (setq w3-default-configuration-file (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (or w3-default-configuration-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 "profile")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 w3-configuration-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (if (and w3-default-configuration-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (file-exists-p w3-default-configuration-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (condition-case e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (load w3-default-configuration-file nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (let ((buf-name " *Configuration Error*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (if (get-buffer buf-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 (kill-buffer (get-buffer buf-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (display-error e (get-buffer-create buf-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (switch-to-buffer-other-window buf-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (shrink-window-if-larger-than-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (w3-warn 'configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (format (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 "Configuration file `%s' contains an error.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 "Please consult the `%s' buffer for details."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 w3-default-configuration-file buf-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 (setq w3-netscape-configuration-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (w3-netscape-configuration-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 w3-netscape-configuration-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 ((memq system-type '(ms-dos ms-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 (expand-file-name "~/NETSCAPE.CFG"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (t (expand-file-name "~/.netscape/preferences"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (if (and (eq w3-user-colors-take-precedence 'guess)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (not (eq (device-type) 'tty))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (not (eq (device-class) 'mono)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 (setq w3-user-colors-take-precedence t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (w3-warn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 'html
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2096 "Disabled document color specification because of mono display.")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2098 (w3-refresh-stylesheets)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (if (not url-global-history-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (setq url-global-history-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (expand-file-name "history"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 w3-configuration-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (if (and w3-use-netscape-configuration-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 w3-netscape-configuration-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (fboundp 'w3-read-netscape-config))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (w3-read-netscape-config w3-netscape-configuration-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (add-minor-mode 'w3-netscape-emulation-minor-mode " NS"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 w3-netscape-emulation-minor-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (add-minor-mode 'w3-lynx-emulation-minor-mode " Lynx"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2112 w3-lynx-emulation-minor-mode-map)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (setq url-package-version w3-version-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 url-package-name "Emacs-W3")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (w3-emit-image-warnings-if-necessary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 ((memq system-type '(ms-dos ms-windows))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
2121 (setq w3-hotlist-file (or w3-hotlist-file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (expand-file-name "~/mosaic.hot"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2123 ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 ((memq system-type '(axp-vms vax-vms))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
2125 (setq w3-hotlist-file (or w3-hotlist-file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 (expand-file-name "~/mosaic.hotlist-default"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2127 ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (t
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
2129 (setq w3-hotlist-file (or w3-hotlist-file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 (expand-file-name "~/.mosaic-hotlist-default"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2131 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 ; Set up a hook that will save the history list when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 ; exiting emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 (add-hook 'kill-emacs-hook 'w3-kill-emacs-func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (mm-parse-mailcaps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (mm-parse-mimetypes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 ; Load in the hotlist if they haven't set it already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (or w3-hotlist (w3-parse-hotlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 ; Set the default home page, honoring their defaults, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 ; the standard WWW_HOME, then default to the documentation @ IU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (or w3-default-homepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (setq w3-default-homepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (or (getenv "WWW_HOME")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 "http://www.cs.indiana.edu/elisp/w3/docs.html")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 ; Set up the entity definition for PGP and PEM authentication
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (run-hooks 'w3-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (setq w3-setup-done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (defun w3-mark-link-as-followed (ext dat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 ;; Mark a link as followed
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2157 (message "Reimplement w3-mark-link-as-followed"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (defun w3-only-links ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (let* (result temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (if (widget-at (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (setq result (list (widget-at (point-min)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (setq temp (w3-next-widget (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (while temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (if (widget-get temp 'href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (setq result (cons temp result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (setq temp (w3-next-widget (widget-get temp :to))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (defun w3-download-callback (fname buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (if (and (get-buffer buff) (buffer-name buff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 (set-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 (let ((require-final-newline nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 (file-name-handler-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (write-file-hooks nil)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2177 (write-contents-hooks nil)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2178 (enable-multibyte-characters t) ; mule 2.4
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2179 (buffer-file-coding-system mule-no-coding-system) ; mule 2.4
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2180 (file-coding-system mule-no-coding-system) ; mule 2.3
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2181 (mc-flag t)) ; mule 2.3
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2182 (write-file fname)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (message "Download of %s complete." (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 (sit-for 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (kill-buffer buff)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 (defun w3-download-url (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (let* ((old-asynch url-be-asynchronous)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (url-inhibit-uncompression t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (url-mime-accept-string "*/*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (urlobj (url-generic-parse-url url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (url-working-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (generate-new-buffer (concat " *" url " download*")))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2194 (stub-fname (url-remove-compressed-extensions
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2195 (url-basepath (or (url-filename urlobj) "") t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (fname (read-file-name "Filename to save as: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (or mm-download-directory "~/")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2198 stub-fname
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 stub-fname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (setq-default url-be-asynchronous t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 (setq url-current-callback-data (list fname (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 url-be-asynchronous t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 url-current-callback-func 'w3-download-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 (url-retrieve url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (setq-default url-be-asynchronous old-asynch)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (defun w3-follow-link-other-frame (&optional p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 "Attempt to follow the hypertext reference under point in a new frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 With prefix-arg P, ignore viewers and dump the link straight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 to disk."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 ((and (fboundp 'make-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 (fboundp 'select-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (let ((frm (make-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (select-frame frm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (w3-follow-link p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 (t (w3-follow-link p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (defun w3-follow-link (&optional p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 "Attempt to follow the hypertext reference under point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 With prefix-arg P, ignore viewers and dump the link straight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 to disk."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (let* ((widget (widget-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 (href (and widget (widget-get widget 'href))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 ((null href) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 ((or p w3-dump-to-disk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (w3-download-url href))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (w3-fetch href)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2238 ;;; FIXME! Need to rewrite these so that we can pass a predicate to
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2239 (defun w3-widget-forward (arg)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2240 "Move point to the next field or button.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2241 With optional ARG, move across that many fields."
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2242 (interactive "p")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2243 (widget-forward arg))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2244
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2245 (defun w3-widget-backward (arg)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2246 "Move point to the previous field or button.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2247 With optional ARG, move across that many fields."
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2248 (interactive "p")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2249 (w3-widget-forward (- arg)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2250
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (defun w3-complete-link ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 "Choose a link from the current buffer and follow it"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (let (links-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 link-at-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 choice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (completion-ignore-case t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (setq link-at-point (widget-at (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 link-at-point (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 link-at-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 (widget-get link-at-point 'href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 (w3-fix-spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (buffer-substring
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2264 (widget-get link-at-point :from)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2265 (widget-get link-at-point :to)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (w3-map-links (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 (lambda (widget arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 (setq links-alist (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (w3-fix-spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (widget-get widget :from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 (widget-get widget :to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (widget-get widget 'href))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 links-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 (if (not links-alist) (error "No links in current document."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 (setq links-alist (sort links-alist (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 (lambda (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 (string< (car x) (car y))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 ;; Destructively remove duplicate entries from links-alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 (let ((remaining-links links-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 (while remaining-links
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (if (equal (car remaining-links) (car (cdr remaining-links)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 (setcdr remaining-links (cdr (cdr remaining-links)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 (setq remaining-links (cdr remaining-links)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (setq choice (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 (if link-at-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 (concat "Link (default "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 (if (< (length link-at-point) 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 link-at-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (substring link-at-point 0 17) "..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 "): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 "Link: ") links-alist nil t))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2295 (if (setq choice (try-completion choice links-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2296 (w3-fetch (cdr (assoc choice links-alist))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 (defun w3-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 "Mode for viewing HTML documents. If called interactively, will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 display the current buffer as HTML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 Current keymap is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 \\{w3-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 (or w3-setup-done (w3-do-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (w3-preview-this-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (let ((tmp (mapcar (function (lambda (x) (cons x (symbol-value x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 w3-persistent-variables)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (use-local-map w3-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 (setq major-mode 'w3-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (setq mode-name "WWW")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (mapcar (function (lambda (x) (set-variable (car x) (cdr x)))) tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (w3-mode-version-specifics)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 (w3-menu-install-menus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 (run-hooks 'w3-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (widget-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (setq url-current-passwd-count 0
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2320 inhibit-read-only nil
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2321 truncate-lines t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 mode-line-format w3-modeline-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 (if (and w3-current-isindex (equal url-current-type "http"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (setq mode-line-process "-Searchable")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (require 'mm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (require 'url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 (require 'w3-parse)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2329 (require 'w3-display)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (require 'w3-auto)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (require 'w3-emulate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (require 'w3-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (require 'w3-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 (provide 'w3)