Mercurial > emacs
comparison lisp/url/url.el @ 110693:754df5a0efe9
Modify url-retrieve and related functions and structures to respect a
`silent' flag to signal that the operation should be silent.
author | Lars Magne Ingebrigtsen <larsi@gnus.org> |
---|---|
date | Sat, 02 Oct 2010 04:04:20 +0200 |
parents | ecbe0edc4f69 |
children | 417b1e4d63cd |
comparison
equal
deleted
inserted
replaced
110692:5687cf9288cf | 110693:754df5a0efe9 |
---|---|
119 Sometimes while retrieving a URL, the URL library needs to use another buffer | 119 Sometimes while retrieving a URL, the URL library needs to use another buffer |
120 than the one returned initially by `url-retrieve'. In this case, it sets this | 120 than the one returned initially by `url-retrieve'. In this case, it sets this |
121 variable in the original buffer as a forwarding pointer.") | 121 variable in the original buffer as a forwarding pointer.") |
122 | 122 |
123 ;;;###autoload | 123 ;;;###autoload |
124 (defun url-retrieve (url callback &optional cbargs) | 124 (defun url-retrieve (url callback &optional cbargs silent) |
125 "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished. | 125 "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished. |
126 URL is either a string or a parsed URL. | 126 URL is either a string or a parsed URL. |
127 | 127 |
128 CALLBACK is called when the object has been completely retrieved, with | 128 CALLBACK is called when the object has been completely retrieved, with |
129 the current buffer containing the object, and any MIME headers associated | 129 the current buffer containing the object, and any MIME headers associated |
141 the callback is not called). | 141 the callback is not called). |
142 | 142 |
143 The variables `url-request-data', `url-request-method' and | 143 The variables `url-request-data', `url-request-method' and |
144 `url-request-extra-headers' can be dynamically bound around the | 144 `url-request-extra-headers' can be dynamically bound around the |
145 request; dynamic binding of other variables doesn't necessarily | 145 request; dynamic binding of other variables doesn't necessarily |
146 take effect." | 146 take effect. |
147 | |
148 If SILENT, then don't message progress reports and the like." | |
147 ;;; XXX: There is code in Emacs that does dynamic binding | 149 ;;; XXX: There is code in Emacs that does dynamic binding |
148 ;;; of the following variables around url-retrieve: | 150 ;;; of the following variables around url-retrieve: |
149 ;;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets, | 151 ;;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets, |
150 ;;; url-confirmation-func, url-cookie-multiple-line, | 152 ;;; url-confirmation-func, url-cookie-multiple-line, |
151 ;;; url-cookie-{{,secure-}storage,confirmation} | 153 ;;; url-cookie-{{,secure-}storage,confirmation} |
152 ;;; url-standalone-mode and url-gateway-unplugged should work as | 154 ;;; url-standalone-mode and url-gateway-unplugged should work as |
153 ;;; usual. url-confirmation-func is only used in nnwarchive.el and | 155 ;;; usual. url-confirmation-func is only used in nnwarchive.el and |
154 ;;; webmail.el; the latter should be updated. Is | 156 ;;; webmail.el; the latter should be updated. Is |
155 ;;; url-cookie-multiple-line needed anymore? The other url-cookie-* | 157 ;;; url-cookie-multiple-line needed anymore? The other url-cookie-* |
156 ;;; are (for now) only used in synchronous retrievals. | 158 ;;; are (for now) only used in synchronous retrievals. |
157 (url-retrieve-internal url callback (cons nil cbargs))) | 159 (url-retrieve-internal url callback (cons nil cbargs) silent)) |
158 | 160 |
159 (defun url-retrieve-internal (url callback cbargs) | 161 (defun url-retrieve-internal (url callback cbargs &optional silent) |
160 "Internal function; external interface is `url-retrieve'. | 162 "Internal function; external interface is `url-retrieve'. |
161 CBARGS is what the callback will actually receive - the first item is | 163 CBARGS is what the callback will actually receive - the first item is |
162 the list of events, as described in the docstring of `url-retrieve'." | 164 the list of events, as described in the docstring of `url-retrieve'. |
165 | |
166 If SILENT, don't message progress reports and the like." | |
163 (url-do-setup) | 167 (url-do-setup) |
164 (url-gc-dead-buffers) | 168 (url-gc-dead-buffers) |
165 (if (stringp url) | 169 (if (stringp url) |
166 (set-text-properties 0 (length url) nil url)) | 170 (set-text-properties 0 (length url) nil url)) |
167 (if (not (vectorp url)) | 171 (if (not (vectorp url)) |
168 (setq url (url-generic-parse-url url))) | 172 (setq url (url-generic-parse-url url))) |
169 (if (not (functionp callback)) | 173 (if (not (functionp callback)) |
170 (error "Must provide a callback function to url-retrieve")) | 174 (error "Must provide a callback function to url-retrieve")) |
171 (unless (url-type url) | 175 (unless (url-type url) |
172 (error "Bad url: %s" (url-recreate-url url))) | 176 (error "Bad url: %s" (url-recreate-url url))) |
177 (setf (url-silent url) silent) | |
173 (let ((loader (url-scheme-get-property (url-type url) 'loader)) | 178 (let ((loader (url-scheme-get-property (url-type url) 'loader)) |
174 (url-using-proxy (if (url-host url) | 179 (url-using-proxy (if (url-host url) |
175 (url-find-proxy-for-url url (url-host url)))) | 180 (url-find-proxy-for-url url (url-host url)))) |
176 (buffer nil) | 181 (buffer nil) |
177 (asynch (url-scheme-get-property (url-type url) 'asynchronous-p))) | 182 (asynch (url-scheme-get-property (url-type url) 'asynchronous-p))) |
178 (if url-using-proxy | 183 (if url-using-proxy |
179 (setq asynch t | 184 (setq asynch t |
180 loader 'url-proxy)) | 185 loader 'url-proxy)) |
181 (if asynch | 186 (if asynch |
182 (setq buffer (funcall loader url callback cbargs)) | 187 (let ((url-current-object url)) |
188 (setq buffer (funcall loader url callback cbargs))) | |
183 (setq buffer (funcall loader url)) | 189 (setq buffer (funcall loader url)) |
184 (if buffer | 190 (if buffer |
185 (with-current-buffer buffer | 191 (with-current-buffer buffer |
186 (apply callback cbargs)))) | 192 (apply callback cbargs)))) |
187 (if url-history-track | 193 (if url-history-track |