]> code.delx.au - gnu-emacs/blobdiff - lisp/url/url.el
Merge from emacs-23
[gnu-emacs] / lisp / url / url.el
index 34b3f6540822a86e825919cd859d26a77c0af11f..fe584a97dd0b65c234e808b995521240bf64e6d9 100644 (file)
@@ -1,27 +1,25 @@
 ;;; url.el --- Uniform Resource Locator retrieval tool
 
-;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004,
-;;   2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010, 2011  Free Software Foundation, Inc.
 
 ;; Author: Bill Perry <wmperry@gnu.org>
 ;; Keywords: comm, data, processes, hypermedia
 
 ;; This file is part of GNU Emacs.
 ;;
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-;;
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
-;;
+
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 
 (eval-when-compile (require 'cl))
 
+(require 'mailcap)
+
 (eval-when-compile
   (require 'mm-decode)
   (require 'mm-view))
 
-(require 'mailcap)
 (require 'url-vars)
 (require 'url-cookie)
 (require 'url-history)
 (require 'url-util)
 
 
-;; FIXME convert-standard-filename?
 (defcustom url-configuration-directory
-  (if (and (file-directory-p user-emacs-directory)
-           (not (file-directory-p "~/.url")))
-      (expand-file-name "url" user-emacs-directory)
-    "~/.url")
+  (locate-user-emacs-file "url/" ".url/")
   "Directory used by the URL package for cookies, history, etc."
   :type 'directory
   :group 'url)
 
 (defun url-do-setup ()
-  "Setup the url package.
+  "Setup the URL package.
 This is to avoid conflict with user settings if URL is dumped with
 Emacs."
   (unless url-setup-done
@@ -126,7 +121,7 @@ than the one returned initially by `url-retrieve'.  In this case, it sets this
 variable in the original buffer as a forwarding pointer.")
 
 ;;;###autoload
-(defun url-retrieve (url callback &optional cbargs)
+(defun url-retrieve (url callback &optional cbargs silent)
   "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished.
 URL is either a string or a parsed URL.
 
@@ -148,7 +143,9 @@ the callback is not called).
 The variables `url-request-data', `url-request-method' and
 `url-request-extra-headers' can be dynamically bound around the
 request; dynamic binding of other variables doesn't necessarily
-take effect."
+take effect.
+
+If SILENT, then don't message progress reports and the like."
 ;;; XXX: There is code in Emacs that does dynamic binding
 ;;; of the following variables around url-retrieve:
 ;;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets,
@@ -159,12 +156,14 @@ take effect."
 ;;; webmail.el; the latter should be updated.  Is
 ;;; url-cookie-multiple-line needed anymore?  The other url-cookie-*
 ;;; are (for now) only used in synchronous retrievals.
-  (url-retrieve-internal url callback (cons nil cbargs)))
+  (url-retrieve-internal url callback (cons nil cbargs) silent))
 
-(defun url-retrieve-internal (url callback cbargs)
+(defun url-retrieve-internal (url callback cbargs &optional silent)
   "Internal function; external interface is `url-retrieve'.
 CBARGS is what the callback will actually receive - the first item is
-the list of events, as described in the docstring of `url-retrieve'."
+the list of events, as described in the docstring of `url-retrieve'.
+
+If SILENT, don't message progress reports and the like."
   (url-do-setup)
   (url-gc-dead-buffers)
   (if (stringp url)
@@ -175,6 +174,7 @@ the list of events, as described in the docstring of `url-retrieve'."
       (error "Must provide a callback function to url-retrieve"))
   (unless (url-type url)
     (error "Bad url: %s" (url-recreate-url url)))
+  (setf (url-silent url) silent)
   (let ((loader (url-scheme-get-property (url-type url) 'loader))
        (url-using-proxy (if (url-host url)
                             (url-find-proxy-for-url url (url-host url))))
@@ -184,7 +184,8 @@ the list of events, as described in the docstring of `url-retrieve'."
        (setq asynch t
              loader 'url-proxy))
     (if asynch
-       (setq buffer (funcall loader url callback cbargs))
+       (let ((url-current-object url))
+         (setq buffer (funcall loader url callback cbargs)))
       (setq buffer (funcall loader url))
       (if buffer
          (with-current-buffer buffer
@@ -325,5 +326,4 @@ no further processing).  URL is either a string or a parsed URL."
 
 (provide 'url)
 
-;; arch-tag: bc182f1f-d187-4f10-b961-47af2066579a
 ;;; url.el ends here