Link to info manual in `defgroup'.
[bpt/emacs.git] / lisp / url / url-vars.el
CommitLineData
8c8b8430 1;;; url-vars.el --- Variables for Uniform Resource Locator tool
2a6c7fe5 2
ba318903
PE
3;; Copyright (C) 1996-1999, 2001, 2004-2014 Free Software Foundation,
4;; Inc.
2a6c7fe5 5
8c8b8430
SM
6;; Keywords: comm, data, processes, hypermedia
7
2a6c7fe5
LH
8;; This file is part of GNU Emacs.
9
4936186e 10;; GNU Emacs is free software: you can redistribute it and/or modify
2a6c7fe5 11;; it under the terms of the GNU General Public License as published by
4936186e
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
2a6c7fe5
LH
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
4936186e 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
2a6c7fe5
LH
22
23;;; Code:
8c8b8430 24
1f3ddf11 25(defconst url-version "Emacs"
8c8b8430
SM
26 "Version number of URL package.")
27
28(defgroup url nil
9a6f3ca5 29 "Uniform Resource Locator tool."
bf247b6e 30 :version "22.1"
ed85dee6
RS
31 :link '(custom-manual "(url) Top")
32 :link '(info-link "(url) Customization")
26f4b8ab 33 :group 'comm)
8c8b8430
SM
34
35(defgroup url-file nil
9a6f3ca5 36 "URL storage."
8c8b8430
SM
37 :prefix "url-"
38 :group 'url)
39
40(defgroup url-cache nil
9a6f3ca5 41 "URL cache."
8c8b8430
SM
42 :prefix "url-"
43 :prefix "url-cache-"
44 :group 'url)
45
46(defgroup url-mime nil
9a6f3ca5 47 "MIME options of URL."
8c8b8430
SM
48 :prefix "url-"
49 :group 'url)
50
51(defgroup url-hairy nil
9a6f3ca5 52 "Hairy options of URL."
8c8b8430
SM
53 :prefix "url-"
54 :group 'url)
55
56
57(defvar url-current-object nil
d1ce47b0 58 "A parsed representation of the current URL.")
8c8b8430
SM
59
60(defvar url-current-mime-headers nil
d1ce47b0 61 "A parsed representation of the MIME headers for the current URL.")
8c8b8430 62
259b63b4
JB
63(mapc 'make-variable-buffer-local
64 '(
65 url-current-object
259b63b4
JB
66 url-current-mime-headers
67 ))
8c8b8430
SM
68
69(defcustom url-honor-refresh-requests t
a5cda60e 70 "Whether to do automatic page reloads.
8c8b8430
SM
71These are done at the request of the document author or the server via
72the `Refresh' header in an HTTP response. If nil, no refresh
73requests will be honored. If t, all refresh requests will be honored.
d1ce47b0 74If non-nil and not t, the user will be asked for each refresh request."
8c8b8430
SM
75 :type '(choice (const :tag "off" nil)
76 (const :tag "on" t)
9c61f806 77 (other :tag "ask" ask))
8c8b8430
SM
78 :group 'url-hairy)
79
80(defcustom url-automatic-caching nil
a5cda60e 81 "If non-nil, all documents will be automatically cached to the local disk."
8c8b8430
SM
82 :type 'boolean
83 :group 'url-cache)
84
016da1c1 85(defconst url-bug-address "bug-gnu-emacs@gnu.org"
8c8b8430
SM
86 "Where to send bug reports.")
87
88(defcustom url-personal-mail-address nil
a5cda60e 89 "Your full email address.
8c8b8430
SM
90This is what is sent to HTTP servers as the FROM field in an HTTP
91request."
92 :type '(choice (const :tag "Unspecified" nil) string)
93 :group 'url)
94
95(defcustom url-directory-index-file "index.html"
a5cda60e 96 "The filename to look for when indexing a directory.
8c8b8430
SM
97If this file exists, and is readable, then it will be viewed instead of
98using `dired' to view the directory."
99 :type 'string
100 :group 'url-file)
101
8c8b8430 102(defcustom url-privacy-level '(email)
5dc3ceeb 103 "How private you want your requests to be.
8c8b8430
SM
104HTTP has header fields for various information about the user, including
105operating system information, email addresses, the last page you visited, etc.
106This variable controls how much of this information is sent.
107
108This should a symbol or a list.
109Valid values if a symbol are:
d1ce47b0
JB
110none -- send all information
111low -- don't send the last location
112high -- don't send the email address or last location
113paranoid -- don't send anything
8c8b8430
SM
114
115If a list, this should be a list of symbols of what NOT to send.
116Valid symbols are:
117email -- the email address
118os -- the operating system info
119lastloc -- the last location
d1ce47b0 120agent -- do not send the User-Agent string
7fb277a9 121cookies -- never accept HTTP cookies
8c8b8430
SM
122
123Samples:
124
125 (setq url-privacy-level 'high)
126 (setq url-privacy-level '(email lastloc)) ;; equivalent to 'high
127 (setq url-privacy-level '(os))
128
129::NOTE::
130This variable controls several other variables and is _NOT_ automatically
131updated. Call the function `url-setup-privacy-info' after modifying this
132variable."
5dc3ceeb
SM
133 :initialize 'custom-initialize-default
134 :set (lambda (sym val) (set-default sym val) (url-setup-privacy-info))
8c8b8430
SM
135 :type '(radio (const :tag "None (you believe in the basic goodness of humanity)"
136 :value none)
137 (const :tag "Low (do not reveal last location)"
138 :value low)
139 (const :tag "High (no email address or last location)"
140 :value high)
141 (const :tag "Paranoid (reveal nothing!)"
142 :value paranoid)
143 (checklist :tag "Custom"
144 (const :tag "Email address" :value email)
145 (const :tag "Operating system" :value os)
146 (const :tag "Last location" :value lastloc)
147 (const :tag "Browser identification" :value agent)
148 (const :tag "No cookies" :value cookie)))
149 :group 'url)
150
151(defvar url-inhibit-uncompression nil "Do not do decompression if non-nil.")
152
153(defcustom url-uncompressor-alist '((".z" . "x-gzip")
154 (".gz" . "x-gzip")
155 (".uue" . "x-uuencoded")
156 (".hqx" . "x-hqx")
157 (".Z" . "x-compress")
076a4db2
LS
158 (".bz2" . "x-bzip2")
159 (".xz" . "x-xz"))
a5cda60e 160 "An alist of file extensions and appropriate content-transfer-encodings."
8c8b8430
SM
161 :type '(repeat (cons :format "%v"
162 (string :tag "Extension")
163 (string :tag "Encoding")))
164 :group 'url-mime)
165
6c9abf6a 166(defcustom url-mail-command 'compose-mail
a5cda60e 167 "This function will be called whenever URL needs to send mail.
8c8b8430
SM
168It should enter a mail-mode-like buffer in the current window.
169The commands `mail-to' and `mail-subject' should still work in this
170buffer, and it should use `mail-header-separator' if possible."
171 :type 'function
172 :group 'url)
173
174(defcustom url-proxy-services nil
a5cda60e 175 "An alist of schemes and proxy servers that gateway them.
8c8b8430
SM
176Looks like ((\"http\" . \"hostname:portnumber\") ...). This is set up
177from the ACCESS_proxy environment variables."
178 :type '(repeat (cons :format "%v"
179 (string :tag "Protocol")
180 (string :tag "Proxy")))
181 :group 'url)
182
8c8b8430 183(defcustom url-standalone-mode nil
a5cda60e 184 "Rely solely on the cache?"
8c8b8430
SM
185 :type 'boolean
186 :group 'url-cache)
187
188(defvar url-mime-separator-chars (mapcar 'identity
189 (concat "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
190 "abcdefghijklmnopqrstuvwxyz"
191 "0123456789'()+_,-./=?"))
192 "Characters allowable in a MIME multipart separator.")
193
194(defcustom url-bad-port-list
195 '("25" "119" "19")
a5cda60e 196 "List of ports to warn the user about connecting to.
8c8b8430
SM
197Defaults to just the mail, chargen, and NNTP ports so you cannot be
198tricked into sending fake mail or forging messages by a malicious HTML
199document."
200 :type '(repeat (string :tag "Port"))
201 :group 'url-hairy)
202
203(defvar url-mime-content-type-charset-regexp
204 ";[ \t]*charset=\"?\\([^\"]+\\)\"?"
205 "Regexp used in parsing `Content-Type' for a charset indication.")
206
207(defvar url-request-data nil "Any data to send with the next request.")
208
209(defvar url-request-extra-headers nil
210 "A list of extra headers to send with the next request.
211Should be an assoc list of headers/contents.")
212
213(defvar url-request-method nil "The method to use for the next request.")
214
d6a04266 215(defvar url-mime-encoding-string (and (fboundp 'zlib-available-p)
7699d09e 216 (zlib-available-p)
6edea0a5 217 "gzip")
fb7ada5f 218 "String to send in the Accept-encoding: field in HTTP requests.")
8c8b8430 219
938beca4
GM
220(defvar mm-mime-mule-charset-alist)
221(declare-function mm-coding-system-p "mm-util" (cs))
222
8c8b8430
SM
223;; Perhaps the first few should actually be given decreasing `q's and
224;; the list should be trimmed significantly.
225;; Fixme: do something sane if we don't have `sort-coding-systems'
226;; (Emacs 20, XEmacs).
227(defun url-mime-charset-string ()
228 "Generate a list of preferred MIME charsets for HTTP requests.
229Generated according to current coding system priorities."
9f9aa044 230 (require 'mm-util)
8c8b8430
SM
231 (if (fboundp 'sort-coding-systems)
232 (let ((ordered (sort-coding-systems
233 (let (accum)
234 (dolist (elt mm-mime-mule-charset-alist)
235 (if (mm-coding-system-p (car elt))
236 (push (car elt) accum)))
237 (nreverse accum)))))
238 (concat (format "%s;q=1, " (pop ordered))
239 (mapconcat 'symbol-name ordered ";q=0.5, ")
240 ";q=0.5"))))
241
b39e2446 242(defvar url-mime-charset-string nil
fb7ada5f 243 "String to send in the Accept-charset: field in HTTP requests.
8c8b8430
SM
244The MIME charset corresponding to the most preferred coding system is
245given priority 1 and the rest are given priority 0.5.")
246
247(defun url-set-mime-charset-string ()
248 (setq url-mime-charset-string (url-mime-charset-string)))
249;; Regenerate if the language environment changes.
250(add-hook 'set-language-environment-hook 'url-set-mime-charset-string)
251
252;; Fixme: set from the locale.
253(defcustom url-mime-language-string nil
a5cda60e 254 "String to send in the Accept-language: field in HTTP requests.
8c8b8430
SM
255
256Specifies the preferred language when servers can serve documents in
d1ce47b0 257several languages. Use RFC 1766 abbreviations, e.g.: `en' for
8c8b8430
SM
258English, `de' for German. A comma-separated specifies descending
259order of preference. The ordering can be made explicit using `q'
260factors defined by HTTP, e.g. `de,en-gb;q=0.8,en;q=0.7'. `*' means
261get the first available language (as opposed to the default)."
262 :type '(radio
263 (const :tag "None (get default language version)" :value nil)
264 (const :tag "Any (get first available language version)" :value "*")
265 (string :tag "Other"))
266 :group 'url-mime
267 :group 'i18n)
268
269(defvar url-mime-accept-string nil
270 "String to send to the server in the Accept: field in HTTP requests.")
271
272(defvar url-package-version nil
273 "Version number of package using URL.")
274
5dc3ceeb 275(defvar url-package-name nil "Name of package using URL.")
8c8b8430
SM
276
277(defvar url-system-type nil
278 "What type of system we are on.")
279(defvar url-os-type nil
280 "What OS we are on.")
281
282(defcustom url-max-password-attempts 5
a5cda60e 283 "Maximum number of times a password will be prompted for.
8c8b8430
SM
284Applies when a protected document is denied by the server."
285 :type 'integer
286 :group 'url)
287
288(defcustom url-temporary-directory (or (getenv "TMPDIR") "/tmp")
a5cda60e 289 "Where temporary files go."
8c8b8430
SM
290 :type 'directory
291 :group 'url-file)
1a399398
CY
292(make-obsolete-variable 'url-temporary-directory
293 'temporary-file-directory "23.1")
8c8b8430
SM
294
295(defcustom url-show-status t
a5cda60e 296 "Whether to show a running total of bytes transferred.
8c8b8430
SM
297Can cause a large hit if using a remote X display over a slow link, or
298a terminal with a slow modem."
299 :type 'boolean
300 :group 'url)
301
302(defvar url-using-proxy nil
303 "Either nil or the fully qualified proxy URL in use, e.g.
d1ce47b0 304http://www.example.com/")
8c8b8430
SM
305
306(defcustom url-news-server nil
a5cda60e 307 "The default news server from which to get newsgroups/articles.
8c8b8430
SM
308Applies if no server is specified in the URL. Defaults to the
309environment variable NNTPSERVER or \"news\" if NNTPSERVER is
310undefined."
311 :type '(choice (const :tag "None" :value nil) string)
312 :group 'url)
313
ce7b18ec
CY
314;; From RFC3986: Scheme names consist of a sequence of characters
315;; beginning with a letter and followed by any combination of letters,
316;; digits, plus ("+"), period ("."), or hyphen ("-").
317
8c8b8430 318(defvar url-nonrelative-link
ce7b18ec 319 "\\`\\([a-zA-Z][-a-zA-Z0-9+.]*:\\)"
8c8b8430
SM
320 "A regular expression that will match an absolute URL.")
321
2faae86b 322(defcustom url-max-redirections 30
a5cda60e 323 "The maximum number of redirection requests to honor in a HTTP connection.
2faae86b
CY
324A negative number means to honor an unlimited number of redirection requests."
325 :type 'integer
326 :group 'url)
327
8c8b8430 328(defcustom url-confirmation-func 'y-or-n-p
a5cda60e 329 "What function to use for asking yes or no functions.
8c8b8430
SM
330Possible values are `yes-or-no-p' or `y-or-n-p', or any function that
331takes a single argument (the prompt), and returns t only if a positive
332answer is given."
333 :type '(choice (const :tag "Short (y or n)" :value y-or-n-p)
334 (const :tag "Long (yes or no)" :value yes-or-no-p)
335 (function :tag "Other"))
336 :group 'url-hairy)
337
338(defcustom url-gateway-method 'native
a5cda60e 339 "The type of gateway support to use.
8c8b8430
SM
340Should be a symbol specifying how to get a connection from the local machine.
341
342Currently supported methods:
343`telnet': Run telnet in a subprocess to connect;
344`rlogin': Rlogin to another machine to connect;
345`socks': Connect through a socks server;
5bbb0eb9
SJ
346`tls': Connect with TLS;
347`ssl': Connect with SSL (deprecated, use `tls' instead);
4c36be58 348`native': Connect directly."
8c8b8430
SM
349 :type '(radio (const :tag "Telnet to gateway host" :value telnet)
350 (const :tag "Rlogin to gateway host" :value rlogin)
351 (const :tag "Use SOCKS proxy" :value socks)
5bbb0eb9
SJ
352 (const :tag "Use SSL/TLS for all connections" :value tls)
353 (const :tag "Use SSL for all connections (obsolete)" :value ssl)
8c8b8430
SM
354 (const :tag "Direct connection" :value native))
355 :group 'url-hairy)
356
357(defvar url-setup-done nil "Has setup configuration been done?")
358
32d3ca3a 359(defconst url-weekday-alist
8c8b8430
SM
360 '(("Sunday" . 0) ("Monday" . 1) ("Tuesday" . 2) ("Wednesday" . 3)
361 ("Thursday" . 4) ("Friday" . 5) ("Saturday" . 6)
362 ("Tues" . 2) ("Thurs" . 4)
363 ("Sun" . 0) ("Mon" . 1) ("Tue" . 2) ("Wed" . 3)
364 ("Thu" . 4) ("Fri" . 5) ("Sat" . 6)))
365
32d3ca3a 366(defconst url-monthabbrev-alist
8c8b8430
SM
367 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6)
368 ("Jul" . 7) ("Aug" . 8) ("Sep" . 9) ("Oct" . 10) ("Nov" . 11)
369 ("Dec" . 12)))
370
371(defvar url-lazy-message-time 0)
372
373;; Fixme: We may not be able to run SSL.
374(defvar url-extensions-header "Security/Digest Security/SSL")
375
376(defvar url-parse-syntax-table
377 (copy-syntax-table emacs-lisp-mode-syntax-table)
fb7ada5f 378 "A syntax table for parsing URLs.")
8c8b8430
SM
379
380(modify-syntax-entry ?' "\"" url-parse-syntax-table)
381(modify-syntax-entry ?` "\"" url-parse-syntax-table)
382(modify-syntax-entry ?< "(>" url-parse-syntax-table)
383(modify-syntax-entry ?> ")<" url-parse-syntax-table)
384(modify-syntax-entry ?/ " " url-parse-syntax-table)
385
f1a4e679
CY
386(defcustom url-load-hook nil
387 "Hook run after initializing the URL library."
388 :group 'url
389 :type 'hook)
8c8b8430
SM
390
391;;; Make OS/2 happy - yeeks
392;; (defvar tcp-binary-process-input-services nil
393;; "*Make OS/2 happy with our CRLF pairs...")
394
395(defconst url-working-buffer " *url-work")
396
397(defvar url-gateway-unplugged nil
9531f95f 398 "Non-nil means don't open new network connections.
8c8b8430
SM
399This should be set, e.g. by mail user agents rendering HTML to avoid
400`bugs' which call home.")
401
8c8b8430
SM
402(provide 'url-vars)
403
404;;; url-vars.el ends here