annotate lisp/url/url-misc.el @ 59534:9bad65481674

2005-01-14 Carsten Dominik <dominik@science.uva.nl> * reftex-cite.el (reftex-bib-sort-year): Catch the case if the year is not given. * reftex-ref.el (reftex-replace-prefix-escapes): Added new escapes %m and %M, fixed bug with %F by adding save-match-data. (reftex-reference): Removed ?. from list of spaces. (reftex-label-info): Added automatic label prefix recognition * reftex-index.el (reftex-index-next-phrase): Added slave parameter to call of `reftex-index-this-phrase' (reftex-index-this-phrase): New optional argument (reftex-index-region-phrases): Added slave parameter to call of `reftex-index-this-phrase' (reftex-display-index): New argument redo (reftex-index-rescan): Added 'redo to arguments of `reftex-display-index' (reftex-index-Rescan, reftex-index-revert) (reftex-index-switch-index-tag): Added 'redo to arguments of `reftex-display-index' (reftex-index-make-phrase-regexp): Fixed bug with case-sensitive indexing. Fixed bug with matching is there is a quote before or after the word. * reftex-cite.el (reftex-all-used-citation-keys): Fix bug when collecting citation keys in lines with comments. (reftex-citation): Prefix argument no longer rescans the document, but forces prompting for optional arguments of cite macros. (reftex-do-citation): Prompting for optional arguments implemented. * reftex-vars.el (reftex-cite-format-builtin): Added optional arguments to most cite commands. (reftex-cite-cleanup-optional-args): New option (reftex-cite-prompt-optional-args): New option. (reftex-trust-label-prefix): New option * reftex-toc.el (reftex-toc-find-section): Added push-mark before changing the position in the buffer. * reftex.el (reftex-prefix-to-typekey-alist): New variable (reftex-compile-variables): Compute reftex-prefix-to-typekey-alist
author Carsten Dominik <dominik@science.uva.nl>
date Fri, 14 Jan 2005 10:12:03 +0000
parents 2954cb243379
children a8fa7c632ee4 ae7fab96922c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; url-misc.el --- Misc Uniform Resource Locator retrieval code
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
2
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
3 ;; Copyright (c) 1996,1997,1998,1999,2002 Free Software Foundation, Inc.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
4
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; Keywords: comm, data, processes
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
7 ;; This file is part of GNU Emacs.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
8
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
12 ;; any later version.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
13
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
17 ;; GNU General Public License for more details.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
18
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
19 ;; You should have received a copy of the GNU General Public License
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
22 ;; Boston, MA 02111-1307, USA.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
23
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
24 ;;; Code:
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25
57512
44bc5df842b7 Load cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 57427
diff changeset
26 (eval-when-compile (require 'cl))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 (require 'url-vars)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28 (require 'url-parse)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 (autoload 'Info-goto-node "info" "" t)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 (autoload 'man "man" nil t)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 (defun url-man (url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34 "Fetch a Unix manual page URL."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 (man (url-filename url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 nil)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 (defun url-info (url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 "Fetch a GNU Info URL."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 ;; Fetch an info node
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 (let* ((fname (url-filename url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 (node (url-unhex-string (or (url-target url) "Top"))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 (if (and fname node)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 (Info-goto-node (concat "(" fname ")" node))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 (error "Malformed url: %s" (url-recreate-url url)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 nil))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 (defun url-do-terminal-emulator (type server port user)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (terminal-emulator
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 (generate-new-buffer (format "%s%s" (if user (concat user "@") "") server))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 (case type
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 (rlogin "rlogin")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 (telnet "telnet")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 (tn3270 "tn3270")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 (otherwise
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 (error "Unknown terminal emulator required: %s" type)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 (case type
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 (rlogin
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 (if user
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 (list server "-l" user)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 (list server)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 (telnet
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 (if user (message "Please log in as user: %s" user))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (if port
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 (list server port)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 (list server)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 (tn3270
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 (if user (message "Please log in as user: %s" user))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 (list server)))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 (defun url-generic-emulator-loader (url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 (let* ((type (intern (downcase (url-type url))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 (server (url-host url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 (name (url-user url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 (port (url-port url)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 (url-do-terminal-emulator type server port name))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 nil)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 (defalias 'url-rlogin 'url-generic-emulator-loader)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 (defalias 'url-telnet 'url-generic-emulator-loader)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 (defalias 'url-tn3270 'url-generic-emulator-loader)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 ;; RFC 2397
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 (defun url-data (url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 "Fetch a data URL (RFC 2397)."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 (let ((mediatype nil)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 ;; The mediatype may need to be hex-encoded too -- see the RFC.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 (desc (url-unhex-string (url-filename url)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 (encoding "8bit")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96 (data nil))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 (save-excursion
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 (if (not (string-match "\\([^,]*\\)?," desc))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 (error "Malformed data URL: %s" desc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 (setq mediatype (match-string 1 desc))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101 (if (and mediatype (string-match ";base64\\'" mediatype))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 (setq mediatype (substring mediatype 0 (match-beginning 0))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103 encoding "base64"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104 (if (or (null mediatype)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 (eq ?\; (aref mediatype 0)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 (setq mediatype (concat "text/plain" mediatype)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 (setq data (url-unhex-string (substring desc (match-end 0)))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 (set-buffer (generate-new-buffer " *url-data*"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109 (mm-disable-multibyte)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 (insert (format "Content-Length: %d\n" (length data))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 "Content-Type: " mediatype "\n"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 "Content-Encoding: " encoding "\n"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 "\n")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 (if data (insert data))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 (current-buffer))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 (provide 'url-misc)
54699
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
118
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
119 ;;; arch-tag: 8c544e1b-d8bc-40a6-b319-f1f37fef65a0
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57512
diff changeset
120 ;;; url-misc.el ends here