title: org-mode capture with sexp
body: <p>I'm trying to get create a capture template that converts an URL to an org-mode link with the <code>&lt;title&gt;</code> as the link name.</p>
  
  <p>My conversion function looks like this:</p>
  
  <pre><code>(defun get-page-title (url)
    "Get title of web page, whose url can be found in the current line"
    ;; Get title of web page, with the help of functions in url.el
    (with-current-buffer (url-retrieve-synchronously url)
      ;; find title by grep the html code
      (goto-char 0)
      (re-search-forward "&lt;title&gt;\\([^&lt;]*\\)&lt;/title&gt;" nil t 1)
      (setq web_title_str (match-string 1))
      ;; find charset by grep the html code
      (goto-char 0)
  
      ;; find the charset, assume utf-8 otherwise
      (if (re-search-forward "charset=\\([-0-9a-zA-Z]*\\)" nil t 1)
          (setq coding_charset (downcase (match-string 1)))
        (setq coding_charset "utf-8")
      ;; decode the string of title.
      (setq web_title_str (decode-coding-string web_title_str (intern
                                                               coding_charset)))
      )
    (concat "[[" url "][" web_title_str "]]")
    ))
  </code></pre>
  
  <p>When called from normal emacs lisp code it returns the correct result. But when used in this <code>org-capture-template</code> it only returns <code>bad url</code>.</p>
  
  <pre><code>setq org-capture-templates
      (quote
       (("l" "Link" entry (file+headline "" "Links")
         "* \"%c\" %(get-page-title \"%c\")"))))
  </code></pre>
  
  <p>Is the order of expansion different? Do I need to escape the string differently? Magic?
  The first <code>%c</code> is only their to debug the string and indeed is getting printed as "url".</p>
  
  <p>Please don't even bother pointing out that parsing XML with regexp is the wrong approach. Cthulhu <strong>is</strong> already haunting me and this isn't going to make it worse.</p>