annotate lisp/w3/w3.el @ 102:a145efe76779 r20-1b3

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