Git Product home page Git Product logo

zotero's Introduction

Emacs Zotero

Introduction

Emacs-zotero is a GNU Emacs interface to the Zotero Web API v3. It provides wrapper functions to access the API, functions to cache and sync emacs-zotero with the Zotero server, and a browser to interact with the cache.

Installation

MELPA

Emacs-zotero is now available from MELPA.

Development Version

To follow or contribute to emacs-zotero development, you can browse or clone the Git repository on GitLab:

git clone https://gitlab.com/fvdbeek/emacs-zotero.git

If you are installing manually, make sure that Emacs can find it by adding the following line to your startup file:

(add-to-list 'load-path "/path/to/emacs-zotero")

Dependencies

  • oauth.el: OAuth library
  • ht.el: hash table library
  • s.el: string manipulation library

Usage

To use emacs-zotero, include the following in your init.el or .emacs file:

(require 'zotero)
(require 'zotero-browser)

If you use use-package, you can do the below instead:

(use-package zotero
  :ensure t
  :commands (zotero-browser)
  :init
  (require 'zotero-browser))

Authentication

Accessing non-public libraries requires the use of an Zotero account. An account can be created via the Zotero website. Authentication is not required for read access to public libraries.

Requests for data in a specific library require a user ID or group ID. User IDs are different from usernames and can be found on the API Keys page. M-x zotero-auth-username, M-x zotero-auth-userid, and M-x zotero-auth-api-key return the username, userid and API key, respectively. When you haven’t authorized emacs-zotero already, you will be redirected to authorize.

Group IDs are different from group names and can be retrieved with the zotero-groups.

Authentication using OAuth

The Zotero API uses OAuth 1.0 to authenticate requests. A token can be requested with zotero-auth-authorize:

(zotero-auth-authorize)

The token is stored in a structure of type zotero-auth-token. It is saved for future sessions, by default to your initialization file. The token will be valid indefinitely, unless it is revoked by the user manually.

Manual authentication

For manual authentication without OAuth, you will need a userid, username, token, and secret (the token and secret are the same) from Zotero, and store it in the zotero-auth-token struct:

  1. The userid is mentioned on the [Zotero feeds/API settings page](https://www.zotero.org/settings/keys):
  2. The username is mentioned on the [Zotero account settings page](https://www.zotero.org/settings/account):
  3. Create a new API key on the [Zotero feeds/API settings page](https://www.zotero.org/settings/keys/new). You will be presented a new API key:
  4. Create a Zotero token:
(setq zotero-auth-token (zotero-auth-token-create :token <api-key>
                                                  :token-secret <api-key>
                                                  :userid <userid>
                                                  :username <username>))
  1. Save the token for future sessions:
(customize-save-variable 'zotero-auth-token zotero-auth-token)

API requests

All requests available in the Zotero Web API can be constructed with the zotero-request function. This function is rather complicated, so for your convenience the most common Zotero requests have specialised functions with less options.

Request

Function: zotero-request METHOD RESOURCE &optional KEY &key TYPE ID API-KEY HOST HEADERS PARAMS DATA NO-AUTH

Return the response of the Zotero request.

METHOD is the method to use for the request, i.e. “GET”, “HEAD” “POST”, “PUT”, “PATCH”, or “DELETE”.

RESOURCE is one of:

  • “collections”: collections in the library
  • “collections-top”: top level collections in the library
  • “collection”: a specific collection in the library
  • “subcollections”: subcollections within a specific collection in the library
  • “items”: all items in the library, excluding trashed items
  • “items-top”: top level items in the library, excluding trashed items
  • “trash-items”: items in the trash
  • “item”: a specific item in the library
  • “item-children”: child items under a specific item
  • “publication-items”: items in My Publications
  • “collection-items”: items within a specific collection in the library
  • “collection-items-top”: top level items within a specific collection in the library
  • “searches”: all saved searches in the library
  • “search”: a specific saved search in the library
  • “tags”: all tags in the library, or tags of all types matching a specific name when an url encoded tag is provided
  • “item-tags”: tags associated with a specific item
  • “collection-tags”: tags within a specific collection in the library
  • “items-tags”: all tags in the library, with the ability to filter based on the items
  • “items-top-tags”: tags assigned to top level items
  • “trash-items-tags”: tags assigned to items in the trash
  • “collection-items-tags”: tags assigned to items in a given collection
  • “collection-items-top-tags”: tags assigned to top level items in a given collection
  • “publication-items-tags”: tags assigned to items in My Publications
  • “keys”: the user id and privileges of the given API key
  • “groups”: all groups the current API key has access to, including public groups the key owner belongs to even if the key doesn’t have explicit permissions for them
  • “group”: group metadata
  • “all-fulltext”: all full-text content
  • “item-fulltext”: an item’s full-text content
  • “file”: an item’s attachment file
  • “deleted”: all deleted data.

KEY is the item key, collection key, or search key. Which key is needed varies by resource.

Keyword TYPE is “user” for your personal library, and “group” for the group libraries.

ID is the ID of the personal or group library you want to access, that is the user ID or group ID. Your personal library ID is available at URL ‘https://www.zotero.org/settings/keys/’. For group libraries, the ID can be found by opening the group’s page at URL ‘https://www.zotero.org/groups/’.

API-KEY is the Zotero API key.

If HOST is non-nil, use that instead of zotero-base-url.

HEADERS is an alist of extra headers. The CAR of each cons cell is the field name and the CDR is the field value. HEADERS has the form:

(("Content-Type" . "application/x-www-form-urlencoded"))

PARAMS is an alist of the query string that is part of the URL. The CAR of each cons cell is the parameter, CAR of the CDR is the value. PARAMS has the form:

((key1 val1) (key2 val2) (key3 val1 val2) (key4) (key5 ""))

DATA is the data to be sent to the server.

If NO-AUTH is non-nil, no authentication is used. Authentication is not required for read access to public libraries.

Examples

Below are several examples of web API request URLs taken from the Zotero Web API Documentation and their equivalent emacs-zotero requests:

Multi-object JSON response: top-level items in a collection

Web API request

https://api.zotero.org/users/475425/collections/9KH9TNSJ/items/top?v=3

Emacs-zotero request
(zotero-request "GET"
                "collection-items-top" "475425"
                :type "user"
                :id "475425"
                :no-auth t)

Single-object JSON response: individual item

Web API Request

https://api.zotero.org/users/475425/items/X42A7DEE?v=3

Emacs-zotero request
(zotero-request "GET"
                "item" "X42A7DEE"
                :type "user"
                :id "475425"
                :no-auth t)

Multi-object JSON response: collections for a user

Web API request

https://api.zotero.org/users/475425/collections?v=3

Emacs-zotero request
(zotero-request "GET"
                "collections" "X42A7DEE"
                :type "user"
                :id "475425"
                :no-auth t)

Atom feed: items in a library

Web API request

https://api.zotero.org/users/475425/items?format=atom&v=3

Emacs-zotero request
(zotero-request "GET"
                "items" nil
                :type "user"
                :id "475425"
                :params '(("format" "atom"))
                :no-auth t)

Formatted bibliography: items in a collection

Web API request

https://api.zotero.org/users/475425/collections/9KH9TNSJ/items?format=bib

Emacs-zotero request
(zotero-request "GET"
                "collection-items" "9KH9TNSJ"
                :type "user"
                :id "475425"
                :params '(("format" "bib"))
                :no-auth t)

Response

All request functions return a record of type zotero-response, which contains the following slots:

  • status-code: status code of the response
  • headers: alist of response headers. The CAR of each cons cell is the field name and the CDR is the field value.
  • version: current library version, as returned by the “Last-Modified-Version” header in the response.
  • etag: attachment item’s md5 value, as returned by the “ETag” header in the response.
  • data: data returned in the response. The data is returned as a property list, converted from JSON. The value :json-empty (instead of nil) is used for an empty object to differentiate an empty value and an empty object.

Example

Given a zotero-response object response, you can access the slots by calling (zotero-response-status-code response), (zotero-response-headers response), (zotero-response-version response), (zotero-response-etag response), and (zotero-response-data response). For example:

(setq response (zotero-request "GET"
                               "item" "E4TD9XGL"
                               :type "user"
                               :id "475425"
                               :no-auth t))

(zotero-response-status-code response) ; => 200

(zotero-response-version response) ; => 3662

(zotero-response-data response) ; => (:key "E4TD9XGL" :version 3662 :library (:type "user" :id 475425 :name "Z public library" :links (:alternate (:href "https://www.zotero.org/z_public_library" :type "text/html"))) :links (:self (:href "https://api.zotero.org/users/475425/items/E4TD9XGL" :type "application/json") :alternate (:href "https://www.zotero.org/z_public_library/items/E4TD9XGL" :type "text/html") :up (:href "https://api.zotero.org/users/475425/items/7VLLCTW7" :type "application/json")) :meta (:numChildren :json-false) :data (:key "E4TD9XGL" :version 3662 :parentItem "7VLLCTW7" :itemType "attachment" :linkMode "imported_file" :title "Zotero Blog » Blog Archive » A Unified Zotero Experience.pdf" :accessDate "" :url "" :note "" :contentType "application/pdf" :charset "" :filename "Zotero Blog » Blog Archive » A Unified Zotero Experience.pdf" :md5 "fb8537e562048fc14b4fc9b637e195de" :mtime 1503415007000 :inPublications t :tags [] :relations :json-empty :dateAdded "2017-08-22T15:16:47Z" :dateModified "2017-08-22T15:16:47Z"))

Request functions

The most common Zotero requests are provided in the specialised functions outlined below.

Arguments

The request functions accept one or more of the following arguments:

  • TYPE (string): a valid Zotero API library type: “user” or “group”. Defaults to “user”.
  • ID (string): a valid Zotero API user or group ID. Defaults to the user ID stored in zotero-auth-token.
  • API-KEY (string): a valid Zotero API user key. Defaults to the API key stored in zotero-auth-token.
  • LOCALE (string): the locale, allowing retrieval of localised item types, field types, and creator types. Defaults to “en-US”.
  • KEY (string): a valid item key, collection key, or search key, depending on the resource.
  • OBJECT (plist): a plist of an object. Instead of a plist, OBJECT may be:
    • buffer (read one Lisp expression from the beginning)
    • a function (call it with no arguments)
    • a file (read one Lisp expression from the beginning)
    • a string (takes text from string, starting at the beginning).
  • VERSION (string or number): the last known version number of the object, as returned by the “Last-Modified-Version” response header.

Customization

User Option: zotero-timeout

Timeout in seconds. Default=30.

User Option: zotero-locale

Locale used in translations. Default=”en-US”.

Retrieve items

Function: zotero-items &key TYPE ID API-KEY

Return Zotero library items.

Function: zotero-top &key TYPE ID API-KEY

Return top level Zotero library items.

Function: zotero-publications &key TYPE ID API-KEY

Return the publications from the “My Publications” collection of a user’s library. Only available on user libraries.

Function: zotero-trash &key TYPE ID API-KEY

Return library items from the library’s trash.

Function: zotero-item KEY &key TYPE ID API-KEY

Return a specific item.

Function: zotero-children KEY &key TYPE ID API-KEY

Return the child items of a specific item.

Retrieve collections

Function: zotero-collection-items KEY &key TYPE ID API-KEY

Return items from the specified collection. This includes sub-collection items.

Function: zotero-collection-items-top KEY &key TYPE ID API-KEY

Return top level items from the specified collection.

Function: zotero-collections &key TYPE ID API-KEY

Return a library’s collections. This includes subcollections.

Function: zotero-collections-top &key TYPE ID API-KEY

Return a library’s top level collections.

Function: zotero-collection KEY &key TYPE ID API-KEY

Return a specific collection.

Function: zotero-subcollections KEY &key TYPE ID API-KEY

Return the sub-collections of a specific collection.

Retrieve tags

Function: zotero-tags &key TYPE ID API-KEY

Return a library’s tags.

Function: zotero-item-tags KEY &key TYPE ID API-KEY

Return tags from a specific item.

Function: zotero-collection-tags KEY &key TYPE ID API-KEY

Return tags in a specific collection.

Miscellaneous

Function: zotero-key &optional API-KEY

Return info about the user and group library permissions, based on the API-KEY. Together with zotero-groups, this allows all accessible resources to be determined.

Function: zotero-delete-key &optional API-KEY

Delete the API-KEY.

Function: zotero-groups &key TYPE ID API-KEY

Return the Zotero group data to which the current library ID and API-KEY has access.

Function: zotero-group ID &key API-KEY

Return the metadata of the Zotero group.

Function: zotero-create-group

Create a new group. The Zotero API doesn’t support creating groups, so this function invokes a browser to open a link.

Function: zotero-group-settings ID

Change the group settings of group ID. The Zotero API doesn’t support changing the group settings, so this function invokes a browser to open a link.

Search

Function: zotero-search-items QUERY &optional FULLTEXT INCLUDE-TRASHED &key TYPE ID API-KEY

Search all items.

Function: zotero-search-tags QUERY &optional STARTS-WITH &key TYPE ID API-KEY

Search all tags.

Write items

Function: zotero-create-item OBJECT &key TYPE ID API-KEY

Create an item.

Function: zotero-create-items OBJECTS &key TYPE ID API-KEY

Create multiple items.

Function: zotero-update-item KEY OBJECT VERSION &key TYPE ID API-KEY

Update an existing item.

Function: zotero-update-items OBJECTS &key TYPE ID API-KEY

Update multiple existing items.

Function: zotero-patch-item KEY OBJECT VERSION &key TYPE ID API-KEY

Partially update an existing item.

Function: zotero-delete-item KEY VERSION &key TYPE ID API-KEY

Delete an item.

Function: zotero-delete-items KEYS VERSION &key TYPE ID API-KEY

Delete multiple items.

Write collections

Function: zotero-create-collection OBJECT &key TYPE ID API-KEY

Create a collection.

Function: zotero-create-collection OBJECTS &key TYPE ID API-KEY

Create multiple collections.

Function: zotero-update-collection KEY OBJECT &key TYPE ID API-KEY

Update an existing collection.

Function: zotero-update-collections OBJECTS &key TYPE ID API-KEY

Update multiple existing collections.

Function: zotero-delete-collection KEY VERSION &key TYPE ID API-KEY

Delete a collection.

Function: zotero-delete-collections KEYS VERSION &key TYPE ID API-KEY

Delete multiple collections.

Write searches

Function: zotero-create-search OBJECT &key TYPE ID API-KEY

Create a saved search.

Function: zotero-create-searches OBJECTS &key TYPE ID API-KEY

Create multiple searches.

Function: zotero-update-searches OBJECTS &key TYPE ID API-KEY

Update existing searches.

Function: zotero-delete-searches KEYS VERSION &key TYPE ID API-KEY

Delete multiple searches.

Write tags

Function: zotero-delete-tags TAGS VERSION &key TYPE ID API-KEY

Delete multiple tags.

Retrieve item types and fields

Function: zotero-item-types &optional LOCALE

Return all available item types.

Function: zotero-item-fields &optional LOCALE

Return all available item fields.

Function: zotero-item-type-fields ITEM-TYPE &optional LOCALE

Return all valid fields for the specified item type.

Function: zotero-item-type-creator-types ITEM-TYPE &optional LOCALE

Return all valid creator types for the specified item type.

Function: zotero-creator-fields &optional LOCALE

Return all creator fields.

Function: zotero-attachment-linkmodes

Return the attachment linkmode types.

Retrieve templates

Function: zotero-collection-template

Return a template for a new collection.

Function: zotero-item-template ITEM-TYPE

Return the template for a new item of an item type.

Function: zotero-attachment-template LINKMODE

Return a template for a new attachment item of a linkmode.

Upload files

Function: zotero-attachment-attributes KEY &key TYPE ID API-KEY

Return the attributes of an attachment file.

Function: zotero-file-attributes FILE

Get the attributes of a file. The result is a plist with :filename, :filesize, :content-type, :md5, :mtime, and :accessdate props to be passed to zotero-authorize-upload.

Function: zotero-upload-attachment KEY FILE &optional HASH &key TYPE ID API-KEY

Authorize, upload and register an attachment to an item. This is a convenient wrapper around zotero-authorize-upload, zotero-upload-file, and zotero-register-upload.

Retrieve files

Function: zotero-file KEY &key TYPE ID API-KEY

Return the raw file content of an item.

Function: zotero-download-file KEY &optional FILE DIR CONFIRM &key TYPE ID API-KEY

A convenient wrapper around zotero-file. Download an attachment using the optional path and filename. If neither are supplied, the file is written to the current working directory, and zotero-item is called to determine the attachment filename.

Webpage snapshots prior to Zotero 5.0.93 were saved as zip files. The downloaded file will be given a zip extension.

Recognize files

PDFs are recognized using an undocumented Zotero web service that operates on the first few pages of text using extraction algorithms and known metadata from CrossRef. The Zotero lookup service doesn’t require a Zotero account, and data about the content or results of searches are not logged.

The metadata can be used to create a parent item for the PDF attachment, by looking up item metadata when supplied with a standard identifier.

Command: zotero-recognize-install-pdftools

Install the PDF tools modified by Zotero. The executables are modified to output a preprocessed JSON that contains rich and structured information about the PDF and the text extracted from it, for use with the PDF recognizer.

This function downloads and extracts the binaries available for macOS, Windows and Linux. You can change the installation directory by setting zotero-recognize-pdftools-dir to an appropriate value before calling this function.

If there are no binaries available for your operating system, you should compile them from source and set the variables zotero-recognize-pdftotext, zotero-recognize-pdfinfo, and zotero-recognize-pdfdata to the corresponding paths. The source is available at https://github.com/zotero/cross-poppler.

Function: zotero-recognize FILE

Return metadata recognized from a PDF.

Full-text content

While Zotero is only able to index PDF documents, emacs-zotero can index far more file types. To index documents external dependencies are needed. The pdftotext executable is needed for PDFs, the antiword executable for Microsoft Word documents until version 2003, and the pandoc executable for pandoc compatible markup formats. See the variable zotero-fulltext-pandoc-mimetypes for a list of formats understood by pandoc.

Function: zotero-fulltext-item KEY &key TYPE ID API-KEY

Return fulltext content of an item.

Function: zotero-fulltext-create-item KEY OBJECT &key TYPE ID API-KEY

Create full-text content for an item.

Function: zotero-fulltext-index-item KEY FILE &optional CONTENT-TYPE &key TYPE ID API-KEY

Create full-text content for an item.

This is a convenient wrapper around zotero-fulltext-create-item that is able to index a variety of file formats, including but not limited to:

  • Portable Document Format (PDF)
  • OpenDocument (ODT)
  • Microsoft Word version 2, 6, 7, 97, 2000 and 2003 (DOC)
  • Office Open XML (DOCX)
  • EPUB
  • LaTeX
  • Org-mode.

User Option: zotero-fulltext-pdftotext

Executable for pdftotext. Needed for fulltext indexing of PDF documents. It is freely available and included by default with many Linux distributions, and is also available for Windows as part of the Xpdf Windows port. Default=”pdftotext”.

User Option: zotero-fulltext-pdfinfo

Executable for pdfinfo. Needed for fulltext indexing of PDF documents. It is freely available and included by default with many Linux distributions, and is also available for Windows as part of the Xpdf Windows port. This variable is set by zotero-fulltext-install-pdftools after downloading the PDF tools modified by Zotero. If you compile the PDF tools from source, it should point to the “pdfinfo-*” binary for your operating system. Default=”pdfinfo”.

User Option: zotero-fulltext-pandoc

Executable for pandoc executable. Pandoc is an open-source document converter that supports many formats and is freely available for most operating systems. Default=”pandoc”.

User Option: zotero-fulltext-antiword

Executable for antiword executable. Antiword is an open source reader for proprietary Microsoft Word documents and is freely available for most operating systems. Default=”antiword”.

User Option: zotero-fulltext-max-chars

How much text is indexed. Default: 500000 characters.

User Option: zotero-fulltext-max-pages

How much text is indexed. Default: 100 pages.

The Browser

Zotero provides a user interface to the Zotero library with zotero-browser. The browser allows you to interact with the cache. You can add the browser to your setup by loading it with:

(require 'zotero-browser)

To use the browser, you should do M-x zotero-browser-sync to synchronize the cache with the Zotero server.

The default layout is shown in the screenshot below. It can be changed by using window parameters as explained in the Elisp reference manual accessible from Emacs or online.

screenshot.png

The browser is interactive an has its own keybindings.

Zotero libraries mode

KeyBinding
nMove to next library
pMove to previous library
C-c C-uMove to parent collection
C-c C-nMove to next collection
C-c C-pMove to previous collection
RETDisplay library
eChange group settings
+Create new group
gReload the current buffer
qQuit current window

Zotero collections mode

KeyBinding
nMove to next collection
pMove to previous collection
uMove to parent collection
C-c C-fMove to next collection on same level
C-c C-bMove to previous collection on same level
TABExpand or collapse the children of the current item
S-TABCycle the visibility of children
$Expand all children
M-$Collapse all children
RETDisplay collection
eEdit collection
+Create new collection
DDelete collection
gReload the current buffer
qQuit current window

Zotero items mode

KeyBinding
nMove to next item
pMove to previous item
uMove to parent item
C-c C-fMove to next item on same level
C-c C-bMove to previous item on same level
C-c C-nMove to next collection
C-c C-pMove to previous collection
C-c C-uMove to parent collection
TABExpand or collapse the children of the current item
S-TABCycle the visibility of children
$Expand all children
M-$Collapse all children
RETOpen attachment
eEdit current entry
+Create new item
DDelete item
RRemove item from collection
CCopy item to a collection
MMove item to a parent item
gReload the current buffer

Zotero edit mode

KeyBinding
TABForward
S-TABBackward
RETInvoke button
C-x C-sSave item
C-c C-kReset item
C-c C-cEdit text for the current text field in a separate buffer
M-TAB or C-M-iComplete field
qQuit current window

Cache

Command: zotero-cache-serialize

Serialize the memory cache to the hard drive.

Command: zotero-cache-unserialize

Serialize the hard drive to the memory cache.

Command: zotero-cache-erase &optional NO-CONFIRM

Erase the cache. If optional argument NO-CONFIRM is non-nil, don’t ask for confirmation.

Command: zotero-cache-maybe-initialize-cache

Initialize the cache if needed.

User Option: zotero-cache-enable-caching

Caching is automatically enabled by default.

User Option: zotero-cache-enable-storage

Storage of attachment files is automatically enabled by default.

User Option: zotero-cache-file

The cache file. By default “zotero-cache” in user-emacs-directory.

User Option: zotero-cache-storage-dir

Attachment storage directory. By default “zotero-storage” in user-emacs-directory.

User Option: zotero-cache-expire

Number of seconds before the cache expires. Default=86400 (one day).

Sync

Command: zotero-browser-sync &optional FULL-SYNC

Sync the Zotero library, templates, schemas and file storage. When optional argument FULL-SYNC is non-nil, or with a C-u prefix, force a full sync.

User Option: zotero-sync-max-delay

Seconds to wait before stopping sync retries; set to 0 to disable retrying. Default=3600.

User Option: zotero-sync-max-retries

Maximum sync retries. Set to 0 to disable retrying. Default=100.

Browser functions

Command: zotero-browser

Create a new Zotero browser buffer.

Command: zotero-browser-display

Display current library or collection.

Command: zotero-browser-open-attachment

Open attachment at point.

Command: zotero-browser-ensure-browser-buffer

Check if the current buffer is a Zotero browser buffer.

Command: zotero-browser-ensure-items-mode

Check if the current buffer is a Zotero items buffer.

Command: zotero-browser-ensure-write-access

Check if the library in the current buffer has write access.

Command: zotero-browser-ensure-item-at-point

Check if there is an item at point.

Command: zotero-browser-revert

Reload the current buffer.

Command zotero-browser-next

Move point to the next item.

Command: zotero-browser-prev

Move point to the previous item.

Command: zotero-browser-up

Move point to the parent item.

Command: zotero-browser-next-collection

Move point to the next collection.

Command: zotero-browser-prev-collection

Move point to the previous collection.

Command: zotero-browser-up-collection

Move point to the parent collection.

Command: zotero-browser-all-items

Show all items.

Command: zotero-browser-unfiled-items

Show unfiled items.

Command: zotero-browser-trash-items

Show trashed items.

Command: zotero-browser-toggle

Expand or collapse the children of the current item.

Command: zotero-browser-cycle

Cycle the visibility of children.

Command: zotero-browser-expand-all

Expand all children.

Command: zotero-browser-collapse-all

Collapse all children.

Command: zotero-browser-expand-level &optional NUM

Expand children till level NUM. If NUM is omitted or nil, expand till level 1.

Command: zotero-browser-edit

Edit current entry.

Command: zotero-browser-move-to-parent &optional ARG

Move current entry to a parent item. With a C-u prefix, move to top level.

Command: zotero-browser-move-to-collection

Move current entry to a collection.

Command: zotero-browser-copy-to-collection

Copy current entry to another collection.

Command: zotero-browser-remove-from-collection

Remove current entry from the collection.

Command: zotero-browser-move-to-trash

Move current entry to trash. If region is active, trash entries in active region instead.

Command: zotero-browser-restore-from-trash

Restore current entry from trash. If region is active, restore entries in active region instead.

Command: zotero-browser-delete

Delete current entry. If region is active, delete entries in active region instead.

Command: zotero-browser-create

Create a new collection or item.

Command: zotero-browser-create-note &optional ARG

Create a new note. With a C-u prefix, create a new top level note.

Command: zotero-browser-create-attachment &optional ARG

Create a new attachment with the current entry as parent. With a C-u prefix, create a new top level attachment.

Only file attachments (imported_file/linked_file) and PDF imported web attachments (imported_url with content type application/pdf) are allowed as top level items, as in the Zotero client.

Command: zotero-browser-update-attachment

Update the attachment of the current entry.

Command: zotero-browser-rename-attachment

Rename the attachment of the current entry to match the metadata.

Command: zotero-browser-import-attachment

Import a PDF file and create a new attachment. Retrieve the metadata automatically, create an appropriate parent item, and rename the associated file based on the metadata.

Command: zotero-browser-link-attachment

Link to a PDF file and create a new attachment. Retrieve the metadata automatically and create an appropriate xparent item.

Command: zotero-browser-add-by-identifier STRING

Create a new item by providing an identifier. Argument STRING is a ISBN, DOI, PMID, or arXiv ID.

Command: zotero-browser-recognize-attachment

Recognize content of the current entry.

Function: zotero-browser-index-attachment

Index the full-text content of the current entry.

Function: zotero-browser-find-attachment

Return the path of the attachment of the current entry.

Function: zotero-browser-download-attachment &optional DIR

Download the attachment of the current entry.

Optional argument DIR is the directory. If DIR is omitted or nil, the attachment is downloaded to the default storage directory zotero-cache-storage-dir and a subdirectory named as the item key.

Browser customization

User Option: zotero-browser-libraries-buffer-name

The default buffer name. Default=”\*Zotero Libraries\*”.

User Option: zotero-browser-collections-buffer-name

The default buffer name. Default=”\*Zotero Collections\*”.

User Option: zotero-browser-items-buffer-name

The default name of the items buffer. Default=”\*Zotero Items\*”.

User Option: zotero-browser-default-collection-level

The default expansion level for collections. Default=1.

User Option: zotero-browser-default-item-level

The default expansion level for items. Default=1.

User Option: zotero-browser-icons

When t show browser icons. Icons are enabled by default.

User Option: zotero-browser-libraries-sort-field

Sort field for the collections buffer. If nil, no sorting is performed. Otherwise, this should be a cons cell (FIELD . FLIP). FIELD is the prop of the object plist to be sorted. FLIP, if non-nil, means to invert the resulting sort. Default=:name.

User Option: zotero-browser-collections-sort-field

Sort field for the collections buffer. If nil, no sorting is performed. Otherwise, this should be a cons cell (FIELD . FLIP). FIELD is the prop of the object plist to be sorted. FLIP, if non-nil, means to invert the resulting sort. Default=:name.

User Option: zotero-browser-items-sort-field

Sort field for the items buffer. If nil, no sorting is performed. Otherwise, this should be a cons cell (FIELD . FLIP). FIELD is the prop of the object plist to be sorted. FLIP, if non-nil, means to invert the resulting sort. Default=:title.

User Option: zotero-browser-library-columns

Fields to show in the libraries buffer. This should be a list of cons cells (FIELD . WIDTH), where:

  • FIELD is the prop of the object plist to be sorted.
  • WIDTH is the width to reserve for the column.

User Option: zotero-browser-collection-columns

Fields to show in the collections buffer. This should be a list of cons cells (FIELD . WIDTH), where:

  • FIELD is the prop of the object plist to be sorted.
  • WIDTH is the width to reserve for the column.

User Option: zotero-browser-item-columns

Fields to show in the items buffer. This should be a list of cons cells (FIELD . WIDTH), where:

  • FIELD is the prop of the object plist to be sorted.
  • WIDTH is the width to reserve for the column.

User Option: zotero-browser-filename-keys

Fields to show in the attachment filename. Join all the key values with the separator in between.

User Option zotero-browser-filename-max-length

Maximum length of fields in attachment filenames. Fields exceeding the maximum length are truncated. Default=50.

User Option zotero-browser-preferred-application

Preferred application to open files. The default is mailcap.

Helper functions

Emacs-zotero provides a few helper functions that are used internally, but could prove useful elsewhere as well.

Convert keywords and strings

Function: zotero-lib-keyword->string KEYWORD

Convert KEYWORD to a string. Strip the leading “:” from the keyword.

Function: zotero-lib-string->keyword STRING

Convert STRING to a keyword. Add a leading “:” to the string.

Manipulate plists

Function: zotero-lib-plist-get* PLIST &rest PROPS

Recursively extract a value from a property list. This function returns the value corresponding to the given PROPS in a nested PLIST. The lookup for each prop should return another plist, except for the final prop, which may return any value.

Function: zotero-lib-plist-delete PLIST &rest PROPS

Delete PROPS from PLIST.

Function: zotero-lib-mergable-plist-p PLIST1 PLIST2

Return non-nil if PLIST1 and PLIST2 can be merged without conflicts. Two plists are considered mergable when the same keys don’t have different values.

Function: zotero-lib-merge-plist PLIST1 PLIST2

Merge PLIST2 into PLIST1.

Validate identifiers

Function: zotero-lib-validate-isbn STRING

Check if STRING is a valid ISBN. Return the ISBN if it is valid, else return nil. Argument STRING can be in either the older ISBN-10 or the current ISBN-13 format. A leading “ISBN” identifier is allowed, and ISBN parts can optionally be separated by hyphens or spaces. The format is validated by a regexp and the validity of the final digit is checked using a checksum algorithm.

Function: zotero-lib-validate-arxiv STRING

Check if STRING is a valid arXiv identifier. Return the arXiv identifier if it is valid, else return nil. The scheme used by arXiv was changed in April 2007. Argument STRING can be in either the old scheme (from 1999 to March 2007) or the new scheme (since 1 April 2007). A leading “arXiv” identifier is allowed. The format is validated by a regexp.

Function: zotero-lib-validate-doi STRING

Check if STRING is a valid Crossref DOI. Return the DOI if it is valid, else return nil. A leading “doi” identifier or a link (for example, https://doi.org/10.1000/182) is allowed. The format is validated by a regexp.

Function: zotero-lib-validate-pmid STRING

Check if STRING is a valid PubMed ID (PMID). Return the PMID if it is valid, else return nil. A leading “PMID” identifier is allowed. The format is validated by a regexp.

Clean up HTML

Function: zotero-lib-html-to-unicode STRING

Replace HTML entities with unicode in STRING.

Function: zotero-lib-remove-html-tags STRING

Remove all HTML tags from STRING.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.