Created
December 9, 2009 10:28
-
-
Save dmj/252402 to your computer and use it in GitHub Desktop.
emacs vs. zotero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun dmj/zotero-export-bibtex () | |
"Ask for a search query, export matching items to bibtex." | |
(interactive) | |
(require 'moz) | |
(let* ((query (read-string "Query: ")) | |
(tmpfile (make-temp-name | |
(expand-file-name "zotemacs" temporary-file-directory))) | |
(js (list | |
"var file = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);" | |
(concat | |
"file.initWithPath('" | |
tmpfile | |
"');") | |
"var zotero = Components.classes['@zotero.org/Zotero;1'].getService(Components.interfaces.nsISupports).wrappedJSObject;" | |
"var s = new Zotero.Search();" | |
(concat | |
"s.addCondition('field','contains','" | |
query | |
"');") | |
"var ids = s.search();" | |
"var items = Zotero.Items.get(ids);" | |
"var t = new Zotero.Translate('export');" | |
"t.setLocation(file);"; | |
"t.setTranslator('9cb70025-a888-4a29-a210-93ec52da40d4');" | |
"t.setItems(items);" | |
"t.translate();")) | |
l) | |
(dolist (l js) | |
(comint-send-string (inferior-moz-process) l)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment