annotate lisp/w3/w3.el @ 14:9ee227acff29 r19-15b90

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