Modify url-retrieve and related functions and structures to respect a

`silent' flag to signal that the operation should be silent.
parent 20a5e996
2010-10-02 Lars Magne Ingebrigtsen <larsi@gnus.org>
* url-util.el (url-display-percentage): Don't message when the URL
is silent.
(url-lazy-message): Ditto.
* url-http.el (url-http-parse-headers): Pass the SILENT parameter
back to the fetching function.
* url.el (url-retrieve): Add a silent parameter.
(url-retrieve-internal): Ditto.
* url-parse.el (url): Add a `silent' slot in the URL struct.
2010-10-01 Lars Magne Ingebrigtsen <larsi@gnus.org> 2010-10-01 Lars Magne Ingebrigtsen <larsi@gnus.org>
* url-cookie.el (url-cookie-handle-set-cookie): Use * url-cookie.el (url-cookie-handle-set-cookie): Use
......
...@@ -643,7 +643,8 @@ should be shown to the user." ...@@ -643,7 +643,8 @@ should be shown to the user."
(set (make-local-variable 'url-redirect-buffer) (set (make-local-variable 'url-redirect-buffer)
(url-retrieve-internal (url-retrieve-internal
redirect-uri url-callback-function redirect-uri url-callback-function
url-callback-arguments)) url-callback-arguments
(url-silent url-current-object)))
(url-mark-buffer-as-dead buffer)) (url-mark-buffer-as-dead buffer))
;; We hit url-max-redirections, so issue an error and ;; We hit url-max-redirections, so issue an error and
;; stop redirecting. ;; stop redirecting.
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
(&optional type user password host portspec filename (&optional type user password host portspec filename
target attributes fullness)) target attributes fullness))
(:copier nil)) (:copier nil))
type user password host portspec filename target attributes fullness) type user password host portspec filename target attributes fullness silent)
(defsubst url-port (urlobj) (defsubst url-port (urlobj)
(or (url-portspec urlobj) (or (url-portspec urlobj)
......
...@@ -177,11 +177,17 @@ Strips out default port numbers, etc." ...@@ -177,11 +177,17 @@ Strips out default port numbers, etc."
(defun url-lazy-message (&rest args) (defun url-lazy-message (&rest args)
"Just like `message', but is a no-op if called more than once a second. "Just like `message', but is a no-op if called more than once a second.
Will not do anything if `url-show-status' is nil." Will not do anything if `url-show-status' is nil."
(if (or (null url-show-status) (if (or (and url-current-object
(url-silent url-current-object))
(null url-show-status)
(active-minibuffer-window) (active-minibuffer-window)
(= url-lazy-message-time (= url-lazy-message-time
(setq url-lazy-message-time (nth 1 (current-time))))) (setq url-lazy-message-time (nth 1 (current-time)))))
nil nil
(message "hei: %s" url-current-object)
(with-current-buffer (get-buffer-create "back")
(let ((standard-output (current-buffer)))
(backtrace)))
(apply 'message args))) (apply 'message args)))
;;;###autoload ;;;###autoload
...@@ -222,7 +228,9 @@ Will not do anything if `url-show-status' is nil." ...@@ -222,7 +228,9 @@ Will not do anything if `url-show-status' is nil."
;;;###autoload ;;;###autoload
(defun url-display-percentage (fmt perc &rest args) (defun url-display-percentage (fmt perc &rest args)
(when url-show-status (when (and url-show-status
(or (null url-current-object)
(not (url-silent url-current-object))))
(if (null fmt) (if (null fmt)
(if (fboundp 'clear-progress-display) (if (fboundp 'clear-progress-display)
(clear-progress-display)) (clear-progress-display))
......
...@@ -121,7 +121,7 @@ than the one returned initially by `url-retrieve'. In this case, it sets this ...@@ -121,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.") variable in the original buffer as a forwarding pointer.")
;;;###autoload ;;;###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. "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished.
URL is either a string or a parsed URL. URL is either a string or a parsed URL.
...@@ -143,7 +143,9 @@ the callback is not called). ...@@ -143,7 +143,9 @@ the callback is not called).
The variables `url-request-data', `url-request-method' and The variables `url-request-data', `url-request-method' and
`url-request-extra-headers' can be dynamically bound around the `url-request-extra-headers' can be dynamically bound around the
request; dynamic binding of other variables doesn't necessarily 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 ;;; XXX: There is code in Emacs that does dynamic binding
;;; of the following variables around url-retrieve: ;;; of the following variables around url-retrieve:
;;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets, ;;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets,
...@@ -154,12 +156,14 @@ take effect." ...@@ -154,12 +156,14 @@ take effect."
;;; webmail.el; the latter should be updated. Is ;;; webmail.el; the latter should be updated. Is
;;; url-cookie-multiple-line needed anymore? The other url-cookie-* ;;; url-cookie-multiple-line needed anymore? The other url-cookie-*
;;; are (for now) only used in synchronous retrievals. ;;; 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'. "Internal function; external interface is `url-retrieve'.
CBARGS is what the callback will actually receive - the first item is 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-do-setup)
(url-gc-dead-buffers) (url-gc-dead-buffers)
(if (stringp url) (if (stringp url)
...@@ -170,6 +174,7 @@ the list of events, as described in the docstring of `url-retrieve'." ...@@ -170,6 +174,7 @@ the list of events, as described in the docstring of `url-retrieve'."
(error "Must provide a callback function to url-retrieve")) (error "Must provide a callback function to url-retrieve"))
(unless (url-type url) (unless (url-type url)
(error "Bad url: %s" (url-recreate-url url))) (error "Bad url: %s" (url-recreate-url url)))
(setf (url-silent url) silent)
(let ((loader (url-scheme-get-property (url-type url) 'loader)) (let ((loader (url-scheme-get-property (url-type url) 'loader))
(url-using-proxy (if (url-host url) (url-using-proxy (if (url-host url)
(url-find-proxy-for-url url (url-host url)))) (url-find-proxy-for-url url (url-host url))))
...@@ -179,7 +184,8 @@ the list of events, as described in the docstring of `url-retrieve'." ...@@ -179,7 +184,8 @@ the list of events, as described in the docstring of `url-retrieve'."
(setq asynch t (setq asynch t
loader 'url-proxy)) loader 'url-proxy))
(if asynch (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)) (setq buffer (funcall loader url))
(if buffer (if buffer
(with-current-buffer buffer (with-current-buffer buffer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment