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