Mercurial > hg > xemacs-beta
comparison lisp/w3/w3.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 8d2a9b52c682 |
children | 1ce6082ce73f |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
1 ;;; w3.el --- Main functions for emacs-w3 on all platforms/versions | 1 ;;; w3.el --- Main functions for emacs-w3 on all platforms/versions |
2 ;; Author: wmperry | 2 ;; Author: wmperry |
3 ;; Created: 1997/03/26 00:02:30 | 3 ;; Created: 1996/08/19 03:30:47 |
4 ;; Version: 1.103 | 4 ;; Version: 1.22 |
5 ;; Keywords: faces, help, comm, news, mail, processes, mouse, hypermedia | 5 ;; Keywords: faces, help, comm, news, mail, processes, mouse, hypermedia |
6 | 6 |
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry (wmperry@cs.indiana.edu) | 8 ;;; Copyright (c) 1993 - 1996 by William M. Perry (wmperry@cs.indiana.edu) |
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc. | |
10 ;;; | 9 ;;; |
11 ;;; This file is part of GNU Emacs. | 10 ;;; This file is not part of GNU Emacs, but the same permissions apply. |
12 ;;; | 11 ;;; |
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;;; GNU Emacs is free software; you can redistribute it and/or modify |
14 ;;; it under the terms of the GNU General Public License as published by | 13 ;;; it under the terms of the GNU General Public License as published by |
15 ;;; the Free Software Foundation; either version 2, or (at your option) | 14 ;;; the Free Software Foundation; either version 2, or (at your option) |
16 ;;; any later version. | 15 ;;; any later version. |
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 ;;; GNU General Public License for more details. | 20 ;;; GNU General Public License for more details. |
22 ;;; | 21 ;;; |
23 ;;; You should have received a copy of the GNU General Public License | 22 ;;; You should have received a copy of the GNU General Public License |
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the | 23 ;;; along with GNU Emacs; see the file COPYING. If not, write to |
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 24 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
26 ;;; Boston, MA 02111-1307, USA. | |
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
28 | 26 |
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
30 ;;; This is a major mode for browsing documents written in Hypertext Markup ;;; | 28 ;;; This is a major mode for browsing documents written in Hypertext Markup ;;; |
31 ;;; Language (HTML). These documents are typicallly part of the World Wide ;;; | 29 ;;; Language (HTML). These documents are typicallly part of the World Wide ;;; |
67 (expand-file-name | 65 (expand-file-name |
68 name (car p2))))))))))) | 66 name (car p2))))))))))) |
69 ) | 67 ) |
70 | 68 |
71 | 69 |
72 (require 'w3-sysdp) | 70 (load-library "w3-sysdp") |
73 (require 'mule-sysdp) | |
74 | |
75 (or (featurep 'efs) | 71 (or (featurep 'efs) |
76 (featurep 'efs-auto) | 72 (featurep 'efs-auto) |
77 (condition-case () | 73 (condition-case () |
78 (require 'ange-ftp) | 74 (require 'ange-ftp) |
79 (error nil))) | 75 (error nil))) |
80 | 76 |
81 (require 'cl) | 77 (require 'cl) |
82 (require 'css) | |
83 (require 'w3-vars) | 78 (require 'w3-vars) |
84 (eval-and-compile | 79 (eval-and-compile |
85 (require 'w3-display)) | 80 (require 'w3-draw)) |
86 | 81 |
87 | 82 |
88 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 83 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
89 ;;; Code for printing out roman numerals | 84 ;;; Code for printing out roman numerals |
90 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 85 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
125 (t (concat (char-to-string (+ ?A (1- (/ n 27)))) | 120 (t (concat (char-to-string (+ ?A (1- (/ n 27)))) |
126 (w3-decimal-to-alpha (% n 26)))))) | 121 (w3-decimal-to-alpha (% n 26)))))) |
127 | 122 |
128 | 123 |
129 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 124 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
125 ;;; Functions for compatibility with XMosaic | |
126 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
127 | |
128 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
129 ;;; Parse out the Mosaic documents-menu file | |
130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
131 (defun w3-parse-docs-menu () | |
132 ;; Parse the Mosaic documents menu | |
133 (let ((tmp-menu (append '((separator)) w3-starting-documents | |
134 '((separator)))) | |
135 real-menu x y name url) | |
136 (if (or (not (file-exists-p w3-documents-menu-file)) | |
137 (not (file-readable-p w3-documents-menu-file))) | |
138 nil | |
139 (save-excursion | |
140 (set-buffer (get-buffer-create " *w3-temp*")) | |
141 (erase-buffer) | |
142 (insert-file-contents w3-documents-menu-file) | |
143 (goto-char (point-min)) | |
144 (while (not (eobp)) | |
145 (if (not (looking-at "-+$")) | |
146 (setq x (progn (beginning-of-line) (point)) | |
147 y (progn (end-of-line) (point)) | |
148 name (prog1 | |
149 (buffer-substring x y) | |
150 (delete-region x (min (1+ y) (point-max)))) | |
151 x (progn (beginning-of-line) (point)) | |
152 y (progn (end-of-line) (point)) | |
153 url (prog1 | |
154 (buffer-substring x y) | |
155 (delete-region x (min (1+ y) (point-max)))) | |
156 tmp-menu (if (rassoc url tmp-menu) tmp-menu | |
157 (cons (cons name url) tmp-menu))) | |
158 (setq tmp-menu (cons '(separator) tmp-menu)) | |
159 (delete-region (point-min) (min (1+ (progn (end-of-line) | |
160 (point))) | |
161 (point-max))))) | |
162 (kill-buffer (current-buffer)))) | |
163 (if (equal (car (car tmp-menu)) "") (setq tmp-menu (cdr tmp-menu))) | |
164 (while tmp-menu | |
165 (setq real-menu (cons (if (equal 'separator (car (car tmp-menu))) | |
166 "--------" | |
167 (vector (car (car tmp-menu)) | |
168 (list 'w3-fetch | |
169 (if (listp (cdr (car tmp-menu))) | |
170 (car (cdr (car tmp-menu))) | |
171 (cdr (car tmp-menu)))) t)) | |
172 real-menu) | |
173 tmp-menu (cdr tmp-menu))) | |
174 (setq w3-navigate-menu (append w3-navigate-menu real-menu | |
175 (list "-----"))))) | |
176 | |
177 | |
178 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
130 ;;; Functions to pass files off to external viewers | 179 ;;; Functions to pass files off to external viewers |
131 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 180 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
132 (defun w3-start-viewer (fname cmd &optional view) | 181 (defun w3-start-viewer (fname cmd &optional view) |
133 "Start a subprocess, named FNAME, executing CMD. | 182 "Start a subprocess, named FNAME, executing CMD |
134 If third arg VIEW is non-nil, show the output in a buffer when | 183 If third arg VIEW is non-nil, show the output in a buffer when |
135 the subprocess exits." | 184 the subprocess exits." |
136 (if view (save-excursion | 185 (if view (save-excursion |
137 (set-buffer (get-buffer-create view)) | 186 (set-buffer (get-buffer-create view)) |
138 (erase-buffer))) | 187 (erase-buffer))) |
139 (start-process fname view shell-file-name shell-command-switch cmd)) | 188 (let ((proc |
189 (start-process fname view (or shell-file-name | |
190 (getenv "ESHELL") | |
191 (getenv "SHELL") | |
192 "/bin/sh") "-c" cmd))) | |
193 proc)) | |
140 | 194 |
141 (defun w3-viewer-filter (proc string) | 195 (defun w3-viewer-filter (proc string) |
142 ;; A process filter for asynchronous external viewers | 196 ;; A process filter for asynchronous external viewers |
143 (let ((buff (get-buffer-create (url-generate-new-buffer-name | 197 (let ((buff (get-buffer-create (url-generate-new-buffer-name |
144 (symbol-name | 198 (symbol-name |
181 (make-frame))) | 235 (make-frame))) |
182 ((eq w3-notify 'bully) | 236 ((eq w3-notify 'bully) |
183 (pop-to-buffer buff) | 237 (pop-to-buffer buff) |
184 (delete-other-windows)) | 238 (delete-other-windows)) |
185 ((eq w3-notify 'semibully) | 239 ((eq w3-notify 'semibully) |
186 (condition-case nil | 240 (switch-to-buffer buff)) |
187 (switch-to-buffer buff) | |
188 (error (message "W3 buffer %s is ready." (buffer-name buff))))) | |
189 ((eq w3-notify 'aggressive) | 241 ((eq w3-notify 'aggressive) |
190 (pop-to-buffer buff)) | 242 (pop-to-buffer buff)) |
191 ((eq w3-notify 'friendly) | 243 ((eq w3-notify 'friendly) |
192 (display-buffer buff 'not-this-window)) | 244 (display-buffer buff 'not-this-window)) |
193 ((eq w3-notify 'polite) | 245 ((eq w3-notify 'polite) |
206 (fmt (cdr-safe (assoc "nametemplate" info)))) ; Template for name | 258 (fmt (cdr-safe (assoc "nametemplate" info)))) ; Template for name |
207 (cond | 259 (cond |
208 (fmt nil) | 260 (fmt nil) |
209 ((cdr-safe (assoc "type" info)) | 261 ((cdr-safe (assoc "type" info)) |
210 (setq fmt (mm-type-to-file (cdr-safe (assoc "type" info)))) | 262 (setq fmt (mm-type-to-file (cdr-safe (assoc "type" info)))) |
211 (if fmt | 263 (if fmt (setq fmt (concat "%s" (car fmt))) |
212 (setq fmt (concat "%s" (car fmt))) | 264 (setq fmt (concat "%s" (url-file-extension url-current-file)))))) |
213 (setq fmt (concat "%s" (url-file-extension | |
214 (url-filename url-current-object))))))) | |
215 (if (null view) | 265 (if (null view) |
216 (setq view 'indented-text-mode)) | 266 (setq view 'indented-text-mode)) |
217 (cond | 267 (cond |
218 ((symbolp view) | 268 ((symbolp view) |
219 (if (not (memq view '(w3-prepare-buffer w3-print w3-source | 269 (if (not (memq view '(w3-prepare-buffer w3-print w3-source |
220 w3-default-local-file | 270 w3-default-local-file |
221 mm-multipart-viewer))) | 271 mm-multipart-viewer))) |
222 (let ((bufnam (url-generate-new-buffer-name | 272 (let ((bufnam (url-generate-new-buffer-name |
223 (file-name-nondirectory | 273 (file-name-nondirectory |
224 (or (url-filename url-current-object) | 274 (or url-current-file "Unknown"))))) |
225 "Unknown"))))) | |
226 (if (string= bufnam "") | 275 (if (string= bufnam "") |
227 (setq bufnam (url-generate-new-buffer-name | 276 (setq bufnam (url-generate-new-buffer-name |
228 (url-view-url t)))) | 277 (url-view-url t)))) |
229 (rename-buffer bufnam) | 278 (rename-buffer bufnam) |
230 ;; Make the URL show in list-buffers output | 279 ;; Make the URL show in list-buffers output |
235 (funcall view) | 284 (funcall view) |
236 (w3-notify-when-ready bufnam)) | 285 (w3-notify-when-ready bufnam)) |
237 (funcall view))) | 286 (funcall view))) |
238 ((stringp view) | 287 ((stringp view) |
239 (let ((fname (url-generate-unique-filename fmt)) | 288 (let ((fname (url-generate-unique-filename fmt)) |
240 (proc nil)) | 289 (proc nil) |
290 (file-coding-system url-mule-no-coding-system)) | |
241 (if (url-file-directly-accessible-p (url-view-url t)) | 291 (if (url-file-directly-accessible-p (url-view-url t)) |
242 (make-symbolic-link (url-filename url-current-object) fname t) | 292 (make-symbolic-link url-current-file fname t) |
243 (mule-write-region-no-coding-system (point-min) (point-max) fname)) | 293 (write-region (point-min) (point-max) fname)) |
244 (if (get-buffer url-working-buffer) | 294 (if (get-buffer url-working-buffer) |
245 (kill-buffer url-working-buffer)) | 295 (kill-buffer url-working-buffer)) |
246 (setq view (mm-viewer-unescape view fname url)) | 296 (setq view (mm-viewer-unescape view fname url)) |
247 (message "Passing to viewer %s " view) | 297 (message "Passing to viewer %s " view) |
248 (setq proc (w3-start-viewer fname view)) | 298 (setq proc (w3-start-viewer fname view)) |
271 nil | 321 nil |
272 (url-remove-compressed-extensions | 322 (url-remove-compressed-extensions |
273 (file-name-nondirectory (url-view-url t))))) | 323 (file-name-nondirectory (url-view-url t))))) |
274 (require-final-newline nil)) | 324 (require-final-newline nil)) |
275 (set-buffer old-buff) | 325 (set-buffer old-buff) |
276 (mule-write-region-no-coding-system (point-min) (point-max) file) | 326 (let ((mc-flag t) |
327 (file-coding-system url-mule-no-coding-system)) | |
328 (write-region (point-min) (point-max) file)) | |
277 (kill-buffer (current-buffer)))) | 329 (kill-buffer (current-buffer)))) |
330 | |
331 (defun w3-build-url (protocol) | |
332 "Build a url for PROTOCOL, return it as a string" | |
333 (interactive (list (cdr (assoc (completing-read | |
334 "Protocol: " | |
335 w3-acceptable-protocols-alist nil t) | |
336 w3-acceptable-protocols-alist)))) | |
337 (let (user host port file) | |
338 (cond | |
339 ((null protocol) (error "Protocol is unknown to me!")) | |
340 ((string= protocol "news") | |
341 (setq host (read-string "Enter news server name, or blank for default: ") | |
342 port (read-string "Enter port number, or blank for default: ") | |
343 file (read-string "Newgroup name or Message-ID: "))) | |
344 ((string= protocol "mailto") (setq file (read-string "E-mail address: "))) | |
345 ((string= protocol "http") | |
346 (setq host (read-string "Enter server name: ") | |
347 port (read-string "Enter port number, or blank for default: ") | |
348 file (read-string "Remote file: ")) | |
349 (and (string= "" port) (setq port nil)) | |
350 (and (string= "" host) (error "Must specify a remote machine!"))) | |
351 ((string= protocol "file") | |
352 (if (funcall url-confirmation-func "Local file?") | |
353 (setq file (read-file-name "Local File: " nil nil t)) | |
354 (setq user (read-string "Login as user (blank=anonymous): ") | |
355 host (read-string "Remote machine name: ")) | |
356 (and (string= user "") (setq user "anonymous")) | |
357 (and (string= host "") (error "Must specify a remote machine!")) | |
358 (setq file (read-file-name "File: " (format "/%s@%s:" user host) | |
359 nil t) | |
360 file (substring file (length (format "/%s@%s:" user host)))))) | |
361 ((or (string= protocol "telnet") | |
362 (string= protocol "tn3270")) | |
363 (setq user (read-string "Login as user (blank=none): ") | |
364 host (read-string "Remote machine name: ") | |
365 port (read-string "Port number (blank=23): ")) | |
366 (and (string= "" port) (setq port nil)) | |
367 (and (string= "" user) (setq user nil)) | |
368 (and (string= "" host) (error "Must specify a host machine!"))) | |
369 ((string= protocol "gopher") | |
370 (setq host (read-string "Enter server name: ") | |
371 port (read-string "Enter port number, or blank for default: ") | |
372 file (read-string "Remote file: ")) | |
373 (and (string= "" port) (setq port nil)) | |
374 (and (string= "" host) (error "Must specify a remote machine!")))) | |
375 (message "%s:%s%s" | |
376 protocol | |
377 (if (null host) "" (concat "//" host | |
378 (if (null port) "" (concat ":" port)))) | |
379 (if (= ?/ (string-to-char file)) file (concat "/" file))))) | |
278 | 380 |
279 ;;;###autoload | 381 ;;;###autoload |
280 (defun w3-open-local (fname) | 382 (defun w3-open-local (fname) |
281 "Find a local file, and interpret it as a hypertext document. | 383 "Find a local file, and interpret it as a hypertext document. |
282 It will prompt for an existing file or directory, and retrieve it as a | 384 It will prompt for an existing file or directory, and retrieve it as a |
283 hypertext document." | 385 hypertext document. If it is a directory, and url-use-hypertext-dired |
386 is non-nil, then an HTML directory listing is created on the fly. | |
387 Otherwise, dired-mode is used to visit the buffer." | |
284 (interactive "FLocal file: ") | 388 (interactive "FLocal file: ") |
285 (setq fname (expand-file-name fname)) | |
286 (if (not w3-setup-done) (w3-do-setup)) | 389 (if (not w3-setup-done) (w3-do-setup)) |
287 (w3-fetch (concat "file:" fname))) | 390 (w3-fetch (concat "file:" fname))) |
288 | 391 |
289 ;;;###autoload | 392 ;;;###autoload |
290 (defun w3-find-file (fname) | 393 (defun w3-find-file (fname) |
291 "Find a local file, and interpret it as a hypertext document. | 394 "Find a local file, and interpret it as a hypertext document. |
292 It will prompt for an existing file or directory, and retrieve it as a | 395 It will prompt for an existing file or directory, and retrieve it as a |
293 hypertext document." | 396 hypertext document. If it is a directory, and url-use-hypertext-dired |
397 is non-nil, then an HTML directory listing is created on the fly. | |
398 Otherwise, dired-mode is used to visit the buffer." | |
294 (interactive "FLocal file: ") | 399 (interactive "FLocal file: ") |
295 (w3-open-local fname)) | 400 (w3-open-local fname)) |
296 | 401 |
297 ;;;###autoload | 402 ;;;###autoload |
298 (defun w3-fetch-other-frame (&optional url) | 403 (defun w3-fetch-other-frame (&optional url) |
316 to disk." | 421 to disk." |
317 (interactive (list (w3-read-url-with-default))) | 422 (interactive (list (w3-read-url-with-default))) |
318 (split-window) | 423 (split-window) |
319 (w3-fetch url)) | 424 (w3-fetch url)) |
320 | 425 |
321 ;; Ripped off from red gnus | |
322 (defun w3-find-etc-directory (package &optional file) | |
323 "Go through the path and find the \".../etc/PACKAGE\" directory. | |
324 If FILE, find the \".../etc/PACKAGE\" file instead." | |
325 (let ((path load-path) | |
326 dir result) | |
327 ;; We try to find the dir by looking at the load path, | |
328 ;; stripping away the last component and adding "etc/". | |
329 (while path | |
330 (if (and (car path) | |
331 (file-exists-p | |
332 (setq dir (concat | |
333 (file-name-directory | |
334 (directory-file-name (car path))) | |
335 "etc/" package | |
336 (if file "" "/")))) | |
337 (or file (file-directory-p dir))) | |
338 (setq result dir | |
339 path nil) | |
340 (setq path (cdr path)))) | |
341 result)) | |
342 | |
343 (defun w3-url-completion-function (string predicate function) | 426 (defun w3-url-completion-function (string predicate function) |
344 (if (not w3-setup-done) (w3-do-setup)) | 427 (if (not w3-setup-done) (w3-do-setup)) |
345 (cond | 428 (cond |
346 ((eq function nil) | 429 ((null function) |
347 (let ((list nil)) | 430 (cond |
348 (cl-maphash (function (lambda (key val) | 431 ((get 'url-gethash 'sysdep-defined-this) |
349 (setq list (cons (cons key val) | 432 ;; Cheat! If we know that these are the sysdep-defined version |
350 list)))) | 433 ;; of hashtables, they are an obarray. |
351 url-global-history-hash-table) | 434 (try-completion string url-global-history-hash-table predicate)) |
352 (try-completion string (nreverse list) predicate))) | 435 ((url-hashtablep url-global-history-hash-table) |
436 (let ((list nil)) | |
437 (url-maphash (function (lambda (key val) | |
438 (setq list (cons (cons (symbol-name key) val) | |
439 list)))) | |
440 url-global-history-hash-table) | |
441 (try-completion string (nreverse list) predicate))) | |
442 (t nil))) | |
353 ((eq function t) | 443 ((eq function t) |
354 (let ((stub (concat "^" (regexp-quote string))) | 444 (cond |
355 (retval nil)) | 445 ((get 'url-gethash 'sysdep-defined-this) |
356 (cl-maphash | 446 ;; Cheat! If we know that these are the sysdep-defined version |
357 (function | 447 ;; of hashtables, they are an obarray. |
358 (lambda (url time) | 448 (all-completions string url-global-history-hash-table predicate)) |
359 (if (string-match stub url) | 449 ((url-hashtablep url-global-history-hash-table) |
360 (setq retval (cons url retval))))) | 450 (let ((stub (concat "^" (regexp-quote string))) |
361 url-global-history-hash-table) | 451 (retval nil)) |
362 retval)) | 452 (url-maphash |
453 (function | |
454 (lambda (url time) | |
455 (setq url (symbol-name url)) | |
456 (if (string-match stub url) | |
457 (setq retval (cons url retval))))) | |
458 url-global-history-hash-table) | |
459 retval)) | |
460 (t nil))) | |
363 ((eq function 'lambda) | 461 ((eq function 'lambda) |
364 (and url-global-history-hash-table | 462 (and (url-hashtablep url-global-history-hash-table) |
365 (cl-gethash string url-global-history-hash-table) | 463 (url-gethash string url-global-history-hash-table) |
366 t)) | 464 t)))) |
367 (t | |
368 (error "w3-url-completion-function very confused.")))) | |
369 | 465 |
370 (defun w3-read-url-with-default () | 466 (defun w3-read-url-with-default () |
371 (url-do-setup) | 467 (url-do-setup) |
372 (let* ((completion-ignore-case t) | 468 (let* ((completion-ignore-case t) |
373 (default | 469 (default |
374 (cond | 470 (if (eq major-mode 'w3-mode) |
375 ((null w3-fetch-with-default) nil) | 471 (if (and current-prefix-arg (w3-view-this-url t)) |
376 ((eq major-mode 'w3-mode) | 472 (w3-view-this-url t) |
377 (or (and current-prefix-arg (w3-view-this-url t)) | 473 (url-view-url t)) |
378 (url-view-url t))) | 474 (url-get-url-at-point))) |
379 ((url-get-url-at-point) | |
380 (url-get-url-at-point)) | |
381 (t "http://www."))) | |
382 (url nil)) | 475 (url nil)) |
476 (if (not default) | |
477 (setq default "http://www.")) | |
383 (setq url | 478 (setq url |
384 (completing-read "URL: " 'w3-url-completion-function | 479 (completing-read "URL: " 'w3-url-completion-function |
385 nil nil default)) | 480 nil nil default)) |
386 (if (string= url "") | 481 (if (string= url "") |
387 (setq url (if (eq major-mode 'w3-mode) | 482 (setq url (if (eq major-mode 'w3-mode) |
390 (url-view-url t)) | 485 (url-view-url t)) |
391 (url-get-url-at-point)))) | 486 (url-get-url-at-point)))) |
392 url)) | 487 url)) |
393 | 488 |
394 ;;;###autoload | 489 ;;;###autoload |
395 (defun w3-fetch (&optional url target) | 490 (defun w3-fetch (&optional url) |
396 "Retrieve a document over the World Wide Web. | 491 "Retrieve a document over the World Wide Web. |
397 Defaults to URL of the current document, if any. | 492 The World Wide Web is a global hypertext system started by CERN in |
398 With prefix argument, use the URL of the hyperlink under point instead." | 493 Switzerland in 1991. |
494 | |
495 The document should be specified by its fully specified | |
496 Uniform Resource Locator. The document will be parsed, printed, or | |
497 passed to an external viewer as appropriate. Variable | |
498 `mm-mime-info' specifies viewers for particular file types." | |
399 (interactive (list (w3-read-url-with-default))) | 499 (interactive (list (w3-read-url-with-default))) |
400 (if (not w3-setup-done) (w3-do-setup)) | 500 (if (not w3-setup-done) (w3-do-setup)) |
401 (if (boundp 'w3-working-buffer) | 501 (if (boundp 'w3-working-buffer) |
402 (setq w3-working-buffer url-working-buffer)) | 502 (setq w3-working-buffer url-working-buffer)) |
403 (if (and (boundp 'command-line-args-left) | 503 (if (and (boundp 'command-line-args-left) |
406 (setq url (car command-line-args-left) | 506 (setq url (car command-line-args-left) |
407 command-line-args-left (cdr command-line-args-left))) | 507 command-line-args-left (cdr command-line-args-left))) |
408 (if (equal url "") (error "No document specified!")) | 508 (if (equal url "") (error "No document specified!")) |
409 ;; legal use for relative URLs ? | 509 ;; legal use for relative URLs ? |
410 (if (string-match "^www:[^/].*" url) | 510 (if (string-match "^www:[^/].*" url) |
411 (setq url (concat (file-name-directory (url-filename | 511 (setq url (concat (file-name-directory url-current-file) |
412 url-current-object)) | |
413 (substring url 4)))) | 512 (substring url 4)))) |
414 ;; In the common case, this is probably cheaper than searching. | 513 ;; In the common case, this is probably cheaper than searching. |
415 (while (= (string-to-char url) ? ) | 514 (while (= (string-to-char url) ? ) |
416 (setq url (substring url 1))) | 515 (setq url (substring url 1))) |
417 (or target (setq target w3-base-target)) | |
418 (if (stringp target) | |
419 (setq target (intern (downcase target)))) | |
420 (and target | |
421 (let ((window-distance (cdr-safe (assq target w3-target-window-distances)))) | |
422 (if (numberp window-distance) | |
423 (other-window window-distance) | |
424 (error "target %S not found." target)))) | |
425 (cond | 516 (cond |
426 ((= (string-to-char url) ?#) | 517 ((= (string-to-char url) ?#) |
427 (w3-relative-link url)) | 518 (w3-relative-link url)) |
428 ((or (and (interactive-p) current-prefix-arg) w3-dump-to-disk) | 519 ((or (and (interactive-p) current-prefix-arg) w3-dump-to-disk) |
429 (w3-download-url url)) | 520 (w3-download-url url)) |
430 (t | 521 (t |
431 (let ((x (url-view-url t)) | 522 (let ((x (url-view-url t)) |
432 (lastbuf (current-buffer)) | 523 (lastbuf (current-buffer)) |
433 (buf (url-buffer-visiting url))) | 524 (buf (url-buffer-visiting url))) |
525 (and x (or (string= "file:nil" x) (string= "" x)) | |
526 (setq x nil)) | |
434 (if (or (not buf) | 527 (if (or (not buf) |
435 (cond | 528 (cond |
436 ((not (equal (downcase (or url-request-method "GET")) "get")) t) | 529 ((not (equal (downcase (or url-request-method "GET")) "get")) t) |
437 ((memq w3-reuse-buffers '(no never reload)) t) | 530 ((memq w3-reuse-buffers '(no never reload)) t) |
438 ((memq w3-reuse-buffers '(yes reuse always)) nil) | 531 ((memq w3-reuse-buffers '(yes reuse always)) nil) |
445 (prin1-to-string w3-reuse-buffers)) | 538 (prin1-to-string w3-reuse-buffers)) |
446 (sit-for 2))) | 539 (sit-for 2))) |
447 (not (funcall url-confirmation-func | 540 (not (funcall url-confirmation-func |
448 (format "Reuse URL in buffer %s? " | 541 (format "Reuse URL in buffer %s? " |
449 (buffer-name buf))))))) | 542 (buffer-name buf))))))) |
450 (let* ((status (url-retrieve url)) | 543 (let ((cached (url-retrieve url))) |
451 (cached (car status)) | |
452 (url-working-buffer (cdr status))) | |
453 (if w3-track-last-buffer | 544 (if w3-track-last-buffer |
454 (setq w3-last-buffer (get-buffer url-working-buffer))) | 545 (setq w3-last-buffer (get-buffer url-working-buffer))) |
455 (if (get-buffer url-working-buffer) | 546 (if (get-buffer url-working-buffer) |
456 (cond | 547 (cond |
457 ((and url-be-asynchronous (not cached)) | 548 ((and url-be-asynchronous (string-match "^http:" url) |
549 (not cached)) | |
458 (save-excursion | 550 (save-excursion |
459 (set-buffer url-working-buffer) | 551 (set-buffer url-working-buffer) |
460 (if x | 552 (if x |
461 (w3-history-push x (url-view-url t))) | 553 (w3-add-urls-to-history x (url-view-url t))) |
462 (setq w3-current-last-buffer lastbuf))) | 554 (setq w3-current-last-buffer lastbuf))) |
463 (t | 555 (t |
464 (w3-history-push x url) | 556 (w3-add-urls-to-history x url) |
465 (w3-sentinel lastbuf))))) | 557 (w3-sentinel lastbuf))))) |
466 (if w3-track-last-buffer | 558 (if w3-track-last-buffer |
467 (setq w3-last-buffer buf)) | 559 (setq w3-last-buffer buf)) |
468 (let ((w3-notify (if (memq w3-notify '(newframe bully | 560 (let ((w3-notify (if (memq w3-notify '(newframe bully |
469 semibully aggressive)) | 561 semibully aggressive)) |
472 (w3-notify-when-ready buf)) | 564 (w3-notify-when-ready buf)) |
473 (if (string-match "#\\(.*\\)" url) | 565 (if (string-match "#\\(.*\\)" url) |
474 (progn | 566 (progn |
475 (push-mark (point) t) | 567 (push-mark (point) t) |
476 (w3-find-specific-link (url-match url 1)))) | 568 (w3-find-specific-link (url-match url 1)))) |
477 (or (w3-maybe-fetch-frames) | 569 (message "Reusing URL. To reload, type %s." |
478 (message "Reusing URL. To reload, type %s." | 570 (substitute-command-keys "\\[w3-reload-document]"))))))) |
479 (substitute-command-keys "\\[w3-reload-document]")))))))) | |
480 | 571 |
481 | 572 |
482 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 573 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
483 ;;; History for forward/back buttons | 574 ;;; History for forward/back buttons |
484 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 575 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
485 (defvar w3-history-stack nil | 576 (defvar w3-node-history nil "History for forward and backward jumping") |
486 "History stack viewing history. | 577 |
487 This is an assoc list, with the oldest items first. | 578 (defun w3-plot-course () |
488 Each element is a cons cell of (url . timeobj), where URL | 579 "Show a map of where the user has been in this session of W3. !!!!NYI!!!" |
489 is the normalized URL (default ports removed, etc), and TIMEOBJ is | 580 (interactive) |
490 a standard Emacs time. See the `current-time' function documentation | 581 (error "Sorry, w3-plot-course is not yet implemented.")) |
491 for information on this format.") | 582 |
492 | 583 (defun w3-forward-in-history () |
493 (defun w3-history-find-url-internal (url) | |
494 "Search in the history list for URL. | |
495 Returns a cons cell, where the car is the 'back' node, and | |
496 the cdr is the 'next' node." | |
497 (let* ((node (assoc url w3-history-stack)) | |
498 (next (cadr (memq node w3-history-stack))) | |
499 (last nil) | |
500 (temp nil) | |
501 (todo w3-history-stack)) | |
502 ;; Last node is a little harder to find without using back links | |
503 (while (and (not last) todo) | |
504 (if (string= (caar todo) url) | |
505 (setq last (or temp 'none)) | |
506 (setq temp (pop todo)))) | |
507 (cons (if (not (symbolp last)) last) | |
508 next))) | |
509 | |
510 (defun w3-history-forward () | |
511 "Go forward in the history from this page" | 584 "Go forward in the history from this page" |
512 (interactive) | 585 (interactive) |
513 (let ((next (cadr (w3-history-find-url-internal (url-view-url t)))) | 586 (let* ((thisurl (url-view-url t)) |
514 (w3-reuse-buffers 'yes)) | 587 (node (assoc (if (string= "" thisurl) (current-buffer) thisurl) |
515 (if next | 588 w3-node-history)) |
516 (w3-fetch next)))) | 589 (url (cdr node)) |
517 | 590 (w3-reuse-buffers 'yes)) |
518 (defun w3-history-backward () | 591 (cond |
592 ((null url) (error "No forward found for %s" thisurl)) | |
593 ((and (bufferp url) (buffer-name url)) | |
594 (switch-to-buffer url)) | |
595 ((stringp url) | |
596 (w3-fetch url)) | |
597 ((bufferp url) | |
598 (setq w3-node-history (delete node w3-node-history)) | |
599 (error "Killed buffer in history, removed.")) | |
600 (t | |
601 (error "Something is very wrong with the history!"))))) | |
602 | |
603 (defun w3-backward-in-history () | |
519 "Go backward in the history from this page" | 604 "Go backward in the history from this page" |
520 (interactive) | 605 (interactive) |
521 (let ((last (caar (w3-history-find-url-internal (url-view-url t)))) | 606 (let* ((thisurl (url-view-url t)) |
522 (w3-reuse-buffers 'yes)) | 607 (node (rassoc (if (string= thisurl "") (current-buffer) thisurl) |
523 (if last | 608 w3-node-history)) |
524 (w3-fetch last)))) | 609 (url (car node)) |
525 | 610 (w3-reuse-buffers 'yes)) |
526 (defun w3-history-push (referer url) | 611 (cond |
612 ((null url) (error "No backward found for %s" thisurl)) | |
613 ((and (bufferp url) (buffer-name url)) | |
614 (switch-to-buffer url)) | |
615 ((stringp url) | |
616 (w3-fetch url)) | |
617 ((bufferp url) | |
618 (setq w3-node-history (delete node w3-node-history)) | |
619 (error "Killed buffer in history, removed.")) | |
620 (t | |
621 (error "Something is very wrong with the history!"))))) | |
622 | |
623 (defun w3-add-urls-to-history (referer url) | |
527 "REFERER is the url we followed this link from. URL is the link we got to." | 624 "REFERER is the url we followed this link from. URL is the link we got to." |
528 (if (not referer) | 625 (let ((node (assoc referer w3-node-history))) |
529 (setq w3-history-stack (list (cons url (current-time)))) | 626 (if node |
530 (let ((node (memq (assoc referer w3-history-stack) w3-history-stack))) | 627 (setcdr node url) |
531 (if node | 628 (setq w3-node-history (cons (cons referer url) w3-node-history))))) |
532 (setcdr node (list (cons url (current-time)))) | |
533 (setq w3-history-stack (append w3-history-stack | |
534 (list | |
535 (cons url (current-time))))))))) | |
536 | |
537 (defalias 'w3-add-urls-to-history 'w3-history-push) | |
538 (defalias 'w3-backward-in-history 'w3-history-backward) | |
539 (defalias 'w3-forward-in-history 'w3-history-forward) | |
540 | 629 |
541 | 630 |
542 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 631 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
543 ;;; Miscellaneous functions | 632 ;;; Miscellaneous functions |
544 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 633 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
587 (save-excursion | 676 (save-excursion |
588 (set-buffer buff) | 677 (set-buffer buff) |
589 (let* ((url (url-view-url t)) | 678 (let* ((url (url-view-url t)) |
590 (cur-links w3-current-links) | 679 (cur-links w3-current-links) |
591 (title (buffer-name)) | 680 (title (buffer-name)) |
592 (case-fold-search t) | |
593 (possible-lastmod (save-excursion | |
594 (goto-char (point-min)) | |
595 (if (re-search-forward "^Last modified:\\(.*\\)" nil t) | |
596 (buffer-substring (match-beginning 1) | |
597 (match-end 1))))) | |
598 (attributes (url-file-attributes url)) | |
599 (lastmod (or (cdr-safe (assoc "last-modified" | 681 (lastmod (or (cdr-safe (assoc "last-modified" |
600 url-current-mime-headers)) | 682 url-current-mime-headers)) |
601 (nth 5 attributes))) | 683 (and (member url-current-type '("file" "ftp")) |
602 (hdrs url-current-mime-headers) | 684 (nth 5 (url-file-attributes url))))) |
603 (size (or (cdr (assoc "content-length" url-current-mime-headers)) | 685 (hdrs url-current-mime-headers)) |
604 (buffer-size))) | |
605 (info w3-current-metainfo)) | |
606 (set-buffer (get-buffer-create url-working-buffer)) | 686 (set-buffer (get-buffer-create url-working-buffer)) |
607 (setq url-current-can-be-cached nil) | 687 (setq url-current-can-be-cached nil |
688 url-current-type "about" | |
689 url-current-file "document") | |
608 (erase-buffer) | 690 (erase-buffer) |
609 (cond | 691 (cond |
610 ((stringp lastmod) nil) | 692 ((stringp lastmod) nil) |
611 ((equal '(0 . 0) lastmod) (setq lastmod possible-lastmod)) | 693 ((equal '(0 . 0) lastmod) (setq lastmod nil)) |
612 ((consp lastmod) (setq lastmod (current-time-string lastmod))) | 694 ((consp lastmod) (setq lastmod (current-time-string lastmod))) |
613 (t (setq lastmod possible-lastmod))) | 695 (t (setq lastmod nil))) |
614 (insert "<html>\n" | 696 (insert "<html>\n" |
615 " <head>\n" | 697 " <head>\n" |
616 " <title>Document Information</title>\n" | 698 " <title>Document Information</title>\n" |
617 " </head>\n" | 699 " </head>\n" |
618 " <body\n" | 700 " <body\n" |
619 " <table border>\n" | 701 " <h1 align=\"center\">Document Information</h1>\n" |
620 " <tr><th colspan=2>Document Information</th></tr>\n" | 702 " <hr>\n" |
621 " <tr><td>Title:</td><td>" title "</td></tr>\n" | 703 " <pre>\n" |
622 " <tr><td>Location:</td><td>" url "</td></tr>\n" | 704 " Title: " title "\n" |
623 " <tr><td>Size:</td><td>" (url-pretty-length | 705 " Location: " url "\n" |
624 (if (stringp size) | 706 " Last Modified: " (or lastmod "None Given") "\n" |
625 (string-to-int size) | 707 " </pre>\n") |
626 size)) "</td></tr>\n" | |
627 " <tr><td>Last Modified:</td><td>" (or lastmod "None Given") | |
628 "</td></tr>\n") | |
629 (if hdrs | 708 (if hdrs |
630 (let* ((maxlength (car (sort (mapcar (function (lambda (x) | 709 (let* ((maxlength (car (sort (mapcar (function (lambda (x) |
631 (length (car x)))) | 710 (length (car x)))) |
632 hdrs) | 711 hdrs) |
633 '>))) | 712 '>))) |
634 (fmtstring (format " <tr><td align=right>%%%ds:</td><td>%%s</td></tr>" maxlength))) | 713 (fmtstring (format "%%%ds: %%s" maxlength))) |
635 (insert " <tr><th>MetaInformation</th></tr>\n" | 714 (insert " <hr label=\" MetaInformation \" textalign=\"left\">\n" |
715 " <pre>\n" | |
636 (mapconcat | 716 (mapconcat |
637 (function | 717 (function |
638 (lambda (x) | 718 (lambda (x) |
639 (if (/= (length (car x)) 0) | 719 (if (/= (length (car x)) 0) |
640 (format fmtstring | 720 (format fmtstring |
643 (int-to-string (cdr x)) | 723 (int-to-string (cdr x)) |
644 (cdr x)))))) | 724 (cdr x)))))) |
645 (sort hdrs | 725 (sort hdrs |
646 (function | 726 (function |
647 (lambda (x y) (string-lessp (car x) (car y))))) | 727 (lambda (x y) (string-lessp (car x) (car y))))) |
648 "\n")))) | 728 "\n") |
649 | 729 " </pre>\n"))) |
650 ;; FIXME!!! Need to reimplement showing rel/rev links for the new | 730 (if cur-links |
651 ;; storage format. | 731 (while cur-links |
652 | 732 (let* ((tmp (car cur-links)) |
653 (if info | 733 (label (car tmp)) |
654 (let* ((maxlength (car (sort (mapcar (function (lambda (x) | 734 (nodes (cdr tmp)) |
655 (length (car x)))) | 735 (links nil) |
656 info) | 736 (maxlength (car (sort (mapcar |
657 '>))) | 737 (function (lambda (x) |
658 (fmtstring (format " <tr><td>%%%ds:</td><td>%%s</td></tr>" maxlength))) | 738 (length (car x)))) |
659 (insert " <tr><th>Miscellaneous Variables</th></tr>\n") | 739 nodes) |
660 (while info | 740 '>))) |
661 (insert (format fmtstring (capitalize (caar info)) | 741 (fmtstring (format "%%%ds: %%s" maxlength))) |
662 (cdar info)) "\n") | 742 (insert " \n" |
663 (setq info (cdr info)) | 743 " <hr width=\"50%\" label=\" " |
664 ) | 744 label " \" align=\"left\" textalign=\"left\">\n" |
665 ) | 745 " <pre>\n") |
666 ) | 746 (while nodes |
667 (insert " </table>\n" | 747 (setq label (car (car nodes)) |
668 " </body>\n" | 748 links (cdr (car nodes)) |
749 nodes (cdr nodes)) | |
750 (while links | |
751 (insert (format " %15s -- <a href=\"%s\">%s</a>\n" | |
752 label (car links) (car links))) | |
753 (setq links (cdr links) | |
754 label ""))) | |
755 (insert " </pre>\n")) | |
756 (setq cur-links (cdr cur-links)))) | |
757 (insert " </body>\n" | |
669 "</html>\n"))))) | 758 "</html>\n"))))) |
670 | 759 |
671 (defun w3-truncate-menu-item (string) | 760 (defun w3-truncate-menu-item (string) |
672 (if (<= (length string) w3-max-menu-width) | 761 (if (<= (length string) w3-max-menu-width) |
673 string | 762 string |
674 (concat (substring string 0 w3-max-menu-width) "$"))) | 763 (concat (substring string 0 w3-max-menu-width) "$"))) |
764 | |
765 (defun w3-use-starting-documents () | |
766 "Use the list of predefined starting documents from w3-starting-documents" | |
767 (interactive) | |
768 (let ((w3-hotlist w3-starting-documents)) | |
769 (w3-use-hotlist))) | |
770 | |
771 (defun w3-show-starting-documents () | |
772 "Show the list of predefined starting documents from w3-starting-documents" | |
773 (interactive) | |
774 (if (not w3-setup-done) (w3-do-setup)) | |
775 (w3-fetch "www://auto/starting-points")) | |
675 | 776 |
676 (defun w3-insert-formatted-url (p) | 777 (defun w3-insert-formatted-url (p) |
677 "Insert a formatted url into a buffer. With prefix arg, insert the url | 778 "Insert a formatted url into a buffer. With prefix arg, insert the url |
678 under point." | 779 under point." |
679 (interactive "P") | 780 (interactive "P") |
680 (let (buff str) | 781 (let (buff str) |
681 (cond | 782 (cond |
682 (p | 783 (p |
683 (setq p (widget-at (point))) | 784 (setq p (widget-at (point))) |
684 (or p (error "No url under point")) | 785 (or p (error "No url under point")) |
685 (setq str (format "<a href=\"%s\">%s</a>" (widget-get p 'href) | 786 (setq str (format "<A HREF=\"%s\">%s</A>" (widget-get p 'href) |
686 (read-string "Link text: " | 787 (read-string "Link text: " |
687 (buffer-substring | 788 (buffer-substring |
688 (widget-get p :from) | 789 (widget-get p :from) |
689 (widget-get p :to)))))) | 790 (widget-get p :to)))))) |
690 (t | 791 (t |
691 (setq str (format "<a href=\"%s\">%s</a>" (url-view-url t) | 792 (setq str (format "<A HREF=\"%s\">%s</A>" (url-view-url t) |
692 (read-string "Link text: " (buffer-name)))))) | 793 (read-string "Link text: " (buffer-name)))))) |
693 (setq buff (read-buffer "Insert into buffer: " nil t)) | 794 (setq buff (read-buffer "Insert into buffer: " nil t)) |
694 (if buff | 795 (if buff |
695 (save-excursion | 796 (save-excursion |
696 (set-buffer buff) | 797 (set-buffer buff) |
713 (if (widget-at (point)) | 814 (if (widget-at (point)) |
714 (widget-button-press (point)))) | 815 (widget-button-press (point)))) |
715 | 816 |
716 (defun w3-widget-button-click (e) | 817 (defun w3-widget-button-click (e) |
717 (interactive "@e") | 818 (interactive "@e") |
718 (cond | 819 (if (widget-at (event-point e)) |
719 ((and (event-point e) | 820 (widget-button-click e))) |
720 (widget-at (event-point e))) | |
721 (widget-button-click e)) | |
722 ((and (fboundp 'event-glyph) | |
723 (event-glyph e) | |
724 (glyph-property (event-glyph e) 'widget)) | |
725 (widget-button-click e)))) | |
726 | 821 |
727 (defun w3-breakup-menu (menu-desc max-len) | 822 (defun w3-breakup-menu (menu-desc max-len) |
728 (if (> (length menu-desc) max-len) | 823 (if (> (length menu-desc) max-len) |
729 (cons (cons "More..." (w3-first-n-items menu-desc max-len)) | 824 (cons (cons "More..." (w3-first-n-items menu-desc max-len)) |
730 (w3-breakup-menu (nthcdr max-len menu-desc) max-len)) | 825 (w3-breakup-menu (nthcdr max-len menu-desc) max-len)) |
768 "Follow the URL under PT, defaults to link under (point)" | 863 "Follow the URL under PT, defaults to link under (point)" |
769 (interactive "d") | 864 (interactive "d") |
770 (let ((url (url-get-url-at-point pt))) | 865 (let ((url (url-get-url-at-point pt))) |
771 (and url (w3-fetch url)))) | 866 (and url (w3-fetch url)))) |
772 | 867 |
868 ;;;###autoload | |
869 (defun w3-batch-fetch () | |
870 "Fetch all the URLs on the command line and save them to files in | |
871 the current directory. The first argument after the -f w3-batch-fetch | |
872 on the command line should be a string specifying how to save the | |
873 information retrieved. If it is \"html\", then the page will be | |
874 unformatted when it is written to disk. If it is \"text\", then the | |
875 page will be formatted before it is written to disk. If it is | |
876 \"binary\" it will not mess with the file extensions, and just save | |
877 the data in raw binary format. If none of those, the default is | |
878 \"text\", and the first argument is treated as a normal URL." | |
879 (if (not w3-setup-done) (w3-do-setup)) | |
880 (if (not noninteractive) | |
881 (error "`w3-batch-fetch' is to be used only with -batch")) | |
882 (let ((fname "") | |
883 (curname "") | |
884 (x 0) | |
885 (args command-line-args-left) | |
886 (w3-strict-width 80) | |
887 (w3-delimit-emphasis nil) | |
888 (w3-delimit-links nil) | |
889 (retrieval-function 'w3-fetch) | |
890 (file-format "text") | |
891 (header "") | |
892 (file-extn ".txt")) | |
893 (setq file-format (downcase (car args))) | |
894 (cond | |
895 ((string= file-format "html") | |
896 (message "Saving all text as raw HTML...") | |
897 (setq retrieval-function 'url-retrieve | |
898 file-extn ".html" | |
899 header "<BASE HREF=\"%s\">" | |
900 args (cdr args))) | |
901 ((string= file-format "binary") | |
902 (message "Saving as raw binary...") | |
903 (setq retrieval-function 'url-retrieve | |
904 file-extn "" | |
905 args (cdr args))) | |
906 ((string= file-format "text") | |
907 (setq header "Text from: %s\n---------------\n") | |
908 (message "Saving all text as formatted...") | |
909 (setq args (cdr args))) | |
910 (t | |
911 (setq header "Text from: %s\n---------------\n") | |
912 (message "Going with default, saving all text as formatted..."))) | |
913 (while args | |
914 (funcall retrieval-function (car args)) | |
915 (goto-char (point-min)) | |
916 (if buffer-read-only (toggle-read-only)) | |
917 (insert (format header (car args))) | |
918 (setq fname (url-basepath url-current-file t)) | |
919 (if (string= file-extn "") nil | |
920 (setq fname (url-file-extension fname t))) | |
921 (if (string= (url-strip-leading-spaces fname) "") | |
922 (setq fname "root")) | |
923 (setq curname fname) | |
924 (while (file-exists-p (concat curname file-extn)) | |
925 (setq curname (concat fname x) | |
926 x (1+ x))) | |
927 (setq fname (concat curname file-extn)) | |
928 (write-region (point-min) (point-max) fname) | |
929 (setq args (cdr args))))) | |
930 | |
773 (defun w3-fix-spaces (x) | 931 (defun w3-fix-spaces (x) |
774 "Remove spaces/tabs at the beginning of a string, | 932 "Remove spaces/tabs at the beginning of a string, |
775 and convert newlines into spaces." | 933 and convert newlines into spaces." |
776 (url-convert-newlines-to-spaces | 934 (url-convert-newlines-to-spaces |
777 (url-strip-leading-spaces | 935 (url-strip-leading-spaces |
782 (interactive) | 940 (interactive) |
783 (setq w3-setup-done nil | 941 (setq w3-setup-done nil |
784 url-setup-done nil | 942 url-setup-done nil |
785 w3-hotlist nil | 943 w3-hotlist nil |
786 url-mime-accept-string nil) | 944 url-mime-accept-string nil) |
787 (let ((x '(w3 mule-sysdp w3-e19 mm url w3-xemac w3-toolbar font))) | 945 (let ((x '(w3 w3-mule w3-e19 w3-xem20 mm url w3-xemac w3-toolbar font))) |
788 (while x | 946 (while x |
789 (setq features (delq (car x) features) | 947 (setq features (delq (car x) features) |
790 x (cdr x))) | 948 x (cdr x))) |
791 (require 'w3)) | 949 (require 'w3)) |
792 (w3-do-setup) | 950 (w3-do-setup) |
796 (defun w3-source-document-at-point () | 954 (defun w3-source-document-at-point () |
797 "View source to the document pointed at by link under point" | 955 "View source to the document pointed at by link under point" |
798 (interactive) | 956 (interactive) |
799 (w3-source-document t)) | 957 (w3-source-document t)) |
800 | 958 |
959 (defun w3-my-safe-copy-face (old new locale) | |
960 (let ((fore (face-foreground old)) | |
961 (back (face-background old)) | |
962 (bpxm (face-background-pixmap old)) | |
963 (font (face-font old)) | |
964 (font-spec (get old 'font-specification))) | |
965 (if (color-specifier-p fore) | |
966 (setq fore (color-name fore))) | |
967 (if (color-specifier-p back) | |
968 (setq back (color-name back))) | |
969 (if (font-specifier-p font) | |
970 (setq font (font-name font))) | |
971 (and fore (set-face-foreground new fore locale)) | |
972 (and back (set-face-background new back locale)) | |
973 (and bpxm (set-face-background-pixmap new bpxm locale)) | |
974 (and (or font-spec font) (set-face-font new (or font-spec font) locale)) | |
975 new)) | |
976 | |
801 (defun w3-source-document (under) | 977 (defun w3-source-document (under) |
802 "View this document's source" | 978 "View this document's source" |
803 (interactive "P") | 979 (interactive "P") |
804 (let* ((url (if under (w3-view-this-url) (url-view-url t))) | 980 (let* ((url (if under (w3-view-this-url) (url-view-url t))) |
981 (fil (if under nil url-current-file)) | |
982 (tag '$html-source) ; For the stylesheet info | |
983 (args nil) ; For the stylesheet info | |
984 (face nil) ; For the stylesheet info | |
805 (src | 985 (src |
806 (cond | 986 (cond |
807 ((null url) | 987 ((or (null url) (string= url "file:nil")) |
808 (error "No URL found!")) | 988 (error "Not a w3 buffer!")) |
809 ((and under (null url)) (error "No link at point!")) | 989 ((and under (null url)) (error "No link at point!")) |
810 ((and (not under) (equal url-current-mime-type "text/plain")) | 990 ((and (not under) (equal url-current-mime-type "text/plain")) |
811 (buffer-string)) | 991 (buffer-string)) |
812 ((and (not under) w3-current-source) w3-current-source) | 992 ((and (not under) w3-current-source) w3-current-source) |
813 (t | 993 (t |
814 (prog2 | 994 (prog2 |
815 (url-retrieve url) | 995 (url-retrieve url) |
816 (buffer-string) | 996 (buffer-string) |
997 (setq fil (or fil url-current-file)) | |
817 (kill-buffer (current-buffer)))))) | 998 (kill-buffer (current-buffer)))))) |
818 (tmp (url-generate-new-buffer-name url))) | 999 (tmp (url-generate-new-buffer-name url))) |
819 (if (and url (get-buffer url)) | 1000 (if (and url (get-buffer url)) |
820 (cond | 1001 (cond |
821 ((memq w3-reuse-buffers '(no never reload)) | 1002 ((memq w3-reuse-buffers '(no never reload)) |
825 (setq url nil)) | 1006 (setq url nil)) |
826 ((funcall url-confirmation-func | 1007 ((funcall url-confirmation-func |
827 (concat "Source for " url " found, reuse? ")) | 1008 (concat "Source for " url " found, reuse? ")) |
828 (w3-notify-when-ready (get-buffer url))))) | 1009 (w3-notify-when-ready (get-buffer url))))) |
829 (if (not url) nil | 1010 (if (not url) nil |
1011 (setq face (and w3-current-stylesheet (cdr (w3-face-for-element)))) | |
830 (set-buffer (get-buffer-create tmp)) | 1012 (set-buffer (get-buffer-create tmp)) |
831 (insert src) | 1013 (insert src) |
1014 (put-text-property (point-min) (point-max) 'face face) | |
832 (put-text-property (point-min) (point-max) 'w3-base url) | 1015 (put-text-property (point-min) (point-max) 'w3-base url) |
833 (goto-char (point-min)) | 1016 (goto-char (point-min)) |
834 (setq buffer-file-truename url | 1017 (setq buffer-file-truename nil |
835 buffer-file-name url) | 1018 buffer-file-name nil) |
836 ;; Null filename bugs `set-auto-mode' in Mule ... | 1019 ;; Null filename bugs `set-auto-mode' in Mule ... |
837 (condition-case () | 1020 (condition-case () |
838 (set-auto-mode) | 1021 (set-auto-mode) |
839 (error nil)) | 1022 (error nil)) |
840 (setq buffer-file-truename nil | |
841 buffer-file-name nil) | |
842 (buffer-enable-undo) | 1023 (buffer-enable-undo) |
843 (set-buffer-modified-p nil) | 1024 (set-buffer-modified-p nil) |
844 (w3-notify-when-ready (get-buffer tmp)))) | 1025 (w3-notify-when-ready (get-buffer tmp)))) |
845 (run-hooks 'w3-source-file-hook)) | 1026 (run-hooks 'w3-source-file-hook)) |
846 | 1027 |
860 ("Formatted Text") | 1041 ("Formatted Text") |
861 ("PostScript") | 1042 ("PostScript") |
862 ("LaTeX Source") | 1043 ("LaTeX Source") |
863 ) | 1044 ) |
864 nil t))) | 1045 nil t))) |
865 (case-fold-search t) | |
866 (url (cond | 1046 (url (cond |
867 ((stringp under) under) | 1047 ((stringp under) under) |
868 (under (w3-view-this-url t)) | 1048 (under (w3-view-this-url t)) |
869 (t (url-view-url t)))) | 1049 (t (url-view-url t)))) |
870 (content-type "text/plain; charset=iso-8859-1") | 1050 (content-type "text/plain; charset=iso-8859-1") |
887 (setq content-type "application/postscript") | 1067 (setq content-type "application/postscript") |
888 (w3-fetch url) | 1068 (w3-fetch url) |
889 (let ((ps-spool-buffer-name " *w3-temp*")) | 1069 (let ((ps-spool-buffer-name " *w3-temp*")) |
890 (if (get-buffer ps-spool-buffer-name) | 1070 (if (get-buffer ps-spool-buffer-name) |
891 (kill-buffer ps-spool-buffer-name)) | 1071 (kill-buffer ps-spool-buffer-name)) |
892 (ps-spool-buffer-with-faces) | 1072 (w3-print-with-ps-print (current-buffer) |
1073 'ps-spool-buffer-with-faces) | |
893 (set-buffer ps-spool-buffer-name))) | 1074 (set-buffer ps-spool-buffer-name))) |
894 ((equal "PostScript" format) | 1075 ((equal "PostScript" format) |
895 (let ((ps-spool-buffer-name " *w3-temp*")) | 1076 (let ((ps-spool-buffer-name " *w3-temp*")) |
896 (if (get-buffer ps-spool-buffer-name) | 1077 (if (get-buffer ps-spool-buffer-name) |
897 (kill-buffer ps-spool-buffer-name)) | 1078 (kill-buffer ps-spool-buffer-name)) |
898 (setq content-type "application/postscript") | 1079 (setq content-type "application/postscript") |
899 (ps-spool-buffer-with-faces) | 1080 (w3-print-with-ps-print (current-buffer) |
1081 'ps-spool-buffer-with-faces) | |
900 (set-buffer ps-spool-buffer-name))) | 1082 (set-buffer ps-spool-buffer-name))) |
901 ((and under (equal "Formatted Text" format)) | 1083 ((and under (equal "Formatted Text" format)) |
902 (setq content-type "text/plain; charset=iso-8859-1") | 1084 (setq content-type "text/plain; charset=iso-8859-1") |
903 (w3-fetch url)) | 1085 (w3-fetch url)) |
904 ((equal "Formatted Text" format) | 1086 ((equal "Formatted Text" format) |
907 (let ((old-asynch url-be-asynchronous)) | 1089 (let ((old-asynch url-be-asynchronous)) |
908 (setq content-type "application/x-latex; charset=iso-8859-1") | 1090 (setq content-type "application/x-latex; charset=iso-8859-1") |
909 (setq-default url-be-asynchronous nil) | 1091 (setq-default url-be-asynchronous nil) |
910 (url-retrieve url) | 1092 (url-retrieve url) |
911 (setq-default url-be-asynchronous old-asynch) | 1093 (setq-default url-be-asynchronous old-asynch) |
912 (w3-parse-tree-to-latex (w3-parse-buffer (current-buffer)) | 1094 (w3-parse-tree-to-latex (w3-parse-buffer (current-buffer) t) |
913 url))) | 1095 url))) |
914 ((equal "LaTeX Source" format) | 1096 ((equal "LaTeX Source" format) |
915 (setq content-type "application/x-latex; charset=iso-8859-1") | 1097 (setq content-type "application/x-latex; charset=iso-8859-1") |
916 (w3-parse-tree-to-latex w3-current-parse url))) | 1098 (w3-parse-tree-to-latex w3-current-parse url))) |
917 (buffer-string)))) | 1099 (buffer-string)))) |
918 (funcall url-mail-command) | 1100 (cond |
1101 ((and w3-mutable-windows (fboundp w3-mail-other-window-command)) | |
1102 (funcall w3-mail-other-window-command)) | |
1103 ((fboundp w3-mail-command) | |
1104 (funcall w3-mail-command)) | |
1105 (w3-mutable-windows (mail-other-window)) | |
1106 (t (mail))) | |
919 (mail-subject) | 1107 (mail-subject) |
920 (if (and (boundp 'mime/editor-mode-flag) mime/editor-mode-flag) | 1108 (insert format " from URL " url "\n" |
921 (insert format " from <URL: " url ">") | 1109 "Mime-Version: 1.0\n" |
922 (insert format " from <URL: " url ">\n" | 1110 "Content-transfer-encoding: 8bit\n" |
923 "Mime-Version: 1.0\n" | 1111 "Content-type: " content-type) |
924 "Content-transfer-encoding: 8bit\n" | 1112 |
925 "Content-type: " content-type)) | |
926 (re-search-forward mail-header-separator nil) | 1113 (re-search-forward mail-header-separator nil) |
927 (forward-char 1) | 1114 (forward-char 1) |
928 (if (and (boundp 'mime/editor-mode-flag) mime/editor-mode-flag) | 1115 (insert (if (equal "HTML Source" format) |
929 (insert (format mime-tag-format content-type) "\n")) | 1116 (format "<BASE HREF=\"%s\">" url) "") |
930 (save-excursion | 1117 str) |
931 (insert str)) | |
932 (cond ((equal "HTML Source" format) | |
933 (if (or (search-forward "<head>" nil t) | |
934 (search-forward "<html>" nil t)) | |
935 (insert "\n")) | |
936 (insert (format "<base href=\"%s\">" url)))) | |
937 (mail-to))) | 1118 (mail-to))) |
938 | 1119 |
939 (defun w3-internal-use-history (hist-item) | 1120 (defun w3-internal-use-history (hist-item) |
940 ;; Go to the link in the history | 1121 ;; Go to the link in the history |
941 (let ((url (nth 0 hist-item)) | 1122 (let ((url (nth 0 hist-item)) |
983 (defun w3-build-continuation () | 1164 (defun w3-build-continuation () |
984 ;; Build a series of functions to be run on this file | 1165 ;; Build a series of functions to be run on this file |
985 (save-excursion | 1166 (save-excursion |
986 (set-buffer url-working-buffer) | 1167 (set-buffer url-working-buffer) |
987 (let ((cont w3-default-continuation) | 1168 (let ((cont w3-default-continuation) |
988 (extn (url-file-extension | 1169 (extn (url-file-extension url-current-file))) |
989 (url-filename url-current-object)))) | |
990 (if (assoc extn url-uncompressor-alist) | 1170 (if (assoc extn url-uncompressor-alist) |
991 (setq extn (url-file-extension | 1171 (setq extn (url-file-extension |
992 (substring (url-filename url-current-object) | 1172 (substring url-current-file 0 (- (length extn)))))) |
993 0 (- (length extn)))))) | |
994 (if w3-source | 1173 (if w3-source |
995 (setq url-current-mime-viewer '(("viewer" . w3-source)))) | 1174 (setq url-current-mime-viewer '(("viewer" . w3-source)))) |
996 (if (not url-current-mime-viewer) | 1175 (if (not url-current-mime-viewer) |
997 (setq url-current-mime-viewer | 1176 (setq url-current-mime-viewer |
998 (mm-mime-info (or url-current-mime-type | 1177 (mm-mime-info (or url-current-mime-type |
999 (mm-extension-to-mime extn)) nil 5))) | 1178 (mm-extension-to-mime extn)) nil 5))) |
1000 (if url-current-mime-viewer | 1179 (if url-current-mime-viewer |
1001 (setq cont (append cont '(w3-pass-to-viewer))) | 1180 (setq cont (append cont '(w3-pass-to-viewer))) |
1002 (setq cont (append cont (list 'w3-prepare-buffer)))) | 1181 (setq cont (append cont (list w3-default-action)))) |
1003 cont))) | 1182 cont))) |
1004 | 1183 |
1005 (defun w3-use-links () | 1184 (defun w3-use-links () |
1006 "Select one of the <LINK> tags from this document and fetch it." | 1185 "Select one of the <LINK> tags from this document and fetch it." |
1007 (interactive) | 1186 (interactive) |
1011 | 1190 |
1012 (defun w3-find-this-file () | 1191 (defun w3-find-this-file () |
1013 "Do a find-file on the currently viewed html document if it is a file: or | 1192 "Do a find-file on the currently viewed html document if it is a file: or |
1014 ftp: reference" | 1193 ftp: reference" |
1015 (interactive) | 1194 (interactive) |
1016 (or url-current-object | 1195 (cond |
1017 (error "Not a URL-based buffer")) | 1196 ((and (or (null url-current-type) (equal url-current-type "file")) |
1018 (let ((type (url-type url-current-object))) | 1197 (eq major-mode 'w3-mode)) |
1019 (cond | 1198 (if w3-mutable-windows |
1020 ((equal type "file") | 1199 (find-file-other-window url-current-file) |
1021 (find-file (url-filename url-current-object))) | 1200 (find-file url-current-file))) |
1022 ((equal type "ftp") | 1201 ((equal url-current-type "ftp") |
1202 (if w3-mutable-windows | |
1203 (find-file-other-window | |
1204 (format "/%s@%s:%s" url-current-user url-current-server | |
1205 url-current-file)) | |
1023 (find-file | 1206 (find-file |
1024 (format "/%s@%s:%s" | 1207 (format "/%s@%s:%s" url-current-user url-current-server |
1025 (url-user url-current-object) | 1208 url-current-file)))) |
1026 (url-host url-current-object) | 1209 (t (message "Sorry, I can't get that file so you can alter it.")))) |
1027 (url-filename url-current-object)))) | |
1028 (t (message "Sorry, I can't get that file so you can alter it."))))) | |
1029 | 1210 |
1030 (defun w3-insert-this-url (pref-arg) | 1211 (defun w3-insert-this-url (pref-arg) |
1031 "Insert the current url in another buffer, with prefix ARG, | 1212 "Insert the current url in another buffer, with prefix ARG, |
1032 insert URL under point" | 1213 insert URL under point" |
1033 (interactive "P") | 1214 (interactive "P") |
1089 specify formatting for text. More information on HTML can be found at | 1270 specify formatting for text. More information on HTML can be found at |
1090 ftp.w3.org:/pub/www/doc." | 1271 ftp.w3.org:/pub/www/doc." |
1091 (interactive) | 1272 (interactive) |
1092 (w3-fetch (concat "www://preview/" (buffer-name)))) | 1273 (w3-fetch (concat "www://preview/" (buffer-name)))) |
1093 | 1274 |
1275 (defun w3-edit-source () | |
1276 "Edit the html document just retrieved" | |
1277 (set-buffer url-working-buffer) | |
1278 (let ((ttl (format "Editing %s Annotation: %s" | |
1279 (cond | |
1280 ((eq w3-editing-annotation 'group) "Group") | |
1281 ((eq w3-editing-annotation 'personal) "Personal") | |
1282 (t "Unknown")) | |
1283 (url-basepath url-current-file t))) | |
1284 (str (buffer-string))) | |
1285 (set-buffer (get-buffer-create ttl)) | |
1286 (insert str) | |
1287 (kill-buffer url-working-buffer))) | |
1288 | |
1094 (defun w3-source () | 1289 (defun w3-source () |
1095 "Show the source of a file" | 1290 "Show the source of a file" |
1096 (let ((tmp (buffer-name (generate-new-buffer "Document Source")))) | 1291 (let ((tmp (buffer-name (generate-new-buffer "Document Source")))) |
1097 (set-buffer url-working-buffer) | 1292 (set-buffer url-working-buffer) |
1098 (kill-buffer tmp) | 1293 (kill-buffer tmp) |
1102 (setq list-buffers-directory (url-view-url t)) | 1297 (setq list-buffers-directory (url-view-url t)) |
1103 (set-buffer-modified-p nil) | 1298 (set-buffer-modified-p nil) |
1104 (buffer-enable-undo) | 1299 (buffer-enable-undo) |
1105 (w3-notify-when-ready (get-buffer tmp)))) | 1300 (w3-notify-when-ready (get-buffer tmp)))) |
1106 | 1301 |
1107 (defvar w3-mime-list-for-code-conversion | |
1108 '("text/plain" "text/html") | |
1109 "List of MIME types that require Mules' code conversion.") | |
1110 | |
1111 (defun w3-convert-code-for-mule (mmtype) | |
1112 "Convert current data into the appropriate coding system" | |
1113 (and (or (not mmtype) | |
1114 (member mmtype w3-mime-list-for-code-conversion)) | |
1115 (mule-code-convert-region | |
1116 (point-min) (point-max) | |
1117 (mule-detect-coding-version (point-min) (point-max))))) | |
1118 | |
1119 (defun w3-sentinel (&optional proc string) | 1302 (defun w3-sentinel (&optional proc string) |
1120 (set-buffer url-working-buffer) | 1303 (set-buffer url-working-buffer) |
1121 (if (or (stringp proc) | 1304 (if (or (stringp proc) |
1122 (bufferp proc)) (setq w3-current-last-buffer proc)) | 1305 (bufferp proc)) (setq w3-current-last-buffer proc)) |
1123 (remove-hook 'after-change-functions 'url-after-change-function) | 1306 (if (boundp 'after-change-functions) |
1307 (remove-hook 'after-change-functions 'url-after-change-function)) | |
1124 (if url-be-asynchronous | 1308 (if url-be-asynchronous |
1125 (progn | 1309 (progn |
1126 (url-clean-text) | 1310 (url-clean-text) |
1127 (cond | 1311 (cond |
1128 ((not (get-buffer url-working-buffer)) nil) | 1312 ((not (get-buffer url-working-buffer)) nil) |
1129 ((url-mime-response-p) (url-parse-mime-headers))) | 1313 ((url-mime-response-p) (url-parse-mime-headers))) |
1130 (if (not url-current-mime-type) | 1314 (if (not url-current-mime-type) |
1131 (setq url-current-mime-type (or (mm-extension-to-mime | 1315 (setq url-current-mime-type (or (mm-extension-to-mime |
1132 (url-file-extension | 1316 (url-file-extension |
1133 (url-filename | 1317 url-current-file)) |
1134 url-current-object))) | |
1135 "text/html"))))) | 1318 "text/html"))))) |
1136 (if (not (string-match "^www:" (or (url-view-url t) ""))) | |
1137 (w3-convert-code-for-mule url-current-mime-type)) | |
1138 | |
1139 (let ((x (w3-build-continuation)) | 1319 (let ((x (w3-build-continuation)) |
1140 (url (url-view-url t))) | 1320 (done-mule-conversion nil)) |
1141 (while x | 1321 (while x |
1142 (funcall (pop x))))) | 1322 (if (and (featurep 'mule) (not (eq 'url-uncompress (car x))) |
1323 (not done-mule-conversion)) | |
1324 (progn | |
1325 (if (string-match "^www:" (url-view-url t)) | |
1326 (setq w3-mime-list-for-code-conversion nil)) | |
1327 (w3-convert-code-for-mule url-current-mime-type) | |
1328 (setq done-mule-conversion t))) | |
1329 (funcall (car x)) | |
1330 (setq x (cdr x))))) | |
1143 | 1331 |
1144 (defun w3-show-history-list () | 1332 (defun w3-show-history-list () |
1145 "Format the url-history-list prettily and show it to the user" | 1333 "Format the url-history-list prettily and show it to the user" |
1146 (interactive) | 1334 (interactive) |
1147 (w3-fetch "www://auto/history")) | 1335 (w3-fetch "www://auto/history")) |
1148 | 1336 |
1149 (defun w3-save-as (&optional type) | 1337 (defun w3-save-as (&optional type) |
1150 "Save a document to the local disk" | 1338 "Save a document to the local disk" |
1151 (interactive) | 1339 (interactive) |
1152 (save-excursion | 1340 (let* ((completion-ignore-case t) |
1153 (let* ((completion-ignore-case t) | 1341 (format (or type (completing-read |
1154 (format (or type (completing-read | 1342 "Format: " |
1155 "Format: " | 1343 '(("HTML Source") ("Formatted Text") |
1156 '(("HTML Source") | 1344 ("LaTeX Source") ("Binary")) |
1157 ("Formatted Text") | 1345 nil t))) |
1158 ("LaTeX Source") | 1346 (fname (expand-file-name |
1159 ("PostScript") | 1347 (read-file-name "File name: " default-directory))) |
1160 ("Binary")) | 1348 (url (url-view-url t))) |
1161 nil t))) | 1349 (cond |
1162 (fname (expand-file-name | 1350 ((equal "Binary" format) |
1163 (read-file-name "File name: " default-directory))) | 1351 (if (not w3-current-source) |
1164 (url (url-view-url t))) | 1352 (let ((url-be-asynchronous nil)) |
1165 (cond | 1353 (url-retrieve url)))) |
1166 ((equal "Binary" format) | 1354 ((equal "HTML Source" format) |
1167 (if (not w3-current-source) | 1355 (if (not w3-current-source) |
1168 (let ((url-be-asynchronous nil)) | 1356 (let ((url-be-asynchronous nil)) |
1169 (url-retrieve url)))) | 1357 (url-retrieve url)) ; Get the document if necessary |
1170 ((equal "HTML Source" format) | 1358 (let ((txt w3-current-source)) |
1171 (if (not w3-current-source) | 1359 (set-buffer (get-buffer-create url-working-buffer)) |
1172 (let ((url-be-asynchronous nil)) | 1360 (insert txt))) |
1173 (url-retrieve url)) ; Get the document if necessary | 1361 (goto-char (point-min)) |
1174 (let ((txt w3-current-source)) | 1362 (insert (format "<BASE HREF=\"%s\">\n" url))) |
1175 (set-buffer (get-buffer-create url-working-buffer)) | 1363 ((or (equal "Formatted Text" format) |
1176 (erase-buffer) | 1364 (equal "" format)) |
1177 (insert txt))) | 1365 nil) ; Do nothing - we have the text already |
1178 (goto-char (point-min)) | 1366 ((equal "LaTeX Source" format) |
1179 (if (re-search-forward "<head>" nil t) | 1367 (w3-parse-tree-to-latex w3-current-parse url) |
1180 (insert "\n")) | 1368 (insert-buffer url-working-buffer))) |
1181 (insert (format "<BASE HREF=\"%s\">\n" url))) | 1369 (write-region (point-min) (point-max) fname))) |
1182 ((or (equal "Formatted Text" format) | |
1183 (equal "" format)) | |
1184 nil) ; Do nothing - we have the text already | |
1185 ((equal "PostScript" format) | |
1186 (let ((ps-spool-buffer-name " *w3-temp*")) | |
1187 (if (get-buffer ps-spool-buffer-name) | |
1188 (kill-buffer ps-spool-buffer-name)) | |
1189 (ps-spool-buffer-with-faces) | |
1190 (set-buffer ps-spool-buffer-name))) | |
1191 ((equal "LaTeX Source" format) | |
1192 (w3-parse-tree-to-latex w3-current-parse url) | |
1193 (insert-buffer url-working-buffer))) | |
1194 (write-region (point-min) (point-max) fname)))) | |
1195 | 1370 |
1196 | 1371 |
1197 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1372 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1198 ;;; Functions to parse out <A> tags and replace it with a hyperlink zone | 1373 ;;; Functions to parse out <A> tags and replace it with a hyperlink zone |
1199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1374 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1227 (or info "")) | 1402 (or info "")) |
1228 (display-buffer (current-buffer) t)))) | 1403 (display-buffer (current-buffer) t)))) |
1229 | 1404 |
1230 (defun w3-popup-info (&optional url) | 1405 (defun w3-popup-info (&optional url) |
1231 "Show information about the link under point. (All SGML attributes)" | 1406 "Show information about the link under point. (All SGML attributes)" |
1232 (interactive (list (or (w3-view-this-url t) | 1407 (interactive (list (w3-read-url-with-default))) |
1233 (w3-read-url-with-default)))) | |
1234 (let (dat widget) | 1408 (let (dat widget) |
1235 (if (interactive-p) | 1409 (if (interactive-p) |
1236 nil | 1410 nil |
1237 (setq widget (widget-at (point)) | 1411 (setq widget (widget-at (point)) |
1238 dat (and widget (widget-get widget 'attributes)))) | 1412 dat (and widget (widget-get widget 'attributes)))) |
1308 | 1482 |
1309 | 1483 |
1310 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1484 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1311 ;;; Functions to handle formatting an html buffer | 1485 ;;; Functions to handle formatting an html buffer |
1312 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1486 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1487 (defun w3-insert-headers () | |
1488 ;; Insert some HTTP/1.0 headers if necessary | |
1489 (url-lazy-message "Inserting HTTP/1.0 headers...") | |
1490 (let ((hdrs (if (eq t w3-show-headers) (mapcar 'car url-current-mime-headers) | |
1491 w3-show-headers)) | |
1492 x y) | |
1493 (goto-char (setq y (point-max))) | |
1494 (while hdrs | |
1495 (if (setq x (w3-in-assoc (car hdrs) url-current-mime-headers)) | |
1496 (insert "<LI> <B>" (car x) "</B>: " (url-insert-entities-in-string | |
1497 (if (numberp (cdr x)) | |
1498 (int-to-string (cdr x)) | |
1499 (cdr x))))) | |
1500 (setq hdrs (cdr hdrs))) | |
1501 (if (= y (point-max)) | |
1502 nil | |
1503 (insert "</UL>") | |
1504 (goto-char y) | |
1505 (url-lazy-message "Inserting HTTP/1.0 headers... done.") | |
1506 (insert "<HR><UL>")))) | |
1507 | |
1313 (defun w3-add-delayed-graphic (widget) | 1508 (defun w3-add-delayed-graphic (widget) |
1314 ;; Add a delayed image for the current buffer. | 1509 ;; Add a delayed image for the current buffer. |
1315 (setq w3-delayed-images (cons widget w3-delayed-images))) | 1510 (setq w3-delayed-images (cons widget w3-delayed-images))) |
1316 | 1511 |
1317 | 1512 |
1322 (error "WinEmacs no longer supported.")) | 1517 (error "WinEmacs no longer supported.")) |
1323 (w3-running-xemacs (require 'w3-xemac)) | 1518 (w3-running-xemacs (require 'w3-xemac)) |
1324 (w3-running-FSF19 (require 'w3-e19)) | 1519 (w3-running-FSF19 (require 'w3-e19)) |
1325 (t | 1520 (t |
1326 (error "Unable to determine the capabilities of this emacs."))) | 1521 (error "Unable to determine the capabilities of this emacs."))) |
1327 (if (featurep 'emacspeak) | 1522 (cond |
1328 (condition-case () | 1523 ((boundp 'MULE) |
1329 (progn | 1524 (require 'w3-mule)) |
1330 (require 'dtk-css-speech) | 1525 ((featurep 'mule) |
1331 (require 'w3-speak)))) | 1526 (require 'w3-xem20) |
1527 )) | |
1332 (condition-case () | 1528 (condition-case () |
1333 (require 'w3-site-init) | 1529 (require 'w3-site-init) |
1334 (error nil))) | 1530 (error nil))) |
1335 | 1531 |
1336 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1532 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1380 new)) | 1576 new)) |
1381 | 1577 |
1382 (defun w3-search () | 1578 (defun w3-search () |
1383 "Perform a search, if this is a searchable index." | 1579 "Perform a search, if this is a searchable index." |
1384 (interactive) | 1580 (interactive) |
1581 (or w3-current-isindex | |
1582 (error "Not a searchable index (via <isindex>)")) | |
1385 (let* (querystring ; The string to send to the server | 1583 (let* (querystring ; The string to send to the server |
1386 (data | 1584 (data |
1387 (cond | 1585 (cond |
1388 ((null w3-current-isindex) | 1586 ((null w3-current-isindex) |
1389 (let ((rels (cdr-safe (assq 'rel w3-current-links))) | 1587 (let ((rels (mapcar |
1390 val cur) | 1588 (function |
1589 (lambda (data) | |
1590 (if (assoc "rel" data) data))) | |
1591 w3-current-links)) | |
1592 val) | |
1391 (while rels | 1593 (while rels |
1392 (setq cur (car rels) | 1594 (if (string-match "useindex" |
1393 rels (cdr rels)) | 1595 (or (cdr (assoc "rel" (car rels))) "")) |
1394 (if (and (or (string-match "^isindex$" (car cur)) | 1596 (setq val (cdr (assoc "href" (car rels))) |
1395 (string-match "^index$" (car cur))) | |
1396 (plist-get (cadr cur) 'href)) | |
1397 (setq val (plist-get (cadr cur) 'href) | |
1398 rels nil)) | 1597 rels nil)) |
1399 ) | 1598 (setq rels (cdr rels))) |
1400 (if val | 1599 (cons val "Search on (+ separates keywords): "))) |
1401 (cons val "Search on (+ separates keywords): ")))) | |
1402 ((eq w3-current-isindex t) | 1600 ((eq w3-current-isindex t) |
1403 (cons (url-view-url t) "Search on (+ separates keywords): ")) | 1601 (cons (url-view-url t) "Search on (+ separates keywords): ")) |
1404 ((consp w3-current-isindex) | 1602 ((consp w3-current-isindex) |
1405 w3-current-isindex) | 1603 w3-current-isindex) |
1406 (t nil))) | 1604 (t nil))) |
1470 ;;; Leftover stuff that didn't quite fit into url.el | 1668 ;;; Leftover stuff that didn't quite fit into url.el |
1471 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1669 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1472 | 1670 |
1473 (defun w3-generate-error (type data) | 1671 (defun w3-generate-error (type data) |
1474 ;; Generate an HTML error buffer for error TYPE with data DATA. | 1672 ;; Generate an HTML error buffer for error TYPE with data DATA. |
1475 (setq url-current-mime-type "text/html") | |
1476 (cond | 1673 (cond |
1477 ((equal type "nofile") | 1674 ((equal type "nofile") |
1478 (let ((error (save-excursion | 1675 (let ((error (save-excursion |
1479 (set-buffer (get-buffer-create " *url-error*")) | 1676 (set-buffer (get-buffer-create " *url-error*")) |
1480 (buffer-string)))) | 1677 (buffer-string)))) |
1524 (insert "\t\t\t\t<li> <a href=\"" (car (cdr (car tmp))) | 1721 (insert "\t\t\t\t<li> <a href=\"" (car (cdr (car tmp))) |
1525 "\">" (url-insert-entities-in-string | 1722 "\">" (url-insert-entities-in-string |
1526 (car (car tmp))) "</a></li>\n") | 1723 (car (car tmp))) "</a></li>\n") |
1527 (setq tmp (cdr tmp))) | 1724 (setq tmp (cdr tmp))) |
1528 (insert "\n\t\t\t</ol>\n\t\t</div>\n\t</body>\n</html>\n"))) | 1725 (insert "\n\t\t\t</ol>\n\t\t</div>\n\t</body>\n</html>\n"))) |
1726 ((equal type "starting-points") | |
1727 (let ((tmp w3-starting-documents)) | |
1728 (insert "<html>\n\t<head>\n\t\t" | |
1729 "<title> Starting Points </title>\n\t</head>\n" | |
1730 "\t<body>\n\t\t<div>\n\t\t\t<h1>Starting Point on the Web" | |
1731 "</h1>\n\t\t\t<ol>\n") | |
1732 (while tmp | |
1733 (insert (format "\t\t\t\t<li> <a href=\"%s\">%s</a></li>\n" | |
1734 (car (cdr (car tmp))) | |
1735 (car (car tmp)))) | |
1736 (setq tmp (cdr tmp))) | |
1737 (insert "\n\t\t\t</ol>\n\t\t</div>\n\t</body>\n</html>\n"))) | |
1529 ((equal type "history") | 1738 ((equal type "history") |
1530 (if (not url-history-list) | 1739 (if (not url-history-list) |
1531 (url-retrieve "www://error/nohist") | 1740 (url-retrieve "www://error/nohist") |
1532 (insert "<html>\n\t<head>\n\t\t" | 1741 (insert "<html>\n\t<head>\n\t\t" |
1533 "<title> History List For This Session of W3</title>" | 1742 "<title> History List For This Session of W3</title>" |
1534 "\n\t</head>\n\t<body>\n\t\t<div>\n\t\t\t<h1>" | 1743 "\n\t</head>\n\t<body>\n\t\t<div>\n\t\t\t<h1>" |
1535 "History List For This Session of W3</h1>\n\t\t\t<ol>\n") | 1744 "History List For This Session of W3</h1>\n\t\t\t<ol>\n") |
1536 (cl-maphash | 1745 (url-maphash |
1537 (function | 1746 (function |
1538 (lambda (url desc) | 1747 (lambda (url desc) |
1539 (insert (format "\t\t\t\t<li> <a href=\"%s\">%s</a>\n" | 1748 (insert (format "\t\t\t\t<li> <a href=\"%s\">%s</a>\n" |
1540 url (url-insert-entities-in-string desc))))) | 1749 url (url-insert-entities-in-string desc))))) |
1541 url-history-list) | 1750 url-history-list) |
1545 (setq buffer (get-buffer buffer)) | 1754 (setq buffer (get-buffer buffer)) |
1546 (let ((base (get-text-property (point-min) 'w3-base buffer))) | 1755 (let ((base (get-text-property (point-min) 'w3-base buffer))) |
1547 (if base | 1756 (if base |
1548 (setq base (url-generic-parse-url base))) | 1757 (setq base (url-generic-parse-url base))) |
1549 (insert-buffer buffer) | 1758 (insert-buffer buffer) |
1550 (let ((inhibit-read-only t)) | |
1551 (set-text-properties (point-min) (point-max) nil)) | |
1552 (if (not base) | 1759 (if (not base) |
1553 (setq url-current-object | 1760 (setq url-current-type "file" |
1554 (url-generic-parse-url (concat "file:" | 1761 url-current-server nil |
1555 (buffer-file-name buffer)))) | 1762 url-current-file (buffer-file-name buffer)) |
1556 (setq url-current-object base)))) | 1763 (setq url-current-object base |
1764 url-current-type (url-type base) | |
1765 url-current-user (url-user base) | |
1766 url-current-port (url-port base) | |
1767 url-current-server (url-host base) | |
1768 url-current-file (url-filename base))))) | |
1557 | 1769 |
1558 (defun w3-internal-url (url) | 1770 (defun w3-internal-url (url) |
1559 ;; Handle internal urls (previewed buffers, etc) | 1771 ;; Handle internal urls (previewed buffers, etc) |
1560 (if (not (string-match "www:/+\\([^/]+\\)/\\(.*\\)" url)) | 1772 (if (not (string-match "www:/+\\([^/]+\\)/\\(.*\\)" url)) |
1561 (w3-fetch "www://error/") | 1773 (w3-fetch "www://error/") |
1562 (let ((type (url-match url 1)) | 1774 (let ((type (url-match url 1)) |
1563 (data (url-match url 2))) | 1775 (data (url-match url 2))) |
1564 (set-buffer (get-buffer-create url-working-buffer)) | 1776 (set-buffer (get-buffer-create url-working-buffer)) |
1777 (setq url-current-type "www" | |
1778 url-current-server type | |
1779 url-current-file data) | |
1565 (cond | 1780 (cond |
1566 ((equal type "preview") ; Previewing a document | 1781 ((equal type "preview") ; Previewing a document |
1567 (if (get-buffer data) ; Buffer still exists | 1782 (if (get-buffer data) ; Buffer still exists |
1568 (w3-internal-handle-preview data) | 1783 (w3-internal-handle-preview data) |
1569 (url-retrieve (concat "www://error/nobuf/" data)))) | 1784 (url-retrieve (concat "www://error/nobuf/" data)))) |
1587 (unfocus-frame)) | 1802 (unfocus-frame)) |
1588 (display-buffer (find-file-noselect file)))) | 1803 (display-buffer (find-file-noselect file)))) |
1589 | 1804 |
1590 (defun w3-default-local-file() | 1805 (defun w3-default-local-file() |
1591 "Use find-file to open the local file" | 1806 "Use find-file to open the local file" |
1592 (w3-ff (url-filename url-current-object))) | 1807 (w3-ff url-current-file)) |
1593 | 1808 |
1594 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1809 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1595 ;;; Mode definition ;;; | 1810 ;;; Mode definition ;;; |
1596 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1811 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1597 (defun w3-search-forward (string) | 1812 (defun w3-search-forward (string) |
1679 href) | 1894 href) |
1680 (href | 1895 (href |
1681 (message "%s" (url-truncate-url-for-viewing href))) | 1896 (message "%s" (url-truncate-url-for-viewing href))) |
1682 (no-show | 1897 (no-show |
1683 nil) | 1898 nil) |
1684 (widget | |
1685 (widget-echo-help (point))) | |
1686 (t | 1899 (t |
1687 nil)))) | 1900 nil)))) |
1688 | 1901 |
1689 (defun w3-load-delayed-images () | 1902 (defun w3-load-delayed-images () |
1690 "Load inlined images that were delayed, if any." | 1903 "Load inlined images that were delayed, if any." |
1750 (let ((x w3-current-links) | 1963 (let ((x w3-current-links) |
1751 (y nil) | 1964 (y nil) |
1752 (found nil)) | 1965 (found nil)) |
1753 (setq found (cdr-safe (assoc "reply-to" url-current-mime-headers))) | 1966 (setq found (cdr-safe (assoc "reply-to" url-current-mime-headers))) |
1754 (if (and found (not (string-match url-nonrelative-link found))) | 1967 (if (and found (not (string-match url-nonrelative-link found))) |
1755 (setq found (list (concat "mailto:" found)))) | 1968 (setq found (concat "mailto:" found))) |
1756 (while (and x (not found)) | 1969 (while (and x (not found)) |
1757 (setq y (car x) | 1970 (setq y (car x) |
1758 x (cdr x) | 1971 x (cdr x) |
1759 found (cdr-safe (assoc "made" y)))) | 1972 found (cdr-safe (assoc "made" y)))) |
1760 (if found | 1973 (if found |
1761 (let ((possible nil) | 1974 (let ((possible nil)) |
1762 (href nil)) | |
1763 (setq x (car found)) ; Fallback if no mail(to|server) found | 1975 (setq x (car found)) ; Fallback if no mail(to|server) found |
1764 (while found | 1976 (while found |
1765 (setq href (plist-get (pop found) 'href)) | 1977 (if (string-match "^mail[^:]+:" (car found)) |
1766 (if (and href (string-match "^mail[^:]+:" href)) | 1978 (setq possible (cons (car found) possible))) |
1767 (setq possible (cons href possible)))) | 1979 (setq found (cdr found))) |
1768 (case (length possible) | 1980 (case (length possible) |
1769 (0 ; No mailto links found | 1981 (0 ; No mailto links found |
1770 (w3-fetch x)) ; fall back onto first 'made' link | 1982 (w3-fetch x)) ; fall back onto first 'made' link |
1771 (1 ; Only one found, get it | 1983 (1 ; Only one found, get it |
1772 (w3-fetch (car possible))) | 1984 (w3-fetch (car possible))) |
1773 (otherwise | 1985 (otherwise |
1774 (w3-fetch (completing-read "Choose an address: " | 1986 (w3-fetch (completing-read "Choose an address: " |
1775 (mapcar 'list possible) | 1987 (mapcar 'list possible) |
1776 nil t (car possible)))))) | 1988 nil t (car possible)))))) |
1777 (message "Could not automatically determine authors address, sorry.")))) | 1989 (message "Could not automatically determine authors address, sorry.") |
1990 (sit-for 1) | |
1991 (w3-fetch (concat "mailto:" | |
1992 (read-string "Email address: " | |
1993 (if url-current-server | |
1994 (concat "@" url-current-server)))))))) | |
1778 | 1995 |
1779 (defun w3-kill-emacs-func () | 1996 (defun w3-kill-emacs-func () |
1780 "Routine called when exiting emacs. Do miscellaneous clean up." | 1997 "Routine called when exiting emacs. Do miscellaneous clean up." |
1781 (and (eq url-keep-history t) | 1998 (and (eq url-keep-history t) |
1782 url-global-history-hash-table | 1999 url-global-history-hash-table |
1830 WIDGET and MAPARG. | 2047 WIDGET and MAPARG. |
1831 The arguments FROM, TO, MAPARG, and BUFFER default to the beginning of | 2048 The arguments FROM, TO, MAPARG, and BUFFER default to the beginning of |
1832 BUFFER, the end of BUFFER, nil, and (current-buffer), respectively." | 2049 BUFFER, the end of BUFFER, nil, and (current-buffer), respectively." |
1833 (let ((cur (point-min)) | 2050 (let ((cur (point-min)) |
1834 (widget nil) | 2051 (widget nil) |
1835 (parent nil)) | 2052 (url nil)) |
1836 (while (setq cur (next-single-property-change cur 'button)) | 2053 (while (setq cur (next-single-property-change cur 'button)) |
1837 (setq widget (widget-at cur) | 2054 (setq widget (widget-at cur)) |
1838 parent (and widget (widget-get widget :parent))) | |
1839 ;; Check to see if its a push widget, its got the correct callback, | 2055 ;; Check to see if its a push widget, its got the correct callback, |
1840 ;; and actually has a URL. Remember the url as a side-effect of the | 2056 ;; and actually has a URL. Remember the url as a side-effect of the |
1841 ;; test for later use. | 2057 ;; test for later use. |
1842 (cond | 2058 (if (and (eq (car widget) 'push) |
1843 ((and widget (widget-get widget 'href)) | 2059 (eq (widget-get widget :notify) 'w3-follow-hyperlink) |
1844 (funcall function widget maparg)) | 2060 (setq url (widget-get widget 'href))) |
1845 ((and parent (widget-get parent 'href)) | 2061 (funcall function widget maparg))))) |
1846 (funcall function parent maparg)) | |
1847 (t nil))))) | |
1848 | 2062 |
1849 (defun w3-emit-image-warnings-if-necessary () | 2063 (defun w3-emit-image-warnings-if-necessary () |
1850 (if (and (not w3-delay-image-loads) | 2064 (if (and (not w3-delay-image-loads) |
1851 (fboundp 'w3-insert-graphic) | 2065 (fboundp 'w3-insert-graphic) |
1852 (or (not (featurep 'gif)) | 2066 (or (not (featurep 'gif)) |
1881 "Reload all stylesheets." | 2095 "Reload all stylesheets." |
1882 (interactive) | 2096 (interactive) |
1883 (setq w3-user-stylesheet nil | 2097 (setq w3-user-stylesheet nil |
1884 w3-face-cache nil) | 2098 w3-face-cache nil) |
1885 (w3-find-default-stylesheets) | 2099 (w3-find-default-stylesheets) |
1886 ) | 2100 (w3-style-post-process-stylesheet w3-user-stylesheet)) |
1887 | |
1888 (defvar w3-loaded-stylesheets nil | |
1889 "A list of all the stylesheets Emacs-W3 loaded at startup.") | |
1890 | 2101 |
1891 (defun w3-find-default-stylesheets () | 2102 (defun w3-find-default-stylesheets () |
1892 (setq w3-loaded-stylesheets nil) | |
1893 (let* ((lightp (w3-color-light-p 'default)) | 2103 (let* ((lightp (w3-color-light-p 'default)) |
1894 (longname (if lightp "stylesheet-light" "stylesheet-dark")) | 2104 (longname (if lightp "stylesheet-light" "stylesheet-dark")) |
1895 (shortname (if lightp "light.css" "dark.css")) | 2105 (shortname (if lightp "light.css" "dark.css")) |
1896 (directories (list | 2106 (directories (list |
1897 data-directory | 2107 data-directory |
1898 (concat data-directory "w3/") | 2108 (concat data-directory "w3/") |
1899 (expand-file-name "../../w3" data-directory) | |
1900 (file-name-directory (locate-library "w3")) | 2109 (file-name-directory (locate-library "w3")) |
1901 w3-configuration-directory)) | 2110 w3-configuration-directory)) |
1902 (total-found 0) | 2111 (total-found 0) |
1903 (possible (append | 2112 (possible (append |
1904 (apply | 2113 (apply |
1924 possible (cdr possible) | 2133 possible (cdr possible) |
1925 found (and cur (file-exists-p cur) (file-readable-p cur) | 2134 found (and cur (file-exists-p cur) (file-readable-p cur) |
1926 (not (file-directory-p cur)) cur)) | 2135 (not (file-directory-p cur)) cur)) |
1927 (if found | 2136 (if found |
1928 (setq total-found (1+ total-found) | 2137 (setq total-found (1+ total-found) |
1929 w3-loaded-stylesheets (cons cur w3-loaded-stylesheets) | 2138 w3-user-stylesheet (car |
1930 w3-user-stylesheet (css-parse (concat "file:" cur) nil | 2139 (w3-style-parse-css |
1931 w3-user-stylesheet)))) | 2140 (concat "file:" cur) nil |
2141 w3-user-stylesheet))))) | |
1932 (setq-default url-be-asynchronous old-asynch) | 2142 (setq-default url-be-asynchronous old-asynch) |
1933 (if (= 0 total-found) | 2143 (if (= 0 total-found) |
1934 (w3-warn | 2144 (w3-warn |
1935 'style | 2145 'style |
1936 (concat | 2146 (concat |
1955 (or w3-default-configuration-file | 2165 (or w3-default-configuration-file |
1956 "profile") | 2166 "profile") |
1957 w3-configuration-directory)) | 2167 w3-configuration-directory)) |
1958 | 2168 |
1959 | 2169 |
1960 (if (and init-file-user | 2170 (if (and w3-default-configuration-file |
1961 w3-default-configuration-file | |
1962 (file-exists-p w3-default-configuration-file)) | 2171 (file-exists-p w3-default-configuration-file)) |
1963 (condition-case e | 2172 (condition-case e |
1964 (load w3-default-configuration-file nil t) | 2173 (load w3-default-configuration-file nil t) |
1965 (error | 2174 (error |
1966 (let ((buf-name " *Configuration Error*")) | 2175 (let ((buf-name " *Configuration Error*")) |
1975 (concat | 2184 (concat |
1976 "Configuration file `%s' contains an error.\n" | 2185 "Configuration file `%s' contains an error.\n" |
1977 "Please consult the `%s' buffer for details.")) | 2186 "Please consult the `%s' buffer for details.")) |
1978 w3-default-configuration-file buf-name)))))) | 2187 w3-default-configuration-file buf-name)))))) |
1979 | 2188 |
2189 (setq w3-netscape-configuration-file | |
2190 (cond | |
2191 (w3-netscape-configuration-file | |
2192 w3-netscape-configuration-file) | |
2193 ((memq system-type '(ms-dos ms-windows)) | |
2194 (expand-file-name "~/NETSCAPE.CFG")) | |
2195 (t (expand-file-name "~/.netscape/preferences")))) | |
2196 | |
1980 (if (and (eq w3-user-colors-take-precedence 'guess) | 2197 (if (and (eq w3-user-colors-take-precedence 'guess) |
1981 (not (eq (device-type) 'tty)) | 2198 (not (eq (device-type) 'tty)) |
1982 (not (eq (device-class) 'mono))) | 2199 (not (eq (device-class) 'mono))) |
1983 (progn | 2200 (progn |
1984 (setq w3-user-colors-take-precedence t) | 2201 (setq w3-user-colors-take-precedence t) |
1990 (if (not url-global-history-file) | 2207 (if (not url-global-history-file) |
1991 (setq url-global-history-file | 2208 (setq url-global-history-file |
1992 (expand-file-name "history" | 2209 (expand-file-name "history" |
1993 w3-configuration-directory))) | 2210 w3-configuration-directory))) |
1994 | 2211 |
2212 (if (and w3-use-netscape-configuration-file | |
2213 w3-netscape-configuration-file | |
2214 (fboundp 'w3-read-netscape-config)) | |
2215 (w3-read-netscape-config w3-netscape-configuration-file)) | |
2216 | |
1995 (add-minor-mode 'w3-netscape-emulation-minor-mode " NS" | 2217 (add-minor-mode 'w3-netscape-emulation-minor-mode " NS" |
1996 w3-netscape-emulation-minor-mode-map) | 2218 w3-netscape-emulation-minor-mode-map) |
2219 (add-minor-mode 'w3-annotation-minor-mode " Annotating" | |
2220 w3-annotation-minor-mode-map) | |
1997 (add-minor-mode 'w3-lynx-emulation-minor-mode " Lynx" | 2221 (add-minor-mode 'w3-lynx-emulation-minor-mode " Lynx" |
1998 w3-lynx-emulation-minor-mode-map) | 2222 w3-annotation-minor-mode-map) |
1999 | 2223 |
2000 (setq url-package-version w3-version-number | 2224 (setq url-package-version w3-version-number |
2001 url-package-name "Emacs-W3") | 2225 url-package-name "Emacs-W3") |
2002 | 2226 |
2003 (w3-setup-terminal-chars) | |
2004 | |
2005 (w3-emit-image-warnings-if-necessary) | 2227 (w3-emit-image-warnings-if-necessary) |
2228 (if (eq w3-color-use-reducing 'guess) | |
2229 (setq w3-color-use-reducing | |
2230 (cond | |
2231 ((eq (device-type) 'tty) nil) | |
2232 ((fboundp 'device-class) | |
2233 (not (and (memq (device-class) '(TrueColor true-color)) | |
2234 (<= 16 (or (device-bitplanes) 0))))) | |
2235 (t t)))) | |
2006 | 2236 |
2007 (cond | 2237 (cond |
2008 ((memq system-type '(ms-dos ms-windows)) | 2238 ((memq system-type '(ms-dos ms-windows)) |
2009 (setq w3-hotlist-file (or w3-hotlist-file | 2239 (setq w3-documents-menu-file (or w3-documents-menu-file |
2240 (expand-file-name "~/mosaic.mnu")) | |
2241 w3-hotlist-file (or w3-hotlist-file | |
2010 (expand-file-name "~/mosaic.hot")) | 2242 (expand-file-name "~/mosaic.hot")) |
2011 )) | 2243 w3-personal-annotation-directory (or w3-personal-annotation-directory |
2244 (expand-file-name | |
2245 "~/mosaic.ann")))) | |
2012 ((memq system-type '(axp-vms vax-vms)) | 2246 ((memq system-type '(axp-vms vax-vms)) |
2013 (setq w3-hotlist-file (or w3-hotlist-file | 2247 (setq w3-documents-menu-file |
2248 (or w3-documents-menu-file | |
2249 (expand-file-name "decw$system_defaults:documents.menu")) | |
2250 w3-hotlist-file (or w3-hotlist-file | |
2014 (expand-file-name "~/mosaic.hotlist-default")) | 2251 (expand-file-name "~/mosaic.hotlist-default")) |
2015 )) | 2252 w3-personal-annotation-directory |
2253 (or w3-personal-annotation-directory | |
2254 (expand-file-name "~/mosaic-annotations/")))) | |
2016 (t | 2255 (t |
2017 (setq w3-hotlist-file (or w3-hotlist-file | 2256 (setq w3-documents-menu-file |
2257 (or w3-documents-menu-file | |
2258 (expand-file-name "/usr/local/lib/mosaic/documents.menu")) | |
2259 w3-hotlist-file (or w3-hotlist-file | |
2018 (expand-file-name "~/.mosaic-hotlist-default")) | 2260 (expand-file-name "~/.mosaic-hotlist-default")) |
2019 ))) | 2261 w3-personal-annotation-directory |
2262 (or w3-personal-annotation-directory | |
2263 (expand-file-name "~/.mosaic-personal-annotations"))))) | |
2020 | 2264 |
2265 (if (eq w3-delimit-emphasis 'guess) | |
2266 (setq w3-delimit-emphasis | |
2267 (and (not w3-running-xemacs) | |
2268 (not (and w3-running-FSF19 | |
2269 (memq (device-type) '(x ns pm))))))) | |
2270 | |
2271 (if (eq w3-delimit-links 'guess) | |
2272 (setq w3-delimit-links | |
2273 (and (not w3-running-xemacs) | |
2274 (not (and w3-running-FSF19 | |
2275 (memq (device-type) '(x ns pm))))))) | |
2276 | |
2021 ; Set up a hook that will save the history list when | 2277 ; Set up a hook that will save the history list when |
2022 ; exiting emacs | 2278 ; exiting emacs |
2023 (add-hook 'kill-emacs-hook 'w3-kill-emacs-func) | 2279 (add-hook 'kill-emacs-hook 'w3-kill-emacs-func) |
2024 | 2280 |
2025 (mm-parse-mailcaps) | 2281 (mm-parse-mailcaps) |
2026 (mm-parse-mimetypes) | 2282 (mm-parse-mimetypes) |
2027 | 2283 |
2028 ; Load in the hotlist if they haven't set it already | 2284 ; Load in the hotlist if they haven't set it already |
2029 (or w3-hotlist (w3-parse-hotlist)) | 2285 (or w3-hotlist (w3-parse-hotlist)) |
2286 | |
2287 ; Load in their personal annotations if they haven't set them already | |
2288 (or w3-personal-annotations (w3-parse-personal-annotations)) | |
2030 | 2289 |
2031 ; Set the default home page, honoring their defaults, then | 2290 ; Set the default home page, honoring their defaults, then |
2032 ; the standard WWW_HOME, then default to the documentation @ IU | 2291 ; the standard WWW_HOME, then default to the documentation @ IU |
2033 (or w3-default-homepage | 2292 (or w3-default-homepage |
2034 (setq w3-default-homepage | 2293 (setq w3-default-homepage |
2035 (or (getenv "WWW_HOME") | 2294 (or (getenv "WWW_HOME") |
2036 "http://www.cs.indiana.edu/elisp/w3/docs.html"))) | 2295 "http://www.cs.indiana.edu/elisp/w3/docs.html"))) |
2037 | 2296 |
2297 ; Set up the documents menu | |
2298 (w3-parse-docs-menu) | |
2299 | |
2038 ; Set up the entity definition for PGP and PEM authentication | 2300 ; Set up the entity definition for PGP and PEM authentication |
2039 | 2301 |
2040 (run-hooks 'w3-load-hook) | 2302 (run-hooks 'w3-load-hook) |
2041 (setq w3-setup-done t)) | 2303 (setq w3-setup-done t)) |
2042 | 2304 |
2043 (defun w3-mark-link-as-followed (ext dat) | 2305 (defun w3-mark-link-as-followed (ext dat) |
2044 ;; Mark a link as followed | 2306 ;; Mark a link as followed |
2045 (message "Reimplement w3-mark-link-as-followed")) | 2307 (let* ((st (w3-zone-start ext)) |
2308 (nd (w3-zone-end ext)) | |
2309 (tag 'a) | |
2310 (args (list (cons 'class "visited"))) | |
2311 (face (cdr (w3-face-for-element)))) | |
2312 (w3-add-zone st nd face dat t))) | |
2046 | 2313 |
2047 (defun w3-only-links () | 2314 (defun w3-only-links () |
2048 (let* (result temp) | 2315 (let* (result temp) |
2049 (if (widget-at (point-min)) | 2316 (if (widget-at (point-min)) |
2050 (setq result (list (widget-at (point-min))))) | 2317 (setq result (list (widget-at (point-min))))) |
2061 (set-buffer buff) | 2328 (set-buffer buff) |
2062 (let ((require-final-newline nil) | 2329 (let ((require-final-newline nil) |
2063 (file-name-handler-alist nil) | 2330 (file-name-handler-alist nil) |
2064 (write-file-hooks nil) | 2331 (write-file-hooks nil) |
2065 (write-contents-hooks nil) | 2332 (write-contents-hooks nil) |
2066 (enable-multibyte-characters t) ; mule 2.4 | 2333 (mc-flag t) |
2067 (buffer-file-coding-system mule-no-coding-system) ; mule 2.4 | 2334 (file-coding-system url-mule-no-coding-system)) |
2068 (file-coding-system mule-no-coding-system) ; mule 2.3 | |
2069 (mc-flag t)) ; mule 2.3 | |
2070 (write-file fname) | 2335 (write-file fname) |
2071 (message "Download of %s complete." (url-view-url t)) | 2336 (message "Download of %s complete." (url-view-url t)) |
2072 (sit-for 3) | 2337 (sit-for 3) |
2073 (kill-buffer buff))))) | 2338 (kill-buffer buff))))) |
2074 | 2339 |
2077 (url-inhibit-uncompression t) | 2342 (url-inhibit-uncompression t) |
2078 (url-mime-accept-string "*/*") | 2343 (url-mime-accept-string "*/*") |
2079 (urlobj (url-generic-parse-url url)) | 2344 (urlobj (url-generic-parse-url url)) |
2080 (url-working-buffer | 2345 (url-working-buffer |
2081 (generate-new-buffer (concat " *" url " download*"))) | 2346 (generate-new-buffer (concat " *" url " download*"))) |
2082 (stub-fname (url-basepath (or (url-filename urlobj) "") t)) | 2347 (stub-fname (url-remove-compressed-extensions |
2083 (dir (or mm-download-directory "~/")) | 2348 (url-basepath (or (url-filename urlobj) "") t))) |
2084 (fname (expand-file-name | 2349 (fname (read-file-name "Filename to save as: " |
2085 (read-file-name "Filename to save as: " | 2350 (or mm-download-directory "~/") |
2086 dir | 2351 stub-fname |
2087 stub-fname | 2352 nil |
2088 nil | 2353 stub-fname))) |
2089 stub-fname) dir))) | |
2090 (setq-default url-be-asynchronous t) | 2354 (setq-default url-be-asynchronous t) |
2091 (save-excursion | 2355 (save-excursion |
2092 (set-buffer url-working-buffer) | 2356 (set-buffer url-working-buffer) |
2093 (setq url-current-callback-data (list fname (current-buffer)) | 2357 (setq url-current-callback-data (list fname (current-buffer)) |
2094 url-be-asynchronous t | 2358 url-be-asynchronous t |
2122 ((or p w3-dump-to-disk) | 2386 ((or p w3-dump-to-disk) |
2123 (w3-download-url href)) | 2387 (w3-download-url href)) |
2124 (t | 2388 (t |
2125 (w3-fetch href))))) | 2389 (w3-fetch href))))) |
2126 | 2390 |
2127 ;;; FIXME! Need to rewrite these so that we can pass a predicate to | |
2128 (defun w3-widget-forward (arg) | |
2129 "Move point to the next field or button. | |
2130 With optional ARG, move across that many fields." | |
2131 (interactive "p") | |
2132 (widget-forward arg)) | |
2133 | |
2134 (defun w3-widget-backward (arg) | |
2135 "Move point to the previous field or button. | |
2136 With optional ARG, move across that many fields." | |
2137 (interactive "p") | |
2138 (w3-widget-forward (- arg))) | |
2139 | |
2140 (defun w3-complete-link () | 2391 (defun w3-complete-link () |
2141 "Choose a link from the current buffer and follow it" | 2392 "Choose a link from the current buffer and follow it" |
2142 (interactive) | 2393 (interactive) |
2143 (let (links-alist | 2394 (let (links-alist |
2144 link-at-point | 2395 link-at-point |
2146 (completion-ignore-case t)) | 2397 (completion-ignore-case t)) |
2147 (setq link-at-point (widget-at (point)) | 2398 (setq link-at-point (widget-at (point)) |
2148 link-at-point (and | 2399 link-at-point (and |
2149 link-at-point | 2400 link-at-point |
2150 (widget-get link-at-point 'href) | 2401 (widget-get link-at-point 'href) |
2151 (widget-get link-at-point :from) | |
2152 (widget-get link-at-point :to) | |
2153 (w3-fix-spaces | 2402 (w3-fix-spaces |
2154 (buffer-substring | 2403 (buffer-substring |
2155 (widget-get link-at-point :from) | 2404 (car (widget-get link-at-point 'title)) |
2156 (widget-get link-at-point :to))))) | 2405 (cdr (widget-get link-at-point 'title)))))) |
2157 (w3-map-links (function | 2406 (w3-map-links (function |
2158 (lambda (widget arg) | 2407 (lambda (widget arg) |
2159 (if (and (widget-get widget :from) | 2408 (setq links-alist (cons |
2160 (widget-get widget :to)) | 2409 (cons |
2161 (setq links-alist (cons | 2410 (w3-fix-spaces |
2162 (cons | 2411 (buffer-substring-no-properties |
2163 (w3-fix-spaces | 2412 (widget-get widget :from) |
2164 (buffer-substring-no-properties | 2413 (widget-get widget :to))) |
2165 (widget-get widget :from) | 2414 (widget-get widget 'href)) |
2166 (widget-get widget :to))) | 2415 links-alist))))) |
2167 (widget-get widget 'href)) | |
2168 links-alist)))))) | |
2169 (if (not links-alist) (error "No links in current document.")) | 2416 (if (not links-alist) (error "No links in current document.")) |
2170 (setq links-alist (sort links-alist (function | 2417 (setq links-alist (sort links-alist (function |
2171 (lambda (x y) | 2418 (lambda (x y) |
2172 (string< (car x) (car y)))))) | 2419 (string< (car x) (car y)))))) |
2173 ;; Destructively remove duplicate entries from links-alist. | 2420 ;; Destructively remove duplicate entries from links-alist. |
2183 link-at-point | 2430 link-at-point |
2184 (concat | 2431 (concat |
2185 (substring link-at-point 0 17) "...")) | 2432 (substring link-at-point 0 17) "...")) |
2186 "): ") | 2433 "): ") |
2187 "Link: ") links-alist nil t)) | 2434 "Link: ") links-alist nil t)) |
2188 (let ((match (try-completion choice links-alist))) | 2435 (if (string= choice "") |
2189 (cond | 2436 (w3-follow-link) |
2190 ((eq t match) ; We have an exact match | 2437 (w3-fetch (cdr (assoc choice links-alist)))))) |
2191 (setq choice (cdr (assoc choice links-alist)))) | 2438 |
2192 ((stringp match) | 2439 (defun w3-widget-motion-hook (widget) |
2193 (setq choice (cdr (assoc match links-alist)))) | 2440 (assert widget nil "Bad data to w3-widget-motion-hook! Bad hook bad!") |
2194 (t (setq choice nil))) | 2441 (case w3-echo-link |
2195 (if choice | 2442 (text |
2196 (w3-fetch choice))))) | 2443 (message "%s" (w3-fix-spaces (buffer-substring (widget-get widget :from) |
2444 (widget-get widget :to))))) | |
2445 (url | |
2446 (if (widget-get widget 'href) | |
2447 (message "%s" (widget-get widget 'href)))) | |
2448 (otherwise nil))) | |
2197 | 2449 |
2198 (defun w3-mode () | 2450 (defun w3-mode () |
2199 "Mode for viewing HTML documents. If called interactively, will | 2451 "Mode for viewing HTML documents. If called interactively, will |
2200 display the current buffer as HTML. | 2452 display the current buffer as HTML. |
2201 | 2453 |
2205 (or w3-setup-done (w3-do-setup)) | 2457 (or w3-setup-done (w3-do-setup)) |
2206 (if (interactive-p) | 2458 (if (interactive-p) |
2207 (w3-preview-this-buffer) | 2459 (w3-preview-this-buffer) |
2208 (let ((tmp (mapcar (function (lambda (x) (cons x (symbol-value x)))) | 2460 (let ((tmp (mapcar (function (lambda (x) (cons x (symbol-value x)))) |
2209 w3-persistent-variables))) | 2461 w3-persistent-variables))) |
2210 ;; Oh gross, this kills buffer-local faces in XEmacs | 2462 (kill-all-local-variables) |
2211 ;;(kill-all-local-variables) | |
2212 (use-local-map w3-mode-map) | 2463 (use-local-map w3-mode-map) |
2213 (setq major-mode 'w3-mode) | 2464 (setq major-mode 'w3-mode) |
2214 (setq mode-name "WWW") | 2465 (setq mode-name "WWW") |
2215 (mapcar (function (lambda (x) (set-variable (car x) (cdr x)))) tmp) | 2466 (mapcar (function (lambda (x) (set-variable (car x) (cdr x)))) tmp) |
2216 (w3-mode-version-specifics) | 2467 (w3-mode-version-specifics) |
2217 (w3-menu-install-menus) | 2468 (w3-menu-install-menus) |
2218 (setq url-current-passwd-count 0 | 2469 (make-local-hook 'widget-motion-hook) |
2219 inhibit-read-only nil | 2470 (add-hook 'widget-motion-hook 'w3-widget-motion-hook) |
2220 truncate-lines t | |
2221 mode-line-format w3-modeline-format) | |
2222 (run-hooks 'w3-mode-hook) | 2471 (run-hooks 'w3-mode-hook) |
2223 (widget-setup) | 2472 (widget-setup) |
2224 (if w3-current-isindex | 2473 (setq url-current-passwd-count 0 |
2474 mode-line-format w3-modeline-format) | |
2475 (if (and w3-current-isindex (equal url-current-type "http")) | |
2225 (setq mode-line-process "-Searchable"))))) | 2476 (setq mode-line-process "-Searchable"))))) |
2226 | 2477 |
2227 (require 'mm) | 2478 (require 'mm) |
2228 (require 'url) | 2479 (require 'url) |
2480 (require 'url-hash) | |
2229 (require 'w3-parse) | 2481 (require 'w3-parse) |
2230 (require 'w3-display) | 2482 (require 'w3-draw) |
2231 (require 'w3-auto) | 2483 (require 'w3-auto) |
2232 (require 'w3-emulate) | 2484 (require 'w3-emulate) |
2233 (require 'w3-menu) | 2485 (require 'w3-menu) |
2234 (require 'w3-mouse) | 2486 (require 'w3-mouse) |
2235 (provide 'w3) | 2487 (provide 'w3) |