]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix last change
authorEli Zaretskii <eliz@gnu.org>
Thu, 18 Apr 2024 10:08:23 +0000 (13:08 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 20 Apr 2024 11:06:01 +0000 (14:06 +0300)
* lisp/url/url-util.el (url-build-query-string): Move to after the
definition of 'url-query-key-value-allowed-chars'.

(cherry picked from commit f6c20ed5d5c22ce95df752f482df03209c7c8c42)

lisp/url/url-util.el

index f063efe18a655c0dbc2e2742ca8dd51e281462f2..4d2609cbb95f2bf61f2fb9b3b560547009701d13 100644 (file)
@@ -242,46 +242,6 @@ Will not do anything if `url-show-status' is nil."
           (setq retval (cons (list key val) retval)))))
     retval))
 
-;;;###autoload
-(defun url-build-query-string (query &optional semicolons keep-empty)
-  "Build a query-string.
-
-Given a QUERY in the form:
- ((key1 val1)
-  (key2 val2)
-  (key3 val1 val2)
-  (key4)
-  (key5 \"\"))
-
-\(This is the same format as produced by `url-parse-query-string')
-
-This will return a string
-\"key1=val1&key2=val2&key3=val1&key3=val2&key4&key5\".  Keys may
-be strings or symbols; if they are symbols, the symbol name will
-be used.
-
-When SEMICOLONS is given, the separator will be \";\".
-
-When KEEP-EMPTY is given, empty values will show as \"key=\"
-instead of just \"key\" as in the example above."
-  (mapconcat
-   (lambda (key-vals)
-     (let ((escaped
-            (mapcar (lambda (sym)
-                      (url-hexify-string (format "%s" sym) url-query-key-value-allowed-chars))
-                    key-vals)))
-       (mapconcat (lambda (val)
-                    (let ((vprint (format "%s" val))
-                          (eprint (format "%s" (car escaped))))
-                      (concat eprint
-                              (if (or keep-empty
-                                      (and val (not (zerop (length vprint)))))
-                                  "="
-                                "")
-                              vprint)))
-                  (or (cdr escaped) '("")) (if semicolons ";" "&"))))
-   query (if semicolons ";" "&")))
-
 (defun url-unhex (x)
   (if (> x ?9)
       (if (>= x ?a)
@@ -449,6 +409,47 @@ should return it unchanged."
              (url-hexify-string frag url-query-allowed-chars)))
     (url-recreate-url obj)))
 
+;;;###autoload
+(defun url-build-query-string (query &optional semicolons keep-empty)
+  "Build a query-string.
+
+Given a QUERY in the form:
+ ((key1 val1)
+  (key2 val2)
+  (key3 val1 val2)
+  (key4)
+  (key5 \"\"))
+
+\(This is the same format as produced by `url-parse-query-string')
+
+This will return a string
+\"key1=val1&key2=val2&key3=val1&key3=val2&key4&key5\".  Keys may
+be strings or symbols; if they are symbols, the symbol name will
+be used.
+
+When SEMICOLONS is given, the separator will be \";\".
+
+When KEEP-EMPTY is given, empty values will show as \"key=\"
+instead of just \"key\" as in the example above."
+  (mapconcat
+   (lambda (key-vals)
+     (let ((escaped
+            (mapcar (lambda (sym)
+                      (url-hexify-string (format "%s" sym)
+                                         url-query-key-value-allowed-chars))
+                    key-vals)))
+       (mapconcat (lambda (val)
+                    (let ((vprint (format "%s" val))
+                          (eprint (format "%s" (car escaped))))
+                      (concat eprint
+                              (if (or keep-empty
+                                      (and val (not (zerop (length vprint)))))
+                                  "="
+                                "")
+                              vprint)))
+                  (or (cdr escaped) '("")) (if semicolons ";" "&"))))
+   query (if semicolons ";" "&")))
+
 ;;;###autoload
 (defun url-file-extension (fname &optional x)
   "Return the filename extension of FNAME.