all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ian Eure <ian@simplegeo.com>
To: 8706@debbugs.gnu.org
Subject: bug#8706: 24.0.50; [PATCH] Function to build a URL query-string
Date: Fri, 20 May 2011 11:37:45 -0700	[thread overview]
Message-ID: <m2aaehrzeu.fsf@gmail.com> (raw)

This patch adds a url-build-query-string method, which performs the opposite job of url-parse-query-string. I find myself needing this method in many projects, and having it in url-util.el seems beneficial.

--- url-util.el.orig	2011-05-20 11:32:42.000000000 -0700
+++ url-util.el	2011-05-20 11:32:15.000000000 -0700
@@ -281,6 +281,20 @@
 	  (setq retval (cons (list key val) retval)))))
     retval))
 
+;;;###autoload
+(defun url-build-query-string (query)
+  "Build a query-string.
+
+Given a QUERY in the form:
+'((key1 val1)
+  (key2 val2))
+
+This will return a string `key1=val1&key2=val2'. Keys may be strings
+or symbols; if they are symbols, the string name will be used."
+
+  (c-concat-separated
+   (mapcar (lambda (pair) (apply 'format "%s=%s" pair)) query) "&"))
+
 (defun url-unhex (x)
   (if (> x ?9)
       (if (>= x ?a)





             reply	other threads:[~2011-05-20 18:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 18:37 Ian Eure [this message]
2011-05-23 14:36 ` bug#8706: 24.0.50; [PATCH] Function to build a URL query-string Ted Zlatanov
     [not found]   ` <87zkmaopfs.fsf@lifelogs.com>
2011-05-25 16:32     ` Ian Eure
2011-05-25 20:31       ` Ted Zlatanov
2011-06-07 17:07         ` Ian Eure
2011-06-07 18:12           ` Stefan Monnier
2011-06-07 18:58           ` Ted Zlatanov
2011-06-11  1:15             ` Ted Zlatanov
2011-06-11  6:32               ` Deniz Dogan
2011-06-11 10:29                 ` Ted Zlatanov
2011-06-14  1:15               ` Ted Zlatanov
2011-06-14  1:29                 ` Ian Eure
2011-06-14 16:14                   ` Glenn Morris
2011-06-14 16:27                     ` Glenn Morris
2011-06-14 16:56                     ` Ted Zlatanov
2011-06-14 16:57                       ` Ian Eure
2012-04-12 19:31                         ` Lars Magne Ingebrigtsen
2012-04-12 19:34                           ` Lars Magne Ingebrigtsen
2012-04-15 23:51                             ` Ted Zlatanov
2012-04-16  0:58                               ` Glenn Morris
2012-04-18 22:37                                 ` Glenn Morris
2012-05-13 19:31                 ` Lars Magne Ingebrigtsen
2012-05-15  8:54                   ` Ted Zlatanov
2011-05-26  0:02       ` Stefan Monnier
2011-05-26 14:33         ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2aaehrzeu.fsf@gmail.com \
    --to=ian@simplegeo.com \
    --cc=8706@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.