Mercurial > hg > xemacs-beta
comparison lisp/w3/w3.el @ 98:0d2f883870bc r20-1b1
Import from CVS: tag r20-1b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:13:56 +0200 |
parents | 821dec489c24 |
children | a145efe76779 |
comparison
equal
deleted
inserted
replaced
97:498bf5da1c90 | 98:0d2f883870bc |
---|---|
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/01/29 06:25:59 | 3 ;; Created: 1997/02/13 23:05:56 |
4 ;; Version: 1.61 | 4 ;; Version: 1.77 |
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. | 9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc. |
122 (cond | 122 (cond |
123 ((< n 1) (char-to-string ?Z)) | 123 ((< n 1) (char-to-string ?Z)) |
124 ((<= n 26) (char-to-string (+ ?A (1- n)))) | 124 ((<= n 26) (char-to-string (+ ?A (1- n)))) |
125 (t (concat (char-to-string (+ ?A (1- (/ n 27)))) | 125 (t (concat (char-to-string (+ ?A (1- (/ n 27)))) |
126 (w3-decimal-to-alpha (% n 26)))))) | 126 (w3-decimal-to-alpha (% n 26)))))) |
127 | |
128 | |
129 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
130 ;;; Functions for compatibility with XMosaic | |
131 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
132 | |
133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
134 ;;; Parse out the Mosaic documents-menu file | |
135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
136 (defun w3-parse-docs-menu () | |
137 ;; Parse the Mosaic documents menu | |
138 (let ((tmp-menu (append '((separator)) w3-starting-documents | |
139 '((separator)))) | |
140 real-menu x y name url) | |
141 (if (or (not (file-exists-p w3-documents-menu-file)) | |
142 (not (file-readable-p w3-documents-menu-file))) | |
143 nil | |
144 (save-excursion | |
145 (set-buffer (get-buffer-create " *w3-temp*")) | |
146 (erase-buffer) | |
147 (insert-file-contents w3-documents-menu-file) | |
148 (goto-char (point-min)) | |
149 (while (not (eobp)) | |
150 (if (not (looking-at "-+$")) | |
151 (setq x (progn (beginning-of-line) (point)) | |
152 y (progn (end-of-line) (point)) | |
153 name (prog1 | |
154 (buffer-substring x y) | |
155 (delete-region x (min (1+ y) (point-max)))) | |
156 x (progn (beginning-of-line) (point)) | |
157 y (progn (end-of-line) (point)) | |
158 url (prog1 | |
159 (buffer-substring x y) | |
160 (delete-region x (min (1+ y) (point-max)))) | |
161 tmp-menu (if (rassoc url tmp-menu) tmp-menu | |
162 (cons (cons name url) tmp-menu))) | |
163 (setq tmp-menu (cons '(separator) tmp-menu)) | |
164 (delete-region (point-min) (min (1+ (progn (end-of-line) | |
165 (point))) | |
166 (point-max))))) | |
167 (kill-buffer (current-buffer)))) | |
168 (if (equal (car (car tmp-menu)) "") (setq tmp-menu (cdr tmp-menu))) | |
169 (while tmp-menu | |
170 (setq real-menu (cons (if (equal 'separator (car (car tmp-menu))) | |
171 "--------" | |
172 (vector (car (car tmp-menu)) | |
173 (list 'w3-fetch | |
174 (if (listp (cdr (car tmp-menu))) | |
175 (car (cdr (car tmp-menu))) | |
176 (cdr (car tmp-menu)))) t)) | |
177 real-menu) | |
178 tmp-menu (cdr tmp-menu))) | |
179 (setq w3-navigate-menu (append w3-navigate-menu real-menu | |
180 (list "-----"))))) | |
181 | 127 |
182 | 128 |
183 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 129 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
184 ;;; Functions to pass files off to external viewers | 130 ;;; Functions to pass files off to external viewers |
185 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 131 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
382 | 328 |
383 ;;;###autoload | 329 ;;;###autoload |
384 (defun w3-open-local (fname) | 330 (defun w3-open-local (fname) |
385 "Find a local file, and interpret it as a hypertext document. | 331 "Find a local file, and interpret it as a hypertext document. |
386 It will prompt for an existing file or directory, and retrieve it as a | 332 It will prompt for an existing file or directory, and retrieve it as a |
387 hypertext document. If it is a directory, and url-use-hypertext-dired | 333 hypertext document." |
388 is non-nil, then an HTML directory listing is created on the fly. | |
389 Otherwise, dired-mode is used to visit the buffer." | |
390 (interactive "FLocal file: ") | 334 (interactive "FLocal file: ") |
391 (setq fname (expand-file-name fname)) | 335 (setq fname (expand-file-name fname)) |
392 (if (not w3-setup-done) (w3-do-setup)) | 336 (if (not w3-setup-done) (w3-do-setup)) |
393 (w3-fetch (concat "file:" fname))) | 337 (w3-fetch (concat "file:" fname))) |
394 | 338 |
395 ;;;###autoload | 339 ;;;###autoload |
396 (defun w3-find-file (fname) | 340 (defun w3-find-file (fname) |
397 "Find a local file, and interpret it as a hypertext document. | 341 "Find a local file, and interpret it as a hypertext document. |
398 It will prompt for an existing file or directory, and retrieve it as a | 342 It will prompt for an existing file or directory, and retrieve it as a |
399 hypertext document. If it is a directory, and url-use-hypertext-dired | 343 hypertext document." |
400 is non-nil, then an HTML directory listing is created on the fly. | |
401 Otherwise, dired-mode is used to visit the buffer." | |
402 (interactive "FLocal file: ") | 344 (interactive "FLocal file: ") |
403 (w3-open-local fname)) | 345 (w3-open-local fname)) |
404 | 346 |
405 ;;;###autoload | 347 ;;;###autoload |
406 (defun w3-fetch-other-frame (&optional url) | 348 (defun w3-fetch-other-frame (&optional url) |
558 ((and url-be-asynchronous | 500 ((and url-be-asynchronous |
559 (not cached)) | 501 (not cached)) |
560 (save-excursion | 502 (save-excursion |
561 (set-buffer url-working-buffer) | 503 (set-buffer url-working-buffer) |
562 (if x | 504 (if x |
563 (w3-add-urls-to-history x (url-view-url t))) | 505 (w3-history-push x (url-view-url t))) |
564 (setq w3-current-last-buffer lastbuf))) | 506 (setq w3-current-last-buffer lastbuf))) |
565 (t | 507 (t |
566 (w3-add-urls-to-history x url) | 508 (w3-history-push x url) |
567 (w3-sentinel lastbuf) | 509 (w3-sentinel lastbuf) |
568 )))) | 510 (if (string-match "#\\(.*\\)" url) |
511 (progn | |
512 (push-mark (point) t) | |
513 (w3-find-specific-link (match-string 1 url)))))))) | |
569 (if w3-track-last-buffer | 514 (if w3-track-last-buffer |
570 (setq w3-last-buffer buf)) | 515 (setq w3-last-buffer buf)) |
571 (let ((w3-notify (if (memq w3-notify '(newframe bully | 516 (let ((w3-notify (if (memq w3-notify '(newframe bully |
572 semibully aggressive)) | 517 semibully aggressive)) |
573 w3-notify | 518 w3-notify |
582 | 527 |
583 | 528 |
584 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 529 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
585 ;;; History for forward/back buttons | 530 ;;; History for forward/back buttons |
586 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 531 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
587 (defvar w3-node-history nil "History for forward and backward jumping") | 532 (defvar w3-history-stack nil |
588 | 533 "History stack viewing history. |
589 (defun w3-plot-course () | 534 This is an assoc list, with the oldest items first. |
590 "Show a map of where the user has been in this session of W3. !!!!NYI!!!" | 535 Each element is a cons cell of (url . timeobj), where URL |
591 (interactive) | 536 is the normalized URL (default ports removed, etc), and TIMEOBJ is |
592 (error "Sorry, w3-plot-course is not yet implemented.")) | 537 a standard Emacs time. See the `current-time' function documentation |
593 | 538 for information on this format.") |
594 (defun w3-forward-in-history () | 539 |
540 (defun w3-history-find-url-internal (url) | |
541 "Search in the history list for URL. | |
542 Returns a cons cell, where the car is the 'back' node, and | |
543 the cdr is the 'next' node." | |
544 (let* ((node (assoc url w3-history-stack)) | |
545 (next (cadr (memq node w3-history-stack))) | |
546 (last nil) | |
547 (temp nil) | |
548 (todo w3-history-stack)) | |
549 ;; Last node is a little harder to find without using back links | |
550 (while (and (not last) todo) | |
551 (if (string= (caar todo) url) | |
552 (setq last (or temp 'none)) | |
553 (setq temp (pop todo)))) | |
554 (cons (if (not (symbolp last)) last) | |
555 next))) | |
556 | |
557 (defun w3-history-forward () | |
595 "Go forward in the history from this page" | 558 "Go forward in the history from this page" |
596 (interactive) | 559 (interactive) |
597 (let* ((thisurl (url-view-url t)) | 560 (let ((next (cadr (w3-history-find-url-internal (url-view-url t)))) |
598 (node (assoc (if (string= "" thisurl) (current-buffer) thisurl) | 561 (w3-reuse-buffers 'yes)) |
599 w3-node-history)) | 562 (if next |
600 (url (cdr node)) | 563 (w3-fetch next)))) |
601 (w3-reuse-buffers 'yes)) | 564 |
602 (cond | 565 (defun w3-history-backward () |
603 ((null url) (error "No forward found for %s" thisurl)) | |
604 ((and (bufferp url) (buffer-name url)) | |
605 (switch-to-buffer url)) | |
606 ((stringp url) | |
607 (w3-fetch url)) | |
608 ((bufferp url) | |
609 (setq w3-node-history (delete node w3-node-history)) | |
610 (error "Killed buffer in history, removed.")) | |
611 (t | |
612 (error "Something is very wrong with the history!"))))) | |
613 | |
614 (defun w3-backward-in-history () | |
615 "Go backward in the history from this page" | 566 "Go backward in the history from this page" |
616 (interactive) | 567 (interactive) |
617 (let* ((thisurl (url-view-url t)) | 568 (let ((last (caar (w3-history-find-url-internal (url-view-url t)))) |
618 (node (rassoc (if (string= thisurl "") (current-buffer) thisurl) | 569 (w3-reuse-buffers 'yes)) |
619 w3-node-history)) | 570 (if last |
620 (url (car node)) | 571 (w3-fetch last)))) |
621 (w3-reuse-buffers 'yes)) | 572 |
622 (cond | 573 (defun w3-history-push (referer url) |
623 ((null url) (error "No backward found for %s" thisurl)) | |
624 ((and (bufferp url) (buffer-name url)) | |
625 (switch-to-buffer url)) | |
626 ((stringp url) | |
627 (w3-fetch url)) | |
628 ((bufferp url) | |
629 (setq w3-node-history (delete node w3-node-history)) | |
630 (error "Killed buffer in history, removed.")) | |
631 (t | |
632 (error "Something is very wrong with the history!"))))) | |
633 | |
634 (defun w3-add-urls-to-history (referer url) | |
635 "REFERER is the url we followed this link from. URL is the link we got to." | 574 "REFERER is the url we followed this link from. URL is the link we got to." |
636 (let ((node (assoc referer w3-node-history))) | 575 (if (not referer) |
637 (if node | 576 (setq w3-history-stack (list (cons url (current-time)))) |
638 (setcdr node url) | 577 (let ((node (memq (assoc referer w3-history-stack) w3-history-stack))) |
639 (setq w3-node-history (cons (cons referer url) w3-node-history))))) | 578 (if node |
579 (setcdr node (list (cons url (current-time)))))))) | |
580 | |
581 (defalias 'w3-add-urls-to-history 'w3-history-push) | |
582 (defalias 'w3-backward-in-history 'w3-history-backward) | |
583 (defalias 'w3-forward-in-history 'w3-history-forward) | |
640 | 584 |
641 | 585 |
642 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 586 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
643 ;;; Miscellaneous functions | 587 ;;; Miscellaneous functions |
644 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 588 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
761 (defun w3-truncate-menu-item (string) | 705 (defun w3-truncate-menu-item (string) |
762 (if (<= (length string) w3-max-menu-width) | 706 (if (<= (length string) w3-max-menu-width) |
763 string | 707 string |
764 (concat (substring string 0 w3-max-menu-width) "$"))) | 708 (concat (substring string 0 w3-max-menu-width) "$"))) |
765 | 709 |
766 (defun w3-use-starting-documents () | |
767 "Use the list of predefined starting documents from w3-starting-documents" | |
768 (interactive) | |
769 (let ((w3-hotlist w3-starting-documents)) | |
770 (w3-use-hotlist))) | |
771 | |
772 (defun w3-show-starting-documents () | |
773 "Show the list of predefined starting documents from w3-starting-documents" | |
774 (interactive) | |
775 (if (not w3-setup-done) (w3-do-setup)) | |
776 (w3-fetch "www://auto/starting-points")) | |
777 | |
778 (defun w3-insert-formatted-url (p) | 710 (defun w3-insert-formatted-url (p) |
779 "Insert a formatted url into a buffer. With prefix arg, insert the url | 711 "Insert a formatted url into a buffer. With prefix arg, insert the url |
780 under point." | 712 under point." |
781 (interactive "P") | 713 (interactive "P") |
782 (let (buff str) | 714 (let (buff str) |
783 (cond | 715 (cond |
784 (p | 716 (p |
785 (setq p (widget-at (point))) | 717 (setq p (widget-at (point))) |
786 (or p (error "No url under point")) | 718 (or p (error "No url under point")) |
787 (setq str (format "<A HREF=\"%s\">%s</A>" (widget-get p 'href) | 719 (setq str (format "<a href=\"%s\">%s</a>" (widget-get p 'href) |
788 (read-string "Link text: " | 720 (read-string "Link text: " |
789 (buffer-substring | 721 (buffer-substring |
790 (widget-get p :from) | 722 (widget-get p :from) |
791 (widget-get p :to)))))) | 723 (widget-get p :to)))))) |
792 (t | 724 (t |
793 (setq str (format "<A HREF=\"%s\">%s</A>" (url-view-url t) | 725 (setq str (format "<a href=\"%s\">%s</a>" (url-view-url t) |
794 (read-string "Link text: " (buffer-name)))))) | 726 (read-string "Link text: " (buffer-name)))))) |
795 (setq buff (read-buffer "Insert into buffer: " nil t)) | 727 (setq buff (read-buffer "Insert into buffer: " nil t)) |
796 (if buff | 728 (if buff |
797 (save-excursion | 729 (save-excursion |
798 (set-buffer buff) | 730 (set-buffer buff) |
815 (if (widget-at (point)) | 747 (if (widget-at (point)) |
816 (widget-button-press (point)))) | 748 (widget-button-press (point)))) |
817 | 749 |
818 (defun w3-widget-button-click (e) | 750 (defun w3-widget-button-click (e) |
819 (interactive "@e") | 751 (interactive "@e") |
820 (if (widget-at (event-point e)) | 752 (cond |
821 (widget-button-click e))) | 753 ((and (event-point e) |
754 (widget-at (event-point e))) | |
755 (widget-button-click e)) | |
756 ((and (fboundp 'event-glyph) | |
757 (event-glyph e) | |
758 (glyph-property (event-glyph e) 'widget)) | |
759 (widget-button-click e)))) | |
822 | 760 |
823 (defun w3-breakup-menu (menu-desc max-len) | 761 (defun w3-breakup-menu (menu-desc max-len) |
824 (if (> (length menu-desc) max-len) | 762 (if (> (length menu-desc) max-len) |
825 (cons (cons "More..." (w3-first-n-items menu-desc max-len)) | 763 (cons (cons "More..." (w3-first-n-items menu-desc max-len)) |
826 (w3-breakup-menu (nthcdr max-len menu-desc) max-len)) | 764 (w3-breakup-menu (nthcdr max-len menu-desc) max-len)) |
883 (let ((fname "") | 821 (let ((fname "") |
884 (curname "") | 822 (curname "") |
885 (x 0) | 823 (x 0) |
886 (args command-line-args-left) | 824 (args command-line-args-left) |
887 (w3-strict-width 80) | 825 (w3-strict-width 80) |
888 (w3-delimit-emphasis nil) | |
889 (w3-delimit-links nil) | |
890 (retrieval-function 'w3-fetch) | 826 (retrieval-function 'w3-fetch) |
891 (file-format "text") | 827 (file-format "text") |
892 (header "") | 828 (header "") |
893 (file-extn ".txt")) | 829 (file-extn ".txt")) |
894 (setq file-format (downcase (car args))) | 830 (setq file-format (downcase (car args))) |
1065 (setq content-type "application/postscript") | 1001 (setq content-type "application/postscript") |
1066 (w3-fetch url) | 1002 (w3-fetch url) |
1067 (let ((ps-spool-buffer-name " *w3-temp*")) | 1003 (let ((ps-spool-buffer-name " *w3-temp*")) |
1068 (if (get-buffer ps-spool-buffer-name) | 1004 (if (get-buffer ps-spool-buffer-name) |
1069 (kill-buffer ps-spool-buffer-name)) | 1005 (kill-buffer ps-spool-buffer-name)) |
1070 (w3-print-with-ps-print (current-buffer) | 1006 (ps-spool-buffer-with-faces) |
1071 'ps-spool-buffer-with-faces) | |
1072 (set-buffer ps-spool-buffer-name))) | 1007 (set-buffer ps-spool-buffer-name))) |
1073 ((equal "PostScript" format) | 1008 ((equal "PostScript" format) |
1074 (let ((ps-spool-buffer-name " *w3-temp*")) | 1009 (let ((ps-spool-buffer-name " *w3-temp*")) |
1075 (if (get-buffer ps-spool-buffer-name) | 1010 (if (get-buffer ps-spool-buffer-name) |
1076 (kill-buffer ps-spool-buffer-name)) | 1011 (kill-buffer ps-spool-buffer-name)) |
1077 (setq content-type "application/postscript") | 1012 (setq content-type "application/postscript") |
1078 (w3-print-with-ps-print (current-buffer) | 1013 (ps-spool-buffer-with-faces) |
1079 'ps-spool-buffer-with-faces) | |
1080 (set-buffer ps-spool-buffer-name))) | 1014 (set-buffer ps-spool-buffer-name))) |
1081 ((and under (equal "Formatted Text" format)) | 1015 ((and under (equal "Formatted Text" format)) |
1082 (setq content-type "text/plain; charset=iso-8859-1") | 1016 (setq content-type "text/plain; charset=iso-8859-1") |
1083 (w3-fetch url)) | 1017 (w3-fetch url)) |
1084 ((equal "Formatted Text" format) | 1018 ((equal "Formatted Text" format) |
1087 (let ((old-asynch url-be-asynchronous)) | 1021 (let ((old-asynch url-be-asynchronous)) |
1088 (setq content-type "application/x-latex; charset=iso-8859-1") | 1022 (setq content-type "application/x-latex; charset=iso-8859-1") |
1089 (setq-default url-be-asynchronous nil) | 1023 (setq-default url-be-asynchronous nil) |
1090 (url-retrieve url) | 1024 (url-retrieve url) |
1091 (setq-default url-be-asynchronous old-asynch) | 1025 (setq-default url-be-asynchronous old-asynch) |
1092 (w3-parse-tree-to-latex (w3-parse-buffer (current-buffer) t) | 1026 (w3-parse-tree-to-latex (w3-parse-buffer (current-buffer)) |
1093 url))) | 1027 url))) |
1094 ((equal "LaTeX Source" format) | 1028 ((equal "LaTeX Source" format) |
1095 (setq content-type "application/x-latex; charset=iso-8859-1") | 1029 (setq content-type "application/x-latex; charset=iso-8859-1") |
1096 (w3-parse-tree-to-latex w3-current-parse url))) | 1030 (w3-parse-tree-to-latex w3-current-parse url))) |
1097 (buffer-string)))) | 1031 (buffer-string)))) |
1098 (cond | 1032 (funcall w3-mail-command) |
1099 ((and w3-mutable-windows (fboundp w3-mail-other-window-command)) | |
1100 (funcall w3-mail-other-window-command)) | |
1101 ((fboundp w3-mail-command) | |
1102 (funcall w3-mail-command)) | |
1103 (w3-mutable-windows (mail-other-window)) | |
1104 (t (mail))) | |
1105 (mail-subject) | 1033 (mail-subject) |
1106 (insert format " from URL " url "\n" | 1034 (insert format " from URL " url "\n" |
1107 "Mime-Version: 1.0\n" | 1035 "Mime-Version: 1.0\n" |
1108 "Content-transfer-encoding: 8bit\n" | 1036 "Content-transfer-encoding: 8bit\n" |
1109 "Content-type: " content-type) | 1037 "Content-type: " content-type) |
1110 | |
1111 (re-search-forward mail-header-separator nil) | 1038 (re-search-forward mail-header-separator nil) |
1112 (forward-char 1) | 1039 (forward-char 1) |
1113 (insert (if (equal "HTML Source" format) | 1040 (insert (if (equal "HTML Source" format) |
1114 (format "<BASE HREF=\"%s\">" url) "") | 1041 (format "<BASE HREF=\"%s\">" url) "") |
1115 str) | 1042 str) |
1174 (setq url-current-mime-viewer | 1101 (setq url-current-mime-viewer |
1175 (mm-mime-info (or url-current-mime-type | 1102 (mm-mime-info (or url-current-mime-type |
1176 (mm-extension-to-mime extn)) nil 5))) | 1103 (mm-extension-to-mime extn)) nil 5))) |
1177 (if url-current-mime-viewer | 1104 (if url-current-mime-viewer |
1178 (setq cont (append cont '(w3-pass-to-viewer))) | 1105 (setq cont (append cont '(w3-pass-to-viewer))) |
1179 (setq cont (append cont (list w3-default-action)))) | 1106 (setq cont (append cont (list 'w3-prepare-buffer)))) |
1180 cont))) | 1107 cont))) |
1181 | 1108 |
1182 (defun w3-use-links () | 1109 (defun w3-use-links () |
1183 "Select one of the <LINK> tags from this document and fetch it." | 1110 "Select one of the <LINK> tags from this document and fetch it." |
1184 (interactive) | 1111 (interactive) |
1191 ftp: reference" | 1118 ftp: reference" |
1192 (interactive) | 1119 (interactive) |
1193 (cond | 1120 (cond |
1194 ((and (or (null url-current-type) (equal url-current-type "file")) | 1121 ((and (or (null url-current-type) (equal url-current-type "file")) |
1195 (eq major-mode 'w3-mode)) | 1122 (eq major-mode 'w3-mode)) |
1196 (if w3-mutable-windows | 1123 (find-file url-current-file)) |
1197 (find-file-other-window url-current-file) | |
1198 (find-file url-current-file))) | |
1199 ((equal url-current-type "ftp") | 1124 ((equal url-current-type "ftp") |
1200 (if w3-mutable-windows | 1125 (find-file |
1201 (find-file-other-window | 1126 (format "/%s@%s:%s" url-current-user url-current-server |
1202 (format "/%s@%s:%s" url-current-user url-current-server | 1127 url-current-file))) |
1203 url-current-file)) | |
1204 (find-file | |
1205 (format "/%s@%s:%s" url-current-user url-current-server | |
1206 url-current-file)))) | |
1207 (t (message "Sorry, I can't get that file so you can alter it.")))) | 1128 (t (message "Sorry, I can't get that file so you can alter it.")))) |
1208 | 1129 |
1209 (defun w3-insert-this-url (pref-arg) | 1130 (defun w3-insert-this-url (pref-arg) |
1210 "Insert the current url in another buffer, with prefix ARG, | 1131 "Insert the current url in another buffer, with prefix ARG, |
1211 insert URL under point" | 1132 insert URL under point" |
1267 HTML is the HyperText Markup Language used by the World Wide Web to | 1188 HTML is the HyperText Markup Language used by the World Wide Web to |
1268 specify formatting for text. More information on HTML can be found at | 1189 specify formatting for text. More information on HTML can be found at |
1269 ftp.w3.org:/pub/www/doc." | 1190 ftp.w3.org:/pub/www/doc." |
1270 (interactive) | 1191 (interactive) |
1271 (w3-fetch (concat "www://preview/" (buffer-name)))) | 1192 (w3-fetch (concat "www://preview/" (buffer-name)))) |
1272 | |
1273 (defun w3-edit-source () | |
1274 "Edit the html document just retrieved" | |
1275 (set-buffer url-working-buffer) | |
1276 (let ((ttl (format "Editing %s Annotation: %s" | |
1277 (cond | |
1278 ((eq w3-editing-annotation 'group) "Group") | |
1279 ((eq w3-editing-annotation 'personal) "Personal") | |
1280 (t "Unknown")) | |
1281 (url-basepath url-current-file t))) | |
1282 (str (buffer-string))) | |
1283 (set-buffer (get-buffer-create ttl)) | |
1284 (insert str) | |
1285 (kill-buffer url-working-buffer))) | |
1286 | 1193 |
1287 (defun w3-source () | 1194 (defun w3-source () |
1288 "Show the source of a file" | 1195 "Show the source of a file" |
1289 (let ((tmp (buffer-name (generate-new-buffer "Document Source")))) | 1196 (let ((tmp (buffer-name (generate-new-buffer "Document Source")))) |
1290 (set-buffer url-working-buffer) | 1197 (set-buffer url-working-buffer) |
1326 url-current-file)) | 1233 url-current-file)) |
1327 "text/html"))))) | 1234 "text/html"))))) |
1328 (if (not (string-match "^www:" (or (url-view-url t) ""))) | 1235 (if (not (string-match "^www:" (or (url-view-url t) ""))) |
1329 (w3-convert-code-for-mule url-current-mime-type)) | 1236 (w3-convert-code-for-mule url-current-mime-type)) |
1330 | 1237 |
1331 (let ((x (w3-build-continuation))) | 1238 (let ((x (w3-build-continuation)) |
1239 (url (url-view-url t))) | |
1332 (while x | 1240 (while x |
1333 (funcall (pop x))))) | 1241 (funcall (pop x))))) |
1334 | 1242 |
1335 (defun w3-show-history-list () | 1243 (defun w3-show-history-list () |
1336 "Format the url-history-list prettily and show it to the user" | 1244 "Format the url-history-list prettily and show it to the user" |
1375 nil) ; Do nothing - we have the text already | 1283 nil) ; Do nothing - we have the text already |
1376 ((equal "PostScript" format) | 1284 ((equal "PostScript" format) |
1377 (let ((ps-spool-buffer-name " *w3-temp*")) | 1285 (let ((ps-spool-buffer-name " *w3-temp*")) |
1378 (if (get-buffer ps-spool-buffer-name) | 1286 (if (get-buffer ps-spool-buffer-name) |
1379 (kill-buffer ps-spool-buffer-name)) | 1287 (kill-buffer ps-spool-buffer-name)) |
1380 (w3-print-with-ps-print (current-buffer) | 1288 (ps-spool-buffer-with-faces) |
1381 'ps-spool-buffer-with-faces) | |
1382 (set-buffer ps-spool-buffer-name))) | 1289 (set-buffer ps-spool-buffer-name))) |
1383 ((equal "LaTeX Source" format) | 1290 ((equal "LaTeX Source" format) |
1384 (w3-parse-tree-to-latex w3-current-parse url) | 1291 (w3-parse-tree-to-latex w3-current-parse url) |
1385 (insert-buffer url-working-buffer))) | 1292 (insert-buffer url-working-buffer))) |
1386 (write-region (point-min) (point-max) fname)))) | 1293 (write-region (point-min) (point-max) fname)))) |
1499 | 1406 |
1500 | 1407 |
1501 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1408 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1502 ;;; Functions to handle formatting an html buffer | 1409 ;;; Functions to handle formatting an html buffer |
1503 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1410 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1504 (defun w3-insert-headers () | |
1505 ;; Insert some HTTP/1.0 headers if necessary | |
1506 (url-lazy-message "Inserting HTTP/1.0 headers...") | |
1507 (let ((hdrs (if (eq t w3-show-headers) (mapcar 'car url-current-mime-headers) | |
1508 w3-show-headers)) | |
1509 x y) | |
1510 (goto-char (setq y (point-max))) | |
1511 (while hdrs | |
1512 (if (setq x (w3-in-assoc (car hdrs) url-current-mime-headers)) | |
1513 (insert "<LI> <B>" (car x) "</B>: " (url-insert-entities-in-string | |
1514 (if (numberp (cdr x)) | |
1515 (int-to-string (cdr x)) | |
1516 (cdr x))))) | |
1517 (setq hdrs (cdr hdrs))) | |
1518 (if (= y (point-max)) | |
1519 nil | |
1520 (insert "</UL>") | |
1521 (goto-char y) | |
1522 (url-lazy-message "Inserting HTTP/1.0 headers... done.") | |
1523 (insert "<HR><UL>")))) | |
1524 | |
1525 (defun w3-add-delayed-graphic (widget) | 1411 (defun w3-add-delayed-graphic (widget) |
1526 ;; Add a delayed image for the current buffer. | 1412 ;; Add a delayed image for the current buffer. |
1527 (setq w3-delayed-images (cons widget w3-delayed-images))) | 1413 (setq w3-delayed-images (cons widget w3-delayed-images))) |
1528 | 1414 |
1529 | 1415 |
1735 (insert "\t\t\t\t<li> <a href=\"" (car (cdr (car tmp))) | 1621 (insert "\t\t\t\t<li> <a href=\"" (car (cdr (car tmp))) |
1736 "\">" (url-insert-entities-in-string | 1622 "\">" (url-insert-entities-in-string |
1737 (car (car tmp))) "</a></li>\n") | 1623 (car (car tmp))) "</a></li>\n") |
1738 (setq tmp (cdr tmp))) | 1624 (setq tmp (cdr tmp))) |
1739 (insert "\n\t\t\t</ol>\n\t\t</div>\n\t</body>\n</html>\n"))) | 1625 (insert "\n\t\t\t</ol>\n\t\t</div>\n\t</body>\n</html>\n"))) |
1740 ((equal type "starting-points") | |
1741 (let ((tmp w3-starting-documents)) | |
1742 (insert "<html>\n\t<head>\n\t\t" | |
1743 "<title> Starting Points </title>\n\t</head>\n" | |
1744 "\t<body>\n\t\t<div>\n\t\t\t<h1>Starting Point on the Web" | |
1745 "</h1>\n\t\t\t<ol>\n") | |
1746 (while tmp | |
1747 (insert (format "\t\t\t\t<li> <a href=\"%s\">%s</a></li>\n" | |
1748 (car (cdr (car tmp))) | |
1749 (car (car tmp)))) | |
1750 (setq tmp (cdr tmp))) | |
1751 (insert "\n\t\t\t</ol>\n\t\t</div>\n\t</body>\n</html>\n"))) | |
1752 ((equal type "history") | 1626 ((equal type "history") |
1753 (if (not url-history-list) | 1627 (if (not url-history-list) |
1754 (url-retrieve "www://error/nohist") | 1628 (url-retrieve "www://error/nohist") |
1755 (insert "<html>\n\t<head>\n\t\t" | 1629 (insert "<html>\n\t<head>\n\t\t" |
1756 "<title> History List For This Session of W3</title>" | 1630 "<title> History List For This Session of W3</title>" |
1908 href) | 1782 href) |
1909 (href | 1783 (href |
1910 (message "%s" (url-truncate-url-for-viewing href))) | 1784 (message "%s" (url-truncate-url-for-viewing href))) |
1911 (no-show | 1785 (no-show |
1912 nil) | 1786 nil) |
1787 (widget | |
1788 (widget-echo-help (point))) | |
1913 (t | 1789 (t |
1914 nil)))) | 1790 nil)))) |
1915 | 1791 |
1916 (defun w3-load-delayed-images () | 1792 (defun w3-load-delayed-images () |
1917 "Load inlined images that were delayed, if any." | 1793 "Load inlined images that were delayed, if any." |
2230 (fboundp 'w3-read-netscape-config)) | 2106 (fboundp 'w3-read-netscape-config)) |
2231 (w3-read-netscape-config w3-netscape-configuration-file)) | 2107 (w3-read-netscape-config w3-netscape-configuration-file)) |
2232 | 2108 |
2233 (add-minor-mode 'w3-netscape-emulation-minor-mode " NS" | 2109 (add-minor-mode 'w3-netscape-emulation-minor-mode " NS" |
2234 w3-netscape-emulation-minor-mode-map) | 2110 w3-netscape-emulation-minor-mode-map) |
2235 (add-minor-mode 'w3-annotation-minor-mode " Annotating" | |
2236 w3-annotation-minor-mode-map) | |
2237 (add-minor-mode 'w3-lynx-emulation-minor-mode " Lynx" | 2111 (add-minor-mode 'w3-lynx-emulation-minor-mode " Lynx" |
2238 w3-lynx-emulation-minor-mode-map) | 2112 w3-lynx-emulation-minor-mode-map) |
2239 | 2113 |
2240 (setq url-package-version w3-version-number | 2114 (setq url-package-version w3-version-number |
2241 url-package-name "Emacs-W3") | 2115 url-package-name "Emacs-W3") |
2242 | 2116 |
2243 (w3-emit-image-warnings-if-necessary) | 2117 (w3-emit-image-warnings-if-necessary) |
2244 (if (eq w3-color-use-reducing 'guess) | |
2245 (setq w3-color-use-reducing | |
2246 (cond | |
2247 ((eq (device-type) 'tty) nil) | |
2248 ((fboundp 'device-class) | |
2249 (not (and (memq (device-class) '(TrueColor true-color)) | |
2250 (<= 16 (or (device-bitplanes) 0))))) | |
2251 (t t)))) | |
2252 | 2118 |
2253 (cond | 2119 (cond |
2254 ((memq system-type '(ms-dos ms-windows)) | 2120 ((memq system-type '(ms-dos ms-windows)) |
2255 (setq w3-documents-menu-file (or w3-documents-menu-file | 2121 (setq w3-hotlist-file (or w3-hotlist-file |
2256 (expand-file-name "~/mosaic.mnu")) | |
2257 w3-hotlist-file (or w3-hotlist-file | |
2258 (expand-file-name "~/mosaic.hot")) | 2122 (expand-file-name "~/mosaic.hot")) |
2259 w3-personal-annotation-directory (or w3-personal-annotation-directory | 2123 )) |
2260 (expand-file-name | |
2261 "~/mosaic.ann")))) | |
2262 ((memq system-type '(axp-vms vax-vms)) | 2124 ((memq system-type '(axp-vms vax-vms)) |
2263 (setq w3-documents-menu-file | 2125 (setq w3-hotlist-file (or w3-hotlist-file |
2264 (or w3-documents-menu-file | |
2265 (expand-file-name "decw$system_defaults:documents.menu")) | |
2266 w3-hotlist-file (or w3-hotlist-file | |
2267 (expand-file-name "~/mosaic.hotlist-default")) | 2126 (expand-file-name "~/mosaic.hotlist-default")) |
2268 w3-personal-annotation-directory | 2127 )) |
2269 (or w3-personal-annotation-directory | |
2270 (expand-file-name "~/mosaic-annotations/")))) | |
2271 (t | 2128 (t |
2272 (setq w3-documents-menu-file | 2129 (setq w3-hotlist-file (or w3-hotlist-file |
2273 (or w3-documents-menu-file | |
2274 (expand-file-name "/usr/local/lib/mosaic/documents.menu")) | |
2275 w3-hotlist-file (or w3-hotlist-file | |
2276 (expand-file-name "~/.mosaic-hotlist-default")) | 2130 (expand-file-name "~/.mosaic-hotlist-default")) |
2277 w3-personal-annotation-directory | 2131 ))) |
2278 (or w3-personal-annotation-directory | |
2279 (expand-file-name "~/.mosaic-personal-annotations"))))) | |
2280 | 2132 |
2281 (if (eq w3-delimit-emphasis 'guess) | |
2282 (setq w3-delimit-emphasis | |
2283 (and (not w3-running-xemacs) | |
2284 (not (and w3-running-FSF19 | |
2285 (memq (device-type) '(x ns pm))))))) | |
2286 | |
2287 (if (eq w3-delimit-links 'guess) | |
2288 (setq w3-delimit-links | |
2289 (and (not w3-running-xemacs) | |
2290 (not (and w3-running-FSF19 | |
2291 (memq (device-type) '(x ns pm))))))) | |
2292 | |
2293 ; Set up a hook that will save the history list when | 2133 ; Set up a hook that will save the history list when |
2294 ; exiting emacs | 2134 ; exiting emacs |
2295 (add-hook 'kill-emacs-hook 'w3-kill-emacs-func) | 2135 (add-hook 'kill-emacs-hook 'w3-kill-emacs-func) |
2296 | 2136 |
2297 (mm-parse-mailcaps) | 2137 (mm-parse-mailcaps) |
2298 (mm-parse-mimetypes) | 2138 (mm-parse-mimetypes) |
2299 | 2139 |
2300 ; Load in the hotlist if they haven't set it already | 2140 ; Load in the hotlist if they haven't set it already |
2301 (or w3-hotlist (w3-parse-hotlist)) | 2141 (or w3-hotlist (w3-parse-hotlist)) |
2302 | |
2303 ; Load in their personal annotations if they haven't set them already | |
2304 (or w3-personal-annotations (w3-parse-personal-annotations)) | |
2305 | 2142 |
2306 ; Set the default home page, honoring their defaults, then | 2143 ; Set the default home page, honoring their defaults, then |
2307 ; the standard WWW_HOME, then default to the documentation @ IU | 2144 ; the standard WWW_HOME, then default to the documentation @ IU |
2308 (or w3-default-homepage | 2145 (or w3-default-homepage |
2309 (setq w3-default-homepage | 2146 (setq w3-default-homepage |
2310 (or (getenv "WWW_HOME") | 2147 (or (getenv "WWW_HOME") |
2311 "http://www.cs.indiana.edu/elisp/w3/docs.html"))) | 2148 "http://www.cs.indiana.edu/elisp/w3/docs.html"))) |
2312 | |
2313 ; Set up the documents menu | |
2314 (w3-parse-docs-menu) | |
2315 | 2149 |
2316 ; Set up the entity definition for PGP and PEM authentication | 2150 ; Set up the entity definition for PGP and PEM authentication |
2317 | 2151 |
2318 (run-hooks 'w3-load-hook) | 2152 (run-hooks 'w3-load-hook) |
2319 (setq w3-setup-done t)) | 2153 (setq w3-setup-done t)) |
2481 (w3-mode-version-specifics) | 2315 (w3-mode-version-specifics) |
2482 (w3-menu-install-menus) | 2316 (w3-menu-install-menus) |
2483 (run-hooks 'w3-mode-hook) | 2317 (run-hooks 'w3-mode-hook) |
2484 (widget-setup) | 2318 (widget-setup) |
2485 (setq url-current-passwd-count 0 | 2319 (setq url-current-passwd-count 0 |
2320 inhibit-read-only nil | |
2486 truncate-lines t | 2321 truncate-lines t |
2487 mode-line-format w3-modeline-format) | 2322 mode-line-format w3-modeline-format) |
2488 (if (and w3-current-isindex (equal url-current-type "http")) | 2323 (if (and w3-current-isindex (equal url-current-type "http")) |
2489 (setq mode-line-process "-Searchable"))))) | 2324 (setq mode-line-process "-Searchable"))))) |
2490 | 2325 |