annotate lisp/w3/w3.el @ 70:131b0175ea99 r20-0b30

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