]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve how url-http displays status messages
authorStefan Kangas <stefan@marxist.se>
Sun, 7 Aug 2022 11:14:20 +0000 (13:14 +0200)
committerStefan Kangas <stefan@marxist.se>
Sun, 7 Aug 2022 11:14:20 +0000 (13:14 +0200)
* lisp/url/url-util.el (url-display-message): New function.
(url-display-percentage): Make obsolete in favor of
url-display-message.

* lisp/url/url-http.el
(url-http-content-length-after-change-function):
Prefer 'url-display-message' to 'url-display-percentage'.
(url-http-content-length-after-change-function)
(url-http-chunked-encoding-after-change-function):
Remove ineffectual calls to 'url-display-percentage'.

lisp/url/url-http.el
lisp/url/url-util.el

index 125f8436f68b697b32834df0e91093d46c30a511..94ef156108ca046d4958c52e79f2f7f8f9e64027 100644 (file)
@@ -1046,19 +1046,15 @@ More sophisticated percentage downloaded, etc.
 Also does minimal parsing of HTTP headers and will actually cause
 the callback to be triggered."
   (if url-http-content-type
-      (url-display-percentage
+      (url-display-message
        "Reading [%s]... %s of %s (%d%%)"
-       (url-percentage (- nd url-http-end-of-headers)
-                      url-http-content-length)
        url-http-content-type
        (funcall byte-count-to-string-function (- nd url-http-end-of-headers))
        (funcall byte-count-to-string-function url-http-content-length)
        (url-percentage (- nd url-http-end-of-headers)
                       url-http-content-length))
-    (url-display-percentage
+    (url-display-message
      "Reading... %s of %s (%d%%)"
-     (url-percentage (- nd url-http-end-of-headers)
-                    url-http-content-length)
      (funcall byte-count-to-string-function (- nd url-http-end-of-headers))
      (funcall byte-count-to-string-function url-http-content-length)
      (url-percentage (- nd url-http-end-of-headers)
@@ -1067,7 +1063,6 @@ the callback to be triggered."
   (if (> (- nd url-http-end-of-headers) url-http-content-length)
       (progn
        ;; Found the end of the document!  Wheee!
-       (url-display-percentage nil nil)
        (url-lazy-message "Reading... done.")
        (if (url-http-parse-headers)
            (url-http-activate-callback)))))
@@ -1097,13 +1092,6 @@ the end of the document."
         ;; one after-change-function call.
         (while read-next-chunk
          (setq no-initial-crlf (= 0 url-http-chunked-counter))
-         (if url-http-content-type
-             (url-display-percentage nil
-                                     "Reading [%s]... chunk #%d"
-                                     url-http-content-type url-http-chunked-counter)
-           (url-display-percentage nil
-                                   "Reading... chunk #%d"
-                                   url-http-chunked-counter))
          (url-http-debug "Reading chunk %d (%d %d %d)"
                          url-http-chunked-counter st nd length)
          (setq regexp (if no-initial-crlf
@@ -1161,7 +1149,6 @@ the end of the document."
                    ;; Found the end of the document!  Wheee!
                    (url-http-debug "Saw end of stream chunk!")
                    (setq read-next-chunk nil)
-                   (url-display-percentage nil nil)
                    ;; Every chunk, even the last 0-length one, is
                    ;; terminated by CRLF.  Skip it.
                    (if (not (looking-at "\r?\n"))
index 48ea947faba50e59584a7eef8a54f7f51971e213..147a643c9fdcb052e709ff33b2f3f1838b744404 100644 (file)
@@ -189,12 +189,18 @@ Will not do anything if `url-show-status' is nil."
   'file-size-human-readable "24.4")
 
 ;;;###autoload
-(defun url-display-percentage (fmt _perc &rest args)
+(defun url-display-message (fmt &rest args)
+  "Like `message', but do nothing if `url-show-status' is nil."
   (when (and url-show-status
              (not (and url-current-object (url-silent url-current-object)))
              fmt)
     (apply #'message fmt args)))
 
+;;;###autoload
+(defun url-display-percentage (fmt _perc &rest args)
+  (declare (obsolete url-display-message "29.1"))
+  (url-display-message fmt args))
+
 ;;;###autoload
 (defun url-percentage (x y)
   (round (* 100 (/ x (float y)))))