annotate lisp/w3/w3.el @ 32:e04119814345 r19-15b99

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