Hi will,
I haven't gotten very far with this yet, but adding a couple
of lines to the definition of org-add-link-type in
org-zotxt.el (around line 150,
https://bitbucket.org/egh/zotxt-emacs/src/74702e2b2f2aa0427f099eb4fe69dce8709f67fc/org-zotxt.el?at=master)
at least allows for unformatted, plain-text reproduction of
citations:
------------------
(org-add-link-type "zotero"
(lambda (rest)
(zotxt-select-key (substring rest 15)))
(lambda (path desc format)
(if (and (eq format 'latex)
(string-match
"^@\\(.*\\)$"
desc))
(format "\\cite{%s}" (match-string 1
desc))
nil)
(if ( eq format 'html)
(format "%s" desc)
nil)))
-------------------
A better option would be to somehow acquire the html that the
Zotero extension "zotxt" generates when zotxt.el requests the
formatted citation from it. I'm not quite sure how to do this,
but I htink the action happens zotxt-choose-deferred, which
starts on line 125 of zotxt.el (
https://bitbucket.org/egh/zotxt-emacs/src/74702e2b2f2aa0427f099eb4fe69dce8709f67fc/zotxt.el?at=master):
---------------------
(defun zotxt-choose-deferred (&optional method search-string)
"Prompt a user for a search string, then ask the user to select an item from the citation.
If METHOD is supplied, it should be one of :title-creator-year, :fields, or :everything.
If SEARCH-STRING is supplied, it should be the search string."
(if (null method)
(let ((method-name
(zotxt-completing-read
"Zotero search method (nothing for title, creator, year): "
zotxt-quicksearch-method-names
nil t nil nil "title, creator, year")))
(setq method (cdr (assoc method-name zotxt-quicksearch-method-names)))))
(if (null search-string)
(setq search-string
(read-string (format "Zotero quicksearch (%s) query: " (cdr (assq method zotxt-quicksearch-method-to-names))))))
(lexical-let ((d (deferred:new)))
(request
(format "%s/search" zotxt-url-base)
:params `(("q" . ,search-string)
("method" . ,(cdr (assq method zotxt-quicksearch-method-params)))
("format" . "bibliography"))
:parser 'json-read
:success (function*
(lambda (&key data &allow-other-keys)
(let* ((results (mapcar (lambda (e)
(cons (cdr (assq 'text e))
(cdr (assq 'key e))))
data))
(count (length results))
(citation (if (= 0 count)
nil
(if (= 1 count)
(car (car results))
(zotxt-completing-read "Select item: " results))))
(key (cdr (assoc-string citation results))))
(deferred:callback-post
d (if (null citation) nil
`((:key ,key :citation ,citation))))))))
d))
-------------
My lisp isn't good enough to read this function properly, but apparently the
:citation property of the result item plist is set to the 'text' object of each item.
If one could also add the 'html' object which the zotxt Zotero plugin returns
(the nomenclature is a little misleading, I know), then that information could be made available to emacs/org
for use on export. See line 307-309 of the zotxt extension, here:
https://bitbucket.org/egh/zotxt/src/a12d538ae9245b142fdb55550b2d241e43b82221/extension/bootstrap.js?at=master
Not sure if this helps much? It's the best I have so far! Thanks,
Matt