emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Price <moptop99@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [sort-of OT] Help with "request" and "deferred"
Date: Wed, 28 Jan 2015 20:37:37 -0500	[thread overview]
Message-ID: <CAN_Dec-fnLTjp2PphDp8CDsSjJFkhGjK-PHnzHizAm96B-XPmw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2514 bytes --]

in pursuit of the zotero integration I discussed in other threads, I am
trying to write one simple little function to extend Erik's code, and
failing.  Since I'm flailing and going to bed soon:  can anyone see what's
wrong with this function?

The results are generated perfectly well, but the return value of hte
function is

[cl-struct-deferred deferred:default-callback deferred:default-errorback
deferred:default-cancel nil nil nil] [2 times]


whereas I want something like:

"<div style=\"line-height: 1.35; padding-left: 2em; text-indent:-2em;\"
class=\"csl-bib-body\">
  <div class=\"csl-entry\">Suchman, Lucy. “Subject Objects.” <i>Feminist
Theory</i> 12, no. 2 (August 1, 2011): 119–45.
http://resolver.scholarsportal.info/resolve/14647001/v12i0002/119_so.xml
.</div>
  <span class=\"Z3988\"
title=\"url_ver=Z39.88-2004&amp;ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.atitle=Subject%20objects&amp;rft.jtitle=Feminist%20Theory&amp;rft.volume=12&amp;rft.issue=2&amp;rft.aufirst=Lucy&amp;rft.aulast=Suchman&amp;rft.au=Lucy%20Suchman&amp;rft.date=2011-08-01&amp;rft.pages=119-145&amp;rft.spage=119&amp;rft.epage=145&amp;rft.issn=14647001\"></span>
</div>"


-------

(defun org-zotxt-get-html-bib (key)
  ;; (with-output-to-temp-buffer "*help2*"
  ;;   (print key))
  (lexical-let ((d (deferred:new)))
    (request
     (format "%s/items" zotxt-url-base)
     :params `(("key" . ,key)
               ("format" . "bibliography"))
     :parser 'json-read
     :success  (function*
                (lambda (&key data &allow-other-keys)
                  ;; (with-output-to-temp-buffer "*debug*"
                  ;;   (print data))

                  (let* ((results (mapcar (lambda (e)
                                            (cdr (assq 'html e))
                                            )
                                          data))
                         )
                    (with-output-to-temp-buffer "*debug*"
                      (print results))
                    (results)
                    (deferred:callback-post
                      d (if (null results) nil
                          ;; `((:key ,key :citation ,results))
                          (results)
                          ))
                          ))
                    )

                  )
    d))
-------------------

thanks again!

Matt

[-- Attachment #2: Type: text/html, Size: 3560 bytes --]

                 reply	other threads:[~2015-01-29  1:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=CAN_Dec-fnLTjp2PphDp8CDsSjJFkhGjK-PHnzHizAm96B-XPmw@mail.gmail.com \
    --to=moptop99@gmail.com \
    --cc=emacs-orgmode@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).