annotate lisp/w3/w3.el @ 126:1370575f1259 xemacs-20-1p1

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