comparison lisp/w3/w3.el @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 8fc7fe29b841
children ec9a17fef872
comparison
equal deleted inserted replaced
25:383a494979f8 26:441bb1e64a06
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/02/13 23:05:56 3 ;; Created: 1997/02/20 21:50:57
4 ;; Version: 1.77 4 ;; Version: 1.82
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.
209 (fmt (cdr-safe (assoc "nametemplate" info)))) ; Template for name 209 (fmt (cdr-safe (assoc "nametemplate" info)))) ; Template for name
210 (cond 210 (cond
211 (fmt nil) 211 (fmt nil)
212 ((cdr-safe (assoc "type" info)) 212 ((cdr-safe (assoc "type" info))
213 (setq fmt (mm-type-to-file (cdr-safe (assoc "type" info)))) 213 (setq fmt (mm-type-to-file (cdr-safe (assoc "type" info))))
214 (if fmt (setq fmt (concat "%s" (car fmt))) 214 (if fmt
215 (setq fmt (concat "%s" (url-file-extension url-current-file)))))) 215 (setq fmt (concat "%s" (car fmt)))
216 (setq fmt (concat "%s" (url-file-extension
217 (url-filename url-current-object)))))))
216 (if (null view) 218 (if (null view)
217 (setq view 'indented-text-mode)) 219 (setq view 'indented-text-mode))
218 (cond 220 (cond
219 ((symbolp view) 221 ((symbolp view)
220 (if (not (memq view '(w3-prepare-buffer w3-print w3-source 222 (if (not (memq view '(w3-prepare-buffer w3-print w3-source
221 w3-default-local-file 223 w3-default-local-file
222 mm-multipart-viewer))) 224 mm-multipart-viewer)))
223 (let ((bufnam (url-generate-new-buffer-name 225 (let ((bufnam (url-generate-new-buffer-name
224 (file-name-nondirectory 226 (file-name-nondirectory
225 (or url-current-file "Unknown"))))) 227 (or (url-filename url-current-object)
228 "Unknown")))))
226 (if (string= bufnam "") 229 (if (string= bufnam "")
227 (setq bufnam (url-generate-new-buffer-name 230 (setq bufnam (url-generate-new-buffer-name
228 (url-view-url t)))) 231 (url-view-url t))))
229 (rename-buffer bufnam) 232 (rename-buffer bufnam)
230 ;; Make the URL show in list-buffers output 233 ;; Make the URL show in list-buffers output
237 (funcall view))) 240 (funcall view)))
238 ((stringp view) 241 ((stringp view)
239 (let ((fname (url-generate-unique-filename fmt)) 242 (let ((fname (url-generate-unique-filename fmt))
240 (proc nil)) 243 (proc nil))
241 (if (url-file-directly-accessible-p (url-view-url t)) 244 (if (url-file-directly-accessible-p (url-view-url t))
242 (make-symbolic-link url-current-file fname t) 245 (make-symbolic-link (url-filename url-current-object) fname t)
243 (mule-write-region-no-coding-system (point-min) (point-max) fname)) 246 (mule-write-region-no-coding-system (point-min) (point-max) fname))
244 (if (get-buffer url-working-buffer) 247 (if (get-buffer url-working-buffer)
245 (kill-buffer url-working-buffer)) 248 (kill-buffer url-working-buffer))
246 (setq view (mm-viewer-unescape view fname url)) 249 (setq view (mm-viewer-unescape view fname url))
247 (message "Passing to viewer %s " view) 250 (message "Passing to viewer %s " view)
456 (setq url (car command-line-args-left) 459 (setq url (car command-line-args-left)
457 command-line-args-left (cdr command-line-args-left))) 460 command-line-args-left (cdr command-line-args-left)))
458 (if (equal url "") (error "No document specified!")) 461 (if (equal url "") (error "No document specified!"))
459 ;; legal use for relative URLs ? 462 ;; legal use for relative URLs ?
460 (if (string-match "^www:[^/].*" url) 463 (if (string-match "^www:[^/].*" url)
461 (setq url (concat (file-name-directory url-current-file) 464 (setq url (concat (file-name-directory (url-filename
465 url-current-object))
462 (substring url 4)))) 466 (substring url 4))))
463 ;; In the common case, this is probably cheaper than searching. 467 ;; In the common case, this is probably cheaper than searching.
464 (while (= (string-to-char url) ? ) 468 (while (= (string-to-char url) ? )
465 (setq url (substring url 1))) 469 (setq url (substring url 1)))
466 (cond 470 (cond
470 (w3-download-url url)) 474 (w3-download-url url))
471 (t 475 (t
472 (let ((x (url-view-url t)) 476 (let ((x (url-view-url t))
473 (lastbuf (current-buffer)) 477 (lastbuf (current-buffer))
474 (buf (url-buffer-visiting url))) 478 (buf (url-buffer-visiting url)))
475 (and x (or (string= "file:nil" x) (string= "" x))
476 (setq x nil))
477 (if (or (not buf) 479 (if (or (not buf)
478 (cond 480 (cond
479 ((not (equal (downcase (or url-request-method "GET")) "get")) t) 481 ((not (equal (downcase (or url-request-method "GET")) "get")) t)
480 ((memq w3-reuse-buffers '(no never reload)) t) 482 ((memq w3-reuse-buffers '(no never reload)) t)
481 ((memq w3-reuse-buffers '(yes reuse always)) nil) 483 ((memq w3-reuse-buffers '(yes reuse always)) nil)
495 (url-working-buffer (cdr status))) 497 (url-working-buffer (cdr status)))
496 (if w3-track-last-buffer 498 (if w3-track-last-buffer
497 (setq w3-last-buffer (get-buffer url-working-buffer))) 499 (setq w3-last-buffer (get-buffer url-working-buffer)))
498 (if (get-buffer url-working-buffer) 500 (if (get-buffer url-working-buffer)
499 (cond 501 (cond
500 ((and url-be-asynchronous 502 ((and url-be-asynchronous (not cached))
501 (not cached))
502 (save-excursion 503 (save-excursion
503 (set-buffer url-working-buffer) 504 (set-buffer url-working-buffer)
504 (if x 505 (if x
505 (w3-history-push x (url-view-url t))) 506 (w3-history-push x (url-view-url t)))
506 (setq w3-current-last-buffer lastbuf))) 507 (setq w3-current-last-buffer lastbuf)))
507 (t 508 (t
508 (w3-history-push x url) 509 (w3-history-push x url)
509 (w3-sentinel lastbuf) 510 (w3-sentinel lastbuf)))))
510 (if (string-match "#\\(.*\\)" url)
511 (progn
512 (push-mark (point) t)
513 (w3-find-specific-link (match-string 1 url))))))))
514 (if w3-track-last-buffer 511 (if w3-track-last-buffer
515 (setq w3-last-buffer buf)) 512 (setq w3-last-buffer buf))
516 (let ((w3-notify (if (memq w3-notify '(newframe bully 513 (let ((w3-notify (if (memq w3-notify '(newframe bully
517 semibully aggressive)) 514 semibully aggressive))
518 w3-notify 515 w3-notify
574 "REFERER is the url we followed this link from. URL is the link we got to." 571 "REFERER is the url we followed this link from. URL is the link we got to."
575 (if (not referer) 572 (if (not referer)
576 (setq w3-history-stack (list (cons url (current-time)))) 573 (setq w3-history-stack (list (cons url (current-time))))
577 (let ((node (memq (assoc referer w3-history-stack) w3-history-stack))) 574 (let ((node (memq (assoc referer w3-history-stack) w3-history-stack)))
578 (if node 575 (if node
579 (setcdr node (list (cons url (current-time)))))))) 576 (setcdr node (list (cons url (current-time))))
577 (setq w3-history-stack (append w3-history-stack
578 (list
579 (cons url (current-time)))))))))
580 580
581 (defalias 'w3-add-urls-to-history 'w3-history-push) 581 (defalias 'w3-add-urls-to-history 'w3-history-push)
582 (defalias 'w3-backward-in-history 'w3-history-backward) 582 (defalias 'w3-backward-in-history 'w3-history-backward)
583 (defalias 'w3-forward-in-history 'w3-history-forward) 583 (defalias 'w3-forward-in-history 'w3-history-forward)
584 584
632 (set-buffer buff) 632 (set-buffer buff)
633 (let* ((url (url-view-url t)) 633 (let* ((url (url-view-url t))
634 (cur-links w3-current-links) 634 (cur-links w3-current-links)
635 (title (buffer-name)) 635 (title (buffer-name))
636 (lastmod (or (cdr-safe (assoc "last-modified" 636 (lastmod (or (cdr-safe (assoc "last-modified"
637 url-current-mime-headers)) 637 url-current-mime-headers))))
638 (and (member url-current-type '("file" "ftp"))
639 (nth 5 (url-file-attributes url)))))
640 (hdrs url-current-mime-headers) 638 (hdrs url-current-mime-headers)
641 (info w3-current-metainfo)) 639 (info w3-current-metainfo))
642 (set-buffer (get-buffer-create url-working-buffer)) 640 (set-buffer (get-buffer-create url-working-buffer))
643 (setq url-current-can-be-cached nil 641 (setq url-current-can-be-cached nil)
644 url-current-type "about"
645 url-current-file "document")
646 (erase-buffer) 642 (erase-buffer)
647 (cond 643 (cond
648 ((stringp lastmod) nil) 644 ((stringp lastmod) nil)
649 ((equal '(0 . 0) lastmod) (setq lastmod nil)) 645 ((equal '(0 . 0) lastmod) (setq lastmod nil))
650 ((consp lastmod) (setq lastmod (current-time-string lastmod))) 646 ((consp lastmod) (setq lastmod (current-time-string lastmod)))
802 "Follow the URL under PT, defaults to link under (point)" 798 "Follow the URL under PT, defaults to link under (point)"
803 (interactive "d") 799 (interactive "d")
804 (let ((url (url-get-url-at-point pt))) 800 (let ((url (url-get-url-at-point pt)))
805 (and url (w3-fetch url)))) 801 (and url (w3-fetch url))))
806 802
807 ;;;###autoload
808 (defun w3-batch-fetch ()
809 "Fetch all the URLs on the command line and save them to files in
810 the current directory. The first argument after the -f w3-batch-fetch
811 on the command line should be a string specifying how to save the
812 information retrieved. If it is \"html\", then the page will be
813 unformatted when it is written to disk. If it is \"text\", then the
814 page will be formatted before it is written to disk. If it is
815 \"binary\" it will not mess with the file extensions, and just save
816 the data in raw binary format. If none of those, the default is
817 \"text\", and the first argument is treated as a normal URL."
818 (if (not w3-setup-done) (w3-do-setup))
819 (if (not noninteractive)
820 (error "`w3-batch-fetch' is to be used only with -batch"))
821 (let ((fname "")
822 (curname "")
823 (x 0)
824 (args command-line-args-left)
825 (w3-strict-width 80)
826 (retrieval-function 'w3-fetch)
827 (file-format "text")
828 (header "")
829 (file-extn ".txt"))
830 (setq file-format (downcase (car args)))
831 (cond
832 ((string= file-format "html")
833 (message "Saving all text as raw HTML...")
834 (setq retrieval-function 'url-retrieve
835 file-extn ".html"
836 header "<BASE HREF=\"%s\">"
837 args (cdr args)))
838 ((string= file-format "binary")
839 (message "Saving as raw binary...")
840 (setq retrieval-function 'url-retrieve
841 file-extn ""
842 args (cdr args)))
843 ((string= file-format "text")
844 (setq header "Text from: %s\n---------------\n")
845 (message "Saving all text as formatted...")
846 (setq args (cdr args)))
847 (t
848 (setq header "Text from: %s\n---------------\n")
849 (message "Going with default, saving all text as formatted...")))
850 (while args
851 (funcall retrieval-function (car args))
852 (goto-char (point-min))
853 (if buffer-read-only (toggle-read-only))
854 (insert (format header (car args)))
855 (setq fname (url-basepath url-current-file t))
856 (if (string= file-extn "") nil
857 (setq fname (url-file-extension fname t)))
858 (if (string= (url-strip-leading-spaces fname) "")
859 (setq fname "root"))
860 (setq curname fname)
861 (while (file-exists-p (concat curname file-extn))
862 (setq curname (concat fname x)
863 x (1+ x)))
864 (setq fname (concat curname file-extn))
865 (write-region (point-min) (point-max) fname)
866 (setq args (cdr args)))))
867
868 (defun w3-fix-spaces (x) 803 (defun w3-fix-spaces (x)
869 "Remove spaces/tabs at the beginning of a string, 804 "Remove spaces/tabs at the beginning of a string,
870 and convert newlines into spaces." 805 and convert newlines into spaces."
871 (url-convert-newlines-to-spaces 806 (url-convert-newlines-to-spaces
872 (url-strip-leading-spaces 807 (url-strip-leading-spaces
913 848
914 (defun w3-source-document (under) 849 (defun w3-source-document (under)
915 "View this document's source" 850 "View this document's source"
916 (interactive "P") 851 (interactive "P")
917 (let* ((url (if under (w3-view-this-url) (url-view-url t))) 852 (let* ((url (if under (w3-view-this-url) (url-view-url t)))
918 (fil (if under nil url-current-file))
919 (src 853 (src
920 (cond 854 (cond
921 ((null url) 855 ((null url)
922 (error "No URL found!")) 856 (error "No URL found!"))
923 ((and under (null url)) (error "No link at point!")) 857 ((and under (null url)) (error "No link at point!"))
926 ((and (not under) w3-current-source) w3-current-source) 860 ((and (not under) w3-current-source) w3-current-source)
927 (t 861 (t
928 (prog2 862 (prog2
929 (url-retrieve url) 863 (url-retrieve url)
930 (buffer-string) 864 (buffer-string)
931 (setq fil (or fil url-current-file))
932 (kill-buffer (current-buffer)))))) 865 (kill-buffer (current-buffer))))))
933 (tmp (url-generate-new-buffer-name url))) 866 (tmp (url-generate-new-buffer-name url)))
934 (if (and url (get-buffer url)) 867 (if (and url (get-buffer url))
935 (cond 868 (cond
936 ((memq w3-reuse-buffers '(no never reload)) 869 ((memq w3-reuse-buffers '(no never reload))
1089 (defun w3-build-continuation () 1022 (defun w3-build-continuation ()
1090 ;; Build a series of functions to be run on this file 1023 ;; Build a series of functions to be run on this file
1091 (save-excursion 1024 (save-excursion
1092 (set-buffer url-working-buffer) 1025 (set-buffer url-working-buffer)
1093 (let ((cont w3-default-continuation) 1026 (let ((cont w3-default-continuation)
1094 (extn (url-file-extension url-current-file))) 1027 (extn (url-file-extension
1028 (url-filename url-current-object))))
1095 (if (assoc extn url-uncompressor-alist) 1029 (if (assoc extn url-uncompressor-alist)
1096 (setq extn (url-file-extension 1030 (setq extn (url-file-extension
1097 (substring url-current-file 0 (- (length extn)))))) 1031 (substring (url-filename url-current-object)
1032 0 (- (length extn))))))
1098 (if w3-source 1033 (if w3-source
1099 (setq url-current-mime-viewer '(("viewer" . w3-source)))) 1034 (setq url-current-mime-viewer '(("viewer" . w3-source))))
1100 (if (not url-current-mime-viewer) 1035 (if (not url-current-mime-viewer)
1101 (setq url-current-mime-viewer 1036 (setq url-current-mime-viewer
1102 (mm-mime-info (or url-current-mime-type 1037 (mm-mime-info (or url-current-mime-type
1115 1050
1116 (defun w3-find-this-file () 1051 (defun w3-find-this-file ()
1117 "Do a find-file on the currently viewed html document if it is a file: or 1052 "Do a find-file on the currently viewed html document if it is a file: or
1118 ftp: reference" 1053 ftp: reference"
1119 (interactive) 1054 (interactive)
1120 (cond 1055 (or url-current-object
1121 ((and (or (null url-current-type) (equal url-current-type "file")) 1056 (error "Not a URL-based buffer"))
1122 (eq major-mode 'w3-mode)) 1057 (let ((type (url-type url-current-object)))
1123 (find-file url-current-file)) 1058 (cond
1124 ((equal url-current-type "ftp") 1059 ((equal type "file")
1125 (find-file 1060 (find-file (url-filename url-current-object)))
1126 (format "/%s@%s:%s" url-current-user url-current-server 1061 ((equal type "ftp")
1127 url-current-file))) 1062 (find-file
1128 (t (message "Sorry, I can't get that file so you can alter it.")))) 1063 (format "/%s@%s:%s"
1064 (url-user url-current-object)
1065 (url-host url-current-object)
1066 (url-filename url-current-object))))
1067 (t (message "Sorry, I can't get that file so you can alter it.")))))
1129 1068
1130 (defun w3-insert-this-url (pref-arg) 1069 (defun w3-insert-this-url (pref-arg)
1131 "Insert the current url in another buffer, with prefix ARG, 1070 "Insert the current url in another buffer, with prefix ARG,
1132 insert URL under point" 1071 insert URL under point"
1133 (interactive "P") 1072 (interactive "P")
1228 ((not (get-buffer url-working-buffer)) nil) 1167 ((not (get-buffer url-working-buffer)) nil)
1229 ((url-mime-response-p) (url-parse-mime-headers))) 1168 ((url-mime-response-p) (url-parse-mime-headers)))
1230 (if (not url-current-mime-type) 1169 (if (not url-current-mime-type)
1231 (setq url-current-mime-type (or (mm-extension-to-mime 1170 (setq url-current-mime-type (or (mm-extension-to-mime
1232 (url-file-extension 1171 (url-file-extension
1233 url-current-file)) 1172 (url-filename
1173 url-current-object)))
1234 "text/html"))))) 1174 "text/html")))))
1235 (if (not (string-match "^www:" (or (url-view-url t) ""))) 1175 (if (not (string-match "^www:" (or (url-view-url t) "")))
1236 (w3-convert-code-for-mule url-current-mime-type)) 1176 (w3-convert-code-for-mule url-current-mime-type))
1237 1177
1238 (let ((x (w3-build-continuation)) 1178 (let ((x (w3-build-continuation))
1568 ;;; Leftover stuff that didn't quite fit into url.el 1508 ;;; Leftover stuff that didn't quite fit into url.el
1569 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1509 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1570 1510
1571 (defun w3-generate-error (type data) 1511 (defun w3-generate-error (type data)
1572 ;; Generate an HTML error buffer for error TYPE with data DATA. 1512 ;; Generate an HTML error buffer for error TYPE with data DATA.
1513 (setq url-current-mime-type "text/html")
1573 (cond 1514 (cond
1574 ((equal type "nofile") 1515 ((equal type "nofile")
1575 (let ((error (save-excursion 1516 (let ((error (save-excursion
1576 (set-buffer (get-buffer-create " *url-error*")) 1517 (set-buffer (get-buffer-create " *url-error*"))
1577 (buffer-string)))) 1518 (buffer-string))))
1643 (let ((base (get-text-property (point-min) 'w3-base buffer))) 1584 (let ((base (get-text-property (point-min) 'w3-base buffer)))
1644 (if base 1585 (if base
1645 (setq base (url-generic-parse-url base))) 1586 (setq base (url-generic-parse-url base)))
1646 (insert-buffer buffer) 1587 (insert-buffer buffer)
1647 (if (not base) 1588 (if (not base)
1648 (setq url-current-type "file" 1589 (setq url-current-object
1649 url-current-server nil 1590 (url-generic-parse-url (concat "file:"
1650 url-current-file (buffer-file-name buffer)) 1591 (buffer-file-name buffer))))
1651 (setq url-current-object base 1592 (setq url-current-object base))))
1652 url-current-type (url-type base)
1653 url-current-user (url-user base)
1654 url-current-port (url-port base)
1655 url-current-server (url-host base)
1656 url-current-file (url-filename base)))))
1657 1593
1658 (defun w3-internal-url (url) 1594 (defun w3-internal-url (url)
1659 ;; Handle internal urls (previewed buffers, etc) 1595 ;; Handle internal urls (previewed buffers, etc)
1660 (if (not (string-match "www:/+\\([^/]+\\)/\\(.*\\)" url)) 1596 (if (not (string-match "www:/+\\([^/]+\\)/\\(.*\\)" url))
1661 (w3-fetch "www://error/") 1597 (w3-fetch "www://error/")
1662 (let ((type (url-match url 1)) 1598 (let ((type (url-match url 1))
1663 (data (url-match url 2))) 1599 (data (url-match url 2)))
1664 (set-buffer (get-buffer-create url-working-buffer)) 1600 (set-buffer (get-buffer-create url-working-buffer))
1665 (setq url-current-type "www"
1666 url-current-server type
1667 url-current-file data)
1668 (cond 1601 (cond
1669 ((equal type "preview") ; Previewing a document 1602 ((equal type "preview") ; Previewing a document
1670 (if (get-buffer data) ; Buffer still exists 1603 (if (get-buffer data) ; Buffer still exists
1671 (w3-internal-handle-preview data) 1604 (w3-internal-handle-preview data)
1672 (url-retrieve (concat "www://error/nobuf/" data)))) 1605 (url-retrieve (concat "www://error/nobuf/" data))))
1690 (unfocus-frame)) 1623 (unfocus-frame))
1691 (display-buffer (find-file-noselect file)))) 1624 (display-buffer (find-file-noselect file))))
1692 1625
1693 (defun w3-default-local-file() 1626 (defun w3-default-local-file()
1694 "Use find-file to open the local file" 1627 "Use find-file to open the local file"
1695 (w3-ff url-current-file)) 1628 (w3-ff (url-filename url-current-object)))
1696 1629
1697 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1630 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1698 ;;; Mode definition ;;; 1631 ;;; Mode definition ;;;
1699 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1632 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1700 (defun w3-search-forward (string) 1633 (defun w3-search-forward (string)
1874 (w3-fetch (car possible))) 1807 (w3-fetch (car possible)))
1875 (otherwise 1808 (otherwise
1876 (w3-fetch (completing-read "Choose an address: " 1809 (w3-fetch (completing-read "Choose an address: "
1877 (mapcar 'list possible) 1810 (mapcar 'list possible)
1878 nil t (car possible)))))) 1811 nil t (car possible))))))
1879 (message "Could not automatically determine authors address, sorry.") 1812 (message "Could not automatically determine authors address, sorry."))))
1880 (sit-for 1)
1881 (w3-fetch (concat "mailto:"
1882 (read-string "Email address: "
1883 (if url-current-server
1884 (concat "@" url-current-server))))))))
1885 1813
1886 (defun w3-kill-emacs-func () 1814 (defun w3-kill-emacs-func ()
1887 "Routine called when exiting emacs. Do miscellaneous clean up." 1815 "Routine called when exiting emacs. Do miscellaneous clean up."
1888 (and (eq url-keep-history t) 1816 (and (eq url-keep-history t)
1889 url-global-history-hash-table 1817 url-global-history-hash-table
2189 (url-inhibit-uncompression t) 2117 (url-inhibit-uncompression t)
2190 (url-mime-accept-string "*/*") 2118 (url-mime-accept-string "*/*")
2191 (urlobj (url-generic-parse-url url)) 2119 (urlobj (url-generic-parse-url url))
2192 (url-working-buffer 2120 (url-working-buffer
2193 (generate-new-buffer (concat " *" url " download*"))) 2121 (generate-new-buffer (concat " *" url " download*")))
2194 (stub-fname (url-remove-compressed-extensions 2122 (stub-fname (url-basepath (or (url-filename urlobj) "") t))
2195 (url-basepath (or (url-filename urlobj) "") t))) 2123 (dir (or mm-download-directory "~/"))
2196 (fname (read-file-name "Filename to save as: " 2124 (fname (expand-file-name
2197 (or mm-download-directory "~/") 2125 (read-file-name "Filename to save as: "
2198 stub-fname 2126 dir
2199 nil 2127 stub-fname
2200 stub-fname))) 2128 nil
2129 stub-fname) dir)))
2201 (setq-default url-be-asynchronous t) 2130 (setq-default url-be-asynchronous t)
2202 (save-excursion 2131 (save-excursion
2203 (set-buffer url-working-buffer) 2132 (set-buffer url-working-buffer)
2204 (setq url-current-callback-data (list fname (current-buffer)) 2133 (setq url-current-callback-data (list fname (current-buffer))
2205 url-be-asynchronous t 2134 url-be-asynchronous t
2290 link-at-point 2219 link-at-point
2291 (concat 2220 (concat
2292 (substring link-at-point 0 17) "...")) 2221 (substring link-at-point 0 17) "..."))
2293 "): ") 2222 "): ")
2294 "Link: ") links-alist nil t)) 2223 "Link: ") links-alist nil t))
2295 (if (setq choice (try-completion choice links-alist)) 2224 (let ((match (try-completion choice links-alist)))
2296 (w3-fetch (cdr (assoc choice links-alist)))))) 2225 (cond
2226 ((eq t match) ; We have an exact match
2227 (setq choice (cdr (assoc choice links-alist))))
2228 ((stringp match)
2229 (setq choice (cdr (assoc match links-alist))))
2230 (t (setq choice nil)))
2231 (if choice
2232 (w3-fetch choice)))))
2297 2233
2298 (defun w3-mode () 2234 (defun w3-mode ()
2299 "Mode for viewing HTML documents. If called interactively, will 2235 "Mode for viewing HTML documents. If called interactively, will
2300 display the current buffer as HTML. 2236 display the current buffer as HTML.
2301 2237
2318 (widget-setup) 2254 (widget-setup)
2319 (setq url-current-passwd-count 0 2255 (setq url-current-passwd-count 0
2320 inhibit-read-only nil 2256 inhibit-read-only nil
2321 truncate-lines t 2257 truncate-lines t
2322 mode-line-format w3-modeline-format) 2258 mode-line-format w3-modeline-format)
2323 (if (and w3-current-isindex (equal url-current-type "http")) 2259 (if w3-current-isindex
2324 (setq mode-line-process "-Searchable"))))) 2260 (setq mode-line-process "-Searchable")))))
2325 2261
2326 (require 'mm) 2262 (require 'mm)
2327 (require 'url) 2263 (require 'url)
2328 (require 'w3-parse) 2264 (require 'w3-parse)