- 1 Introduction
- 2 The overall design
- 3 Features
- 4 Installation and configuration
- 5 Version and license information
- 6 Bug reports and future work
- 7 The API
- 7.1 Module literef.el – the main module.
- 7.2 Module literef-citation-functions.el – implementation of the citation function link and the associated functionality.
- 7.3 Module literef-citation-link.el – functions for handling citation links.
- 7.3.a Functions
- 7.3.a.1 literef-after-citation-type-p
- 7.3.a.2 literef-after-string-p
- 7.3.a.3 literef-bibtex-from-clipboard
- 7.3.a.4 literef-cite-onclick-function
- 7.3.a.5 literef-copy-current-key
- 7.3.a.6 literef-insert-for-yank
- 7.3.a.7 literef-key-string
- 7.3.a.8 literef-sort-citation-link
- 7.3.a.9 literef-sort-citation-links
- 7.3.a.10 literef-sort-keys
- 7.3.a.11 literef-split-cite
- 7.3.a.12 literef-split-cite-raw
- 7.3.a.13 literef-split-cite-title-author
- 7.3.b Variables
- 7.3.a Functions
- 7.4 Module literef-config.el – values of configuration variables and key shortcuts for frequently used commands.
- 7.4.a Functions
- 7.4.b Variables
- 7.4.b.1 literef-arc-filter-variables-prefix
- 7.4.b.2 literef-bibliography-package
- 7.4.b.3 literef-bibliography-style
- 7.4.b.4 literef-citation-function-color
- 7.4.b.5 literef-citation-function-link
- 7.4.b.6 literef-citation-functions
- 7.4.b.7 literef-citation-link-sorting-criteria
- 7.4.b.8 literef-default-image-html-attrs
- 7.4.b.9 literef-default-image-latex-attrs
- 7.4.b.10 literef-drop-directory
- 7.4.b.11 literef-equal-timestamps
- 7.4.b.12 literef-graph-font-height
- 7.4.b.13 literef-papers-directory
- 7.4.b.14 literef-pdf-annotation-color
- 7.4.b.15 literef-pdf-annotation-link
- 7.4.b.16 literef-sort-citation-links
- 7.4.b.17 literef-subgraph-show-buffer
- 7.4.b.18 literef-subgraph-show-only-generating-arcs
- 7.4.b.19 literef-survey-directory
- 7.5 Module literef-export.el – functions for handling exporting a survey.
- 7.5.a Functions
- 7.5.a.1 literef-export-file-name-without-ext
- 7.5.a.2 literef-export-to-file
- 7.5.a.3 literef-insert-note-references
- 7.5.a.4 literef-insert-subgraph-image-file-link
- 7.5.a.5 literef-key-notes-p
- 7.5.a.6 literef-keys-to-insert
- 7.5.a.7 literef-make-bib-file
- 7.5.a.8 literef-reference-text
- 7.5.a.9 literef-remove-citation-functions
- 7.5.a.10 literef-source-buffer-string
- 7.5.a.11 literef-subgraph-export-dispatch
- 7.5.a.12 literef-subgraph-image-file-link
- 7.5.a.13 literef-subgraph-image-file-name
- 7.5.b Variables
- 7.5.a Functions
- 7.6 Module literef-graph.el – functions for building and updating the citation graph.
- 7.6.a Functions
- 7.6.a.1 literef-add-citation-and-functions-to-hash
- 7.6.a.2 literef-compute-graph
- 7.6.a.3 literef-graph-add-arc
- 7.6.a.4 literef-graph-add-key
- 7.6.a.5 literef-graph-arc-label
- 7.6.a.6 literef-graph-key-entry
- 7.6.a.7 literef-graph-update-key
- 7.6.a.8 literef-init-graph
- 7.6.a.9 literef-key-in-neighbors
- 7.6.a.10 literef-key-out-citations
- 7.6.a.11 literef-key-out-neighbors
- 7.6.a.12 literef-out-citations
- 7.6.a.13 literef-save-hook
- 7.6.b Variables
- 7.6.a Functions
- 7.7 Module literef-helm.el – the
helm
interface for searching in the papers database.- 7.7.a Functions
- 7.7.a.1 literef-action-transformer
- 7.7.a.2 literef-assoc
- 7.7.a.3 literef-author-down
- 7.7.a.4 literef-author-up
- 7.7.a.5 literef-candidate-helm-string
- 7.7.a.6 literef-candidate-property
- 7.7.a.7 literef-candidate-transformer
- 7.7.a.8 literef-candidate-venue
- 7.7.a.9 literef-candidate-venue-type
- 7.7.a.10 literef-char-to-compare
- 7.7.a.11 literef-compare
- 7.7.a.12 literef-criteria-list
- 7.7.a.13 literef-filtered-candidate-transformer
- 7.7.a.14 literef-helm-insert-action
- 7.7.a.15 literef-helm-marked-keys
- 7.7.a.16 literef-key-down
- 7.7.a.17 literef-key-up
- 7.7.a.18 literef-kill-ring-action-yank
- 7.7.a.19 literef-read-sorting-criteria
- 7.7.a.20 literef-sort
- 7.7.a.21 literef-str-compare
- 7.7.a.22 literef-subgraph-helm
- 7.7.a.23 literef-timestamp-compare
- 7.7.a.24 literef-timestamp-down
- 7.7.a.25 literef-timestamp-up
- 7.7.a.26 literef-title-down
- 7.7.a.27 literef-title-up
- 7.7.a.28 literef-type-down
- 7.7.a.29 literef-type-up
- 7.7.a.30 literef-venue-down
- 7.7.a.31 literef-venue-up
- 7.7.a.32 literef-year-down
- 7.7.a.33 literef-year-up
- 7.7.b Variables
- 7.7.a Functions
- 7.8 Module literef-latex-map.el – handling accented characters.
- 7.9 Module literef-pdf.el – PDF annotation links, import of papers referenced in a PDF, searching in the paper PDFs.
- 7.9.a Functions
- 7.9.a.1 literef-buffers-in-mode
- 7.9.a.2 literef-cite-pdf-annotation
- 7.9.a.3 literef-first-word
- 7.9.a.4 literef-follow-pdf-annotation-link
- 7.9.a.5 literef-get-region-bibtex
- 7.9.a.6 literef-glue-p
- 7.9.a.7 literef-last-word-hyphen
- 7.9.a.8 literef-pdf-annotation-string
- 7.9.a.9 literef-pdf-buffer-keys
- 7.9.a.10 literef-search-pdfs
- 7.9.a.11 literef-single-line-query
- 7.9.b Variables
- 7.9.a Functions
- 7.10 Module literef-server.el – communication with the Python server.
- 7.11 Module literef-subgraph.el – building a citation subgraph and working with it.
- 7.11.a Functions
- 7.11.a.1 literef-add-to-next-iter
- 7.11.a.2 literef-append-spaces
- 7.11.a.3 literef-arc-filter-company-backend
- 7.11.a.4 literef-arc-filter-minibuffer-mode
- 7.11.a.5 literef-arc-filter-p
- 7.11.a.6 literef-arc-filter-temp-variable
- 7.11.a.7 literef-arc-filter-variables
- 7.11.a.8 literef-generating-arc-p
- 7.11.a.9 literef-graph-check-arc
- 7.11.a.10 literef-graph-mode
- 7.11.a.11 literef-graph-scroll-down
- 7.11.a.12 literef-graph-scroll-left
- 7.11.a.13 literef-graph-scroll-right
- 7.11.a.14 literef-graph-scroll-up
- 7.11.a.15 literef-init-subgraph
- 7.11.a.16 literef-key-in-subgraph-p
- 7.11.a.17 literef-list-satisfies-predicate-p
- 7.11.a.18 literef-longest-line-length
- 7.11.a.19 literef-make-arc-filter
- 7.11.a.20 literef-neighbor-pairs
- 7.11.a.21 literef-read-arc-filter
- 7.11.a.22 literef-select-subgraph
- 7.11.a.23 literef-select-subgraph-for-export
- 7.11.a.24 literef-selected-subgraph-string
- 7.11.a.25 literef-show-selected-subgraph
- 7.11.a.26 literef-show-selected-subgraph-png
- 7.11.a.27 literef-show-selected-subgraph-raw
- 7.11.a.28 literef-subgraph-add-generating-arc
- 7.11.a.29 literef-subgraph-add-key
- 7.11.a.30 literef-subgraph-build-from-source
- 7.11.a.31 literef-subgraph-compute-initial-keys
- 7.11.a.32 literef-subgraph-generating-arcs
- 7.11.a.33 literef-subgraph-initial-keys
- 7.11.a.34 literef-subgraph-keys
- 7.11.a.35 literef-subgraph-reset-selection
- 7.11.a.36 literef-subgraph-save-image
- 7.11.a.37 literef-subgraph-select-source
- 7.11.a.38 literef-subgraph-set-initial-keys
- 7.11.a.39 literef-subgraph-set-source-property
- 7.11.a.40 literef-subgraph-source
- 7.11.a.41 literef-subgraph-source-property
- 7.11.a.42 literef-uniform-cost-search
- 7.11.b Variables
- 7.11.a Functions
- 7.12 Module literef-util-links.el – utility functions for working with links.
- 7.12.a Functions
- 7.12.a.1 literef-all-links
- 7.12.a.2 literef-citation-function-link-p
- 7.12.a.3 literef-citation-function-links
- 7.12.a.4 literef-citation-link-p
- 7.12.a.5 literef-citation-link-under-cursor
- 7.12.a.6 literef-citation-links
- 7.12.a.7 literef-first-citation-link-on-line
- 7.12.a.8 literef-link-begin
- 7.12.a.9 literef-link-end
- 7.12.a.10 literef-link-path
- 7.12.a.11 literef-link-path-components
- 7.12.a.12 literef-link-prev-element
- 7.12.a.13 literef-link-prev-non-space
- 7.12.a.14 literef-link-type
- 7.12.a.15 literef-link<
- 7.12.b Variables
- 7.12.a Functions
- 7.13 Module literef-utils.el – general-purpose utilities used by the other modules.
- 7.13.a Functions
- 7.13.a.1 literef-all-keys
- 7.13.a.2 literef-bib-filename
- 7.13.a.3 literef-bib-files
- 7.13.a.4 literef-buffer-key
- 7.13.a.5 literef-buffer-keys
- 7.13.a.6 literef-check-arrived-pdfs
- 7.13.a.7 literef-creation-timestamp
- 7.13.a.8 literef-current-buffer-key
- 7.13.a.9 literef-current-key
- 7.13.a.10 literef-eval-string
- 7.13.a.11 literef-file-key
- 7.13.a.12 literef-filename
- 7.13.a.13 literef-find-file-other-window
- 7.13.a.14 literef-folder-key
- 7.13.a.15 literef-get-bibtex-key-under-cursor
- 7.13.a.16 literef-get-entry
- 7.13.a.17 literef-hash-empty-p
- 7.13.a.18 literef-hash-keys-minus
- 7.13.a.19 literef-hash-keys-to-list
- 7.13.a.20 literef-hash-pairs-to-list
- 7.13.a.21 literef-join-strings
- 7.13.a.22 literef-key-exists
- 7.13.a.23 literef-notes-filename
- 7.13.a.24 literef-number-or-nil
- 7.13.a.25 literef-number-or-nil-p
- 7.13.a.26 literef-open-bibfile
- 7.13.a.27 literef-open-key-bibfile
- 7.13.a.28 literef-open-key-notes
- 7.13.a.29 literef-open-key-pdf
- 7.13.a.30 literef-open-key-pdf-raw
- 7.13.a.31 literef-open-notes
- 7.13.a.32 literef-open-pdf
- 7.13.a.33 literef-pdf-filename
- 7.13.a.34 literef-plist-put
- 7.13.a.35 literef-raw-str-compare
- 7.13.a.36 literef-read-char
- 7.13.a.37 literef-read-number-or-nil
- 7.13.a.38 literef-replace-in-string-whole-words
- 7.13.a.39 literef-set-default-bibliography
- 7.13.a.40 literef-string-or-nil-to-string
- 7.13.a.41 literef-word-correct-p
- 7.13.a.42 literef-xor
- 7.13.a.43 replace-in-string
- 7.13.a.44 with-cloned-buffer
- 7.13.b Variables
- 7.14 The server
- 7.13.a Functions
LiteRef
is to provide a thin layer of software that would make it natural and easy to collect papers, maintain notes about both individual papers and branches of research, explore connections between papers and export all or part of this body of knowledge into a coherent document.
There are many software packages for reference management out there. The main difference between LiteRef
and these packages is the focus. While the focus of existing reference management software is on maintaining the database of bibliography entries, the focus of LiteRef
is on providing the researcher with tools that would aid him in growing his understanding of the research field. Consequently, LiteRef
is centered around the notes written by the researcher.
LiteRef
runs under Emacs, an extremely powerful and flexible text editor. In particular, Emacs
comes with an awesome major mode for organizing notes called org-mode. LiteRef
harnesses the power of org-mode
and several other packages (most notably org-ref) to put at the researcher’s disposal a potent tool for maintaining his knowledge of related literature.
LiteRef
offers:
- A variety of means for importing BibTeX entries into the database and performing actions on these entries. In particular, BibTeX entries can be fetched from an extensible set of online resources. Also, one can import entries for all the papers in a given journal volume or conference proceedings. This feature supports maintaining an edge in the knowledge of the papers in the narrow specialization of the researcher. The researcher can conveniently track his progress on studying the imported papers.
- Powerful tools for citing papers and for intelligently handling citations in
org-mode
notes maintained by the researcher. - Automated fetching of paper PDFs from an extensible set of online resources.
- Specialized
org-mode
links enabling references to a particular annotation in a paper PDF from a notes file. The annotations themselves are handled by the awesome pdf-tools package forEmacs
. - Automated generation of bibliography for export and powerful synergies with the standard
org-mode
tools such as narrowing to sub-trees and inclusion directives. - Annotation of citations by their role. This seemingly trivial feature gives raise to some of the most powerful features of
LiteRef
. In particular, the annotated citations in the notes associated with the research papers induce a citation graph, whereby related papers are connected by arcs labeled by citation functions. - A general way of defining a citation subgraph, which is a subgraph of the citation graph possibly augmented with papers cited in an arbitrary buffer.
- The ability to obtain much insight by visualizing the citation subgraph.
- The ability to restrict the action of several commonly used activities such as searching for papers to the citation subgraph.
- Advanced export that integrates all the notes relevant to the citation subgraph into a coherent document. Thus, one can quickly obtain a well-formed survey of a branch of his research area.
The following sections describe both the overall design of LiteRef
and its features. Each feature’s description is accompanied by a short video demonstrating the feature’s usage.
LiteRef
and thereby make reading the sections that describe particular features comfortable.
As far as the user is concerned, two folders in the distribution are of interest: papers/
and drop/
. As suggested by their names, the papers/
folder contains the database of papers, while the drop/
folder is the place where new BibTeX and PDF entries are to be deposited for subsequent handling by LiteRef
.
The database of papers has a very simple structure, whereby each paper gets a folder whose name is the key of that paper’s BibTeX entry (LiteRef
generates these keys automatically). A paper’s folder contains at least two files: paper.bib (the BibTeX entry of the paper) and paper.org (the researcher’s notes about the paper). In addition, it may contain paper.pdf (the PDF of the paper) and any other files that the researcher wishes to associate with the paper.
LiteRef
does not impose any restrictions on the format of the notes. Thus, all the arsenal of org-mode
is put at the researcher’s disposal. In addition, the researcher can maintain any number of survey notes, which can reside anywhere in the file system. Such notes are usually dedicated to branches of research rather than to a particular paper.
LiteRef
database is triggered by the appearance of a .bib file in the drop/
folder and handled by the server written in Python
. This can happen in a large number of ways from manual creation of this file to automated search in online sources. Whatever way is chosen, each BibTeX entry in the new .bib file receives an automatically generated key. This key consists of three parts:
- The last name of the first author followed by a capital first letter of each co-author’s last name,
- Year of publication followed by a letter signifying the type of venue, e.g. 2000c (a conference proceedings in 2000) or 2005j (a journal volume in 2005).
- Two (possibly abbreviated) words from the title.
After duplicate detection, the new entries are entered into the database. Both paper.bib and (an empty) paper.org for each of the new entries are created at this point.
Searching for a PDF file is triggered by trying to open a paper’s PDF file in any one of the ways described below and is handled by the server as well. When this happens, if the drop/
folder contains PDF files, these become the first candidates. If the user rejects these candidates, automated search in the online sources ensues.
The online sources for searching for BibTeX and PDF files are defined in an extensible way in the online_sources.py module of the server. This module documents in detail how one can extend the set of online sources with sources of his own. If such an extension takes place, it is up to the user to respect the terms of service of whatever sites are searched. The author of LiteRef
does not assume any responsibility for violations.
Note that changes in the format of the HTML pages and in the access policies of the online sources may break the ability of LiteRef to import from those sources. As of 13.11.2018, import from both DBLP and Semantic Scholar (of both BibTeX entries and paper PDFs) works well, while Google Scholar blocks access.
Most features ofLiteRef
are implemented in Emacs Lisp. These features use uniquely Emacs
ways for doing things. These ways may come as a surprise to an uninitiated user, but inevitably prove to be extremely time-effective. Once having got used to using Emacs
properly, one rejoices for the rest of his life at having found the ultimate tool for everything related to editing text, maintaining notes and too many other tasks to list. LiteRef
adds maintaining knowledge of related literature to these tasks.
The functionalities related to watching the drop/
folder and creating/fetching new entries are delegated to the server. In contrast to actions executed entirely inside Emacs
, the server relies on dialog windows for its features’ user interface. One positive effect of this difference is that the user can visually and easily distinguish a candidate BibTeX entry or PDF that has just been found and downloaded automatically from an entry that is already in the LiteRef
database. Thus, the overall user experience only wins from this non-uniformness of presentation means.
LiteRef
are centered around working with paper citations. A paper is cited using the org-ref
citation link, which consists of cite:
(or its derivatives, such as citea:
etc.) followed by the keys of the BibTeX entries of the papers being cited, e.g. cite:AbrahamDGW2011c-Hub-Based,ChakrabortiSSKK2016c-Compl-Condit
. In most cases, one would cite a paper by searching for it using helm
, which is the Emacs
way of searching in a large collection of candidates by gradually narrowing the candidate set. The candidates for this search can be either the whole paper database or the papers that form the current citation subgraph. Once some paper citations are added, a number of features of LiteRef
dedicated to making the editing tasks related to paper citations effective are available.
Besides the paper citations, two other types of links are at the user’s disposal. First, a paper citation can be followed by a list of citation functions, e.g. cite:AlfeldZB2016c-Machin-Teach
f:develops,compares
. Citation functions allow the researcher to characterize the relationships between the two papers. For example, suppose the notes for the paper X cite the paper Y. This citation could signify that X develops the ideas of Y, that the ideas presented in X bear a degree of resemblance to those of Y, that X compares its results to those of Y etc. LiteRef
leaves it to the researcher to define the list of legal citation functions. One can either come up with his own list or use an existing set of citation functions such as the Citation Typing Ontology. Once such a list is defined, LiteRef
makes inserting citation function links convenient. As mentioned earlier, citation function links are utilized by LiteRef
to provide functionalities related to the citation (sub-)graph.
Second, a paper’s notes can contain links to particular annotations in the paper’s PDF. This feature allows the researcher to easily relate his comments to particular clauses in the paper.
This section describes the features ofLiteRef
in detail.
There are several ways to import a new BibTeX entry into the database of LiteRef
.
The most direct way to import BibTeX entries into the database of LiteRef
is to either download or copy the corresponding .bib file into the drop/
folder. Should you like to write the new BibTeX entries from scratch, the .bib file can be either created directly in the drop/
folder or in another location and then copied over.
The following actions are performed automatically as soon as a new .bib file appears in the drop/
folder:
- The BibTeX entries are extracted.
- The key for each BibTeX entry is generated.
- All the BibTeX entries are added into the database subject to duplicate detection. In case a duplicate is detected, the user may choose to keep both entries, in which case the key of the new entry is modified to guarantee uniqueness. One practical case when a need for this feature may arise is when the new entry refers to an extended abstract of the full-size conference paper that is already present in the database.
- Note that all the added entries get the same creation time stamp. This makes a difference when ordering papers by multiple criteria as described below.
- The list of newly added keys is put into the clipboard, so the papers can be immediately cited in the notes by invoking the
yank
command (yanking is theEmacs
term for pasting), which is typically bound toC-y
.
literef-bibtex-from-clipboard
command (bound by default to C-c c
) caters to this case.
The literef-get-region-bibtex
command (bound by default to C-c g
) searches for a BibTeX entry corresponding to the text in the active region. The region can be either in a regular Emacs
buffer (e.g. in a notes file) or in a PDF buffer. The latter is the most widespread use case, since most often the researcher becomes interested in a paper that is cited in the paper currently being studied. When the selected region consists of multiple lines with words split between the lines, LiteRef
forms the single-line query intelligently. That is, it uses spell checking to determine whether the hyphen should be kept or removed. It defers to the user’s help only in case of doubt (i.e. when both the hyphenated and the „glued“ versions are spelled (in)correctly).
The researcher can configure LiteRef
to search several online sources. This is done by appropriately setting the BIB_AUTOMATED_SOURCES
variable in config.py. In addition, the user can set the BIB_MANUAL_SOURCE
variable of the server. When this variable is set and the automated search does not come up with the desired BibTeX entry, LiteRef
will open the browser for searching in the specified source manually.
The currently implemented online sources for BibTeX entries are Google Scholar, Semantic Scholar and DBLP. The user can add more online sources by extending online_sources.py with classes that implement interfaces documented in that module.
Suppose that there is a venue that publishes papers in the narrow specialization of the researcher. The researcher needs to be knowledgeable about all the papers appearing in that venue. He may even want to dedicate a special notes file, in which papers from this venue will be represented and organized. (We will see below thatLiteRef
makes it easy to track his progress on studying these papers as well.)
To cater to the above scenario, LiteRef
can handle .html files downloaded into the drop/
folder. LiteRef
extracts from such an HTML links to BibTeX entries and downloads the entries themselves. Of the implemented online sources, only DBLP is currently supported by this feature.
Note that downloading hundreds of BibTeX entries may take a while (up to a few minutes). LiteRef
does not show the progress of downloads, since, in order to re-use connections, all of the BibTeX entries are downloaded with a singe invocation of wget
. Running the following command from the terminal (while in the LiteRef
root folder) will show the downloaded files: grep "Saving" drop/temp/wget.log
.
LiteRef
are centered around citations. In this section, we focus on the tasks of finding the keys to cite, editing the text containing citations, splitting a list of citations and working with the currently active citation or paper.
All the functionalities presented in this and further sections work with all types of citation links supported by org-ref
and described by the variable org-ref-cite-types
. The video demos of this section were recorded before this enhancement and use cite:
links exclusively. The demo in the below section on advanced export capabilities of LiteRef
shows the use of other types of citation links.
LiteRef
inherits from org-ref
and significantly improves the org-ref-insert-link
command (bound by default to C-c ]
) for inserting a citation.
Just like it’s predecessor, the command uses the helm
interface for finding candidates by iterative process of filtering. LiteRef
helps make this process more effective by extending the sorting capabilities to support multiple criteria. Just like in org-ref
, the sorting is bound by default to M-<down>
(M
stands for the Meta key, which is Alt
on most keyboards). For example, one can access the recently added entries by sorting the candidates on the date and time of creation (which is taken to be the date and time of the last update of paper.bib for that entry; entries added within a small time margin, which is two seconds by default, of each other are considered to be added at the same time to enable sorting papers that were imported together on additional criteria).
As in org-ref
, one can select (by pressing C-<SPACE>
) and cite multiple papers. If the configuration variable literef-sort-citation-links
is not nil
, the cited papers are sorted on the criteria encoded in the string value of literef-citation-link-sorting-criteria
.
Note that one can perform actions other than inserting a citation on a candidate (this is done by pressing <TAB>
while the candidate is active).
One can also insert citations based on searching for a given string in the first page of all the paper PDFs contained in the LiteRef
database. This is done with the literef-search-pdfs
command. The following demo shows how to find all papers written by researchers from Toronto (e.g. in order to establish contacts with the researchers from Toronto working in his area).
Emacs
way of storing multiple pieces of text for future use) on top of an already existing citation, LiteRef
makes sure that a well-formed multi-paper citation results. If automated ordering of citation is enabled (i.e. literef-sort-citation-links
is set to t
), then the keys will be sorted on the criteria specified by literef-citation-link-sorting-criteria
. The order of keys appearing in a multi-paper citation can be changed at any time by invoking the literef-sort-citation-link
command (bound by default to C-c <down>
). This command offers the multi-criteria sorting capability familiar to the reader from the above section on searching the papers database. The literef-sort-citation-links
command (not bound to a key by default) can be used to re-order all the citation links in the current buffer.
In addition, LiteRef
offers the literef-copy-current-key
command (bound by default to C-c w
), which puts the currently active citation key into the kill ring. When used in conjunction with helm-show-kill-ring
and bookmarks (which are one of those many tools Emacs has to make your life easier once you discover them), one can easily collect citations scattered all over his notes.
Note that automated ordering of keys in multi-paper citations may affect the operation of the yank-pop
command. However, given the superior convenience offered by helm-show-kill-ring
, this limitation should not discourage one from using automated ordering of citation keys.
LiteRef
, this is easy to achieve by splitting a multi-paper citation using either literef-split-cite
(bound to C-c d
by default) or literef-split-cite-title-author
(bound to C-c s
by default). The latter adds authors and title to each paper. Both commands replicate the context of the original multi-paper citation (i.e. the preceding and the following text) with each resulting single-paper citation.
In addition, when the original multi-paper citation appears as a list item, LiteRef
will offer to create an org-mode
inline task for each paper.
C-c C-o
when the cursor is on the link or by mouse-clicking the link. The actions menu allows the user to open the BibTeX entry, the notes or the PDF associated with the paper. An additional recently added action is for building a citation subgraph rooted at the paper.
When the cursor is located over a citation or the active buffer is visiting a file associated with the paper, each of the above actions can be invoked with a command:
literef-open-bibfile
for opening the BibTeX entry is bound by default toC-c b
.literef-open-notes
for opening the notes is bound by default toC-c n
.literef-open-pdf
for opening the PDF is bound by default toC-c o
. The next section describes what happens when the PDF for the paper has not yet been added to theLiteRef
database.literef-select-subgraph
for building a citation subgraph rooted at the paper is bound by default toC-c u
.
These commands can also be invoked for an active candidate when searching the papers database.
LiteRef
takes a lazy approach to adding paper PDFs to the LiteRef
database. Namely, importing a PDF is initiated when the user tries to open a PDF that is not currently in the database. The search for the needed PDF proceeds in three stages:
- If one or more PDF files exist in the
drop/
folder, the user is asked about each one of them whether it is the one being sought. If the answer for one of these PDFs is positive, that PDF is added to the database and opened. Otherwise, the next step is taken. - The PDF is searched for in the online sources defined by the
PDF_AUTOMATED_SOURCES
configuration variable of the server. The currently implemented online sources for PDFs areGoogleScholar
andSemanticScholar
. The user can add more online sources by extending online_sources.py with classes that implement interfaces documented in that module. If a matching PDF is found and confirmed by the user, it is added to the database and opened. Otherwise, the next step is taken. - If the
PDF_MANUAL_SOURCE
configuration variable of the server is notNone
,LiteRef
opens the browser for searching in the online source specified by that variable. Once a new PDF appears in thedrop/
folder,LiteRef
asks the user to match it with one of the BibTeX entries for which manual download of a PDF had been requested. If none of the entries is matched, the downloaded PDF remains in thedrop/
folder for future use, e.g. as described in the first step above.
pdf-tools
package of Emacs
are prodigious. LiteRef
integrates with the annotation capabilities of pdf-tools
by providing the literef-cite-pdf-annotation
command (bound by default to C-c a
) for linking directly from the researcher’s notes to PDF annotations. Upon the command’s invocation, the user chooses among the currently visited paper PDFs using the uniquely Emacs
Interactively Do Things interface. The buffer visiting the chosen PDF becomes active and a single click is needed to choose the target annotation. Following that choice, the link to the PDF annotation is inserted at the point of the cursor in the notes buffer that was active at the time of invoking the command and that buffer becomes active again. If another kind of a buffer was active, the link is saved in the kill ring.
Following a link to a PDF annotation results in opening the corresponding paper’s PDF and jumping directly to the annotation.
LiteRef
extends the functionality of the org-export-dispatch
command. In its original form, this command was already capable of exporting notes in a variety of formats, including LaTeX and PDF. LiteRef
extends the capabilities of this command, so that:
- The bibliography based on the citations found in the buffer being exported is automatically built. The underlying bibliography file created by
LiteRef
contains only the papers that appear in the bibliography, ordered by the increasing order of the BibTeX key. The bibliography style and the bibliography package used for LaTeX export are determined by the configuration variablesliteref-bibliography-style
andliteref-bibliography-package
, respectively. - Links to PDF annotations are replaced with references to page numbers.
- Citation functions are removed.
In addition to this command, LiteRef
provides a much more powerful command for exporting, which we discuss below.
Two facilities can be particularly powerful when used in conjunction with the export feature of LiteRef
:
- Narrowing is a standard
Emacs
feature, whereby only part of the buffer is visible both to the user and to the commands. In addition to this standard narrowing,org-mode
has theorg-narrow-to-subtree
command (bound by default toC-x n s
), which narrows the buffer to the current headline. When each headline in the notes buffer is dedicated to a research (sub-)area, one can easily focus on that (sub-)area by narrowing the buffer to the corresponding headline. Since a subsequent export command would respect such narrowing, one can easily export notes pertaining to the part of his survey dedicated to the (sub-)area of interest. - One of the keywords understood by
org-mode
is#+INCLUDE
, which allows one to include an external file or a portion of it at the time of export. This allows the researcher to organize his notes into a collection of files, while still being able to collect these notes together for export.
LiteRef
that aid the researcher in grasping the overall state of research in a given area are based on the notion of a citation function. Citation function is the role that the cited paper plays in the paper that cites it as reflected in the notes on the latter paper. For example, suppose that a paper X cites a paper Y, because X develops the ideas of Y. The researcher can reflect this in the notes on X by citing Y while specifying the citation function corresponding to the role of developing the ideas of the cited paper. It can look something like this: cite:Y f:develops-ideas
.
The set of citation functions in use is defined by the configuration variable literef-citation-functions
. The citation functions can be conveniently inserted into the notes by using the literef-citation-function
command (bound by default to C-c f).
LiteRef
are based on the observation that the papers and the citations (possibly labeled with citation functions) induce a directed graph with labeled arcs. This graph is called the citation graph. The vertex set of the citation graph is the set of all papers in the LiteRef
database. If the notes for a paper A cite a paper B and this citation is labeled with citation functions F1, F2, …, Fn, then there is an arc in the citation graph from A to B labeled by the set {F1, F2, …, Fn}. If the notes of A cite B without specifying citation functions, the arc from A to B is labeled with the empty set. It is convenient, though not totally accurate, to call such an arc unlabeled and we do so hereafter. If the notes for A cite B multiple times, then the arc from A to B is labeled by the union of the labels induced by each citation.
LiteRef
maintains the citation graph automatically. Namely, the citation graph is computed at the beginning of the Emacs
session and updated whenever a notes file is saved.
LiteRef
database, possibly appended with a vertex corresponding to an Emacs
buffer and the (unlabeled) arcs corresponding to the citations in that buffer.
At any given time, there is a single active citation subgraph, called the selected subgraph. When the Emacs
session begins, the selected subgraph is the whole citation graph. This subgraph can be selected again at any time by invoking the literef-subgraph-reset-selection
command.
All the operations described below work with the selected subgraph. In principle, this design allows working with multiple subgraphs, one being selected at a time. However, this is not yet supported.
A citation subgraph is built by invoking theliteref-select-subgraph
command bound by default to C-c u
. This command performs a uniform-cost search, with the root being either the active paper (i.e. the paper whose link is under the cursor or whose associated file is being visited by the active buffer) or (if there is no active paper) all the papers cited in the active buffer. The user can specify a filter for the arcs to be followed by the search. These arcs are called the generating arcs of the resulting subgraph, which is induced by the papers reached by the search.
The filter on the arcs is an expression in Emacs Lisp
. This expression is evaluated for each candidate arc. A candidate arc is followed if and only if the filter evaluates to a value other than nil
. When writing the filter, one can use the following variables:
- The variable named after a citation function. This variable’s value is
t
if and only if the candidate arc’s label contains the corresponding citation function. Otherwise, it isnil
. For example, if a citation functiondevelops-ideas
is defined, then the variabledevelops-ideas
indicates whether the candidate label contains this specific citation function. in
, which ist
if and only if the candidate arc is incoming. Otherwise, it isnil
.out
, which ist
if and only if the candidate arc is outgoing. Otherwise, it isnil
.depth
, which is the current depth of the search. The papers at the root of the search are at depth 0. The arcs (traversed either along or against the direction of the arc) leaving the root of the search are at depth 1, etc.
Here is an example of a filter: (and (or (and develops-ideas (< depth 3)) compares-results) out)
. This filter says that we would like to follow the arcs having the develops-ideas
citation function in their label up to depth 2 and the arcs with the compares-results
citation function in their label regardless of the depth. Furthermore, we would like to follow only the outgoing arcs.
Basing arc filters on Emacs Lisp
expressions augmented by special variables allows for great flexibility in specifying the citation subgraph.
The demonstration of selecting the citation subgraph is deferred to a later section that introduces the capabilities of LiteRef
for visualizing the selected subgraph.
LiteRef
provides two ways of visualization:
- textual by means of the
literef-show-selected-subgraph
command (bound by default toC-c v
). This command visualizes the selected subgraph in anorg
buffer. This allows the nodes in the visualization to contain regular citation links that support all the operations described above. In addition, the visualization can be scrolled by pressing an arrow while holding the Meta key. - graphical by means of the
literef-show-selected-subgraph-png
command.
Whichever of the two commands is used, two configuration variables control the information that appears in the visualization:
- When
literef-subgraph-show-only-generating-arcs
is set (i.e. is notnil
), the visualizations shows only the generating arcs of the selected subgraph. This variable isnil
by default. - When
literef-subgraph-show-buffer
is set (i.e. is notnil
) and the selected subgraph was built by searching from a buffer rather than from an active paper, the source buffer is shown as a node of the selected subgraph. This variable isnil
by default.
The two ways of visualization are demonstrated by the following two demos.
Theliteref-subgraph-helm
command (bound by default to C-c )
) operates similarly to the org-ref-insert-link
command explained above with the exception that the set of candidate papers is limited to the current citation subgraph.
We already described above how LiteRef
extends the functionality of the org-export-dispatch
command. The literef-subgraph-export-dispatch
command goes further – it performs export of the citation subgraph. The document for export is constructed in a temporary buffer using the following algorithm:
- The document is initialized based on the subgraph’s source (i.e. the root of the search for building the citation subgraph). In particular:
- If the subgraph’s source is a buffer, the document is initialized to the contents of that buffer. However, if the source buffer does not exist or is visiting a different file, then the contents of the file visited by the source buffer at the time of building the subgraph is used instead. In any case, the name of that file is used to compute the name of the exported document.
- If the subgraph’s source is a paper or the
literef-select-subgraph
command for building the subgraph has not been invoked after the last reset of the subgraph, then the document is initialized to be empty. The user is requested to provide the name of the exported document. Depending on the source, the default folder is either the folder of the source paper or the value of the configuration variableliteref-survey-directory
.
- The document is appended with the notes for the papers in the citation subgraph. Notes of each paper appear in a section of their own. The title of that section consists of the paper’s title and authors, followed by the citation link to the paper. Empty sections, i.e. sections dedicated to papers with empty notes, do not appear.
- Optionally, a section containing all the notes as subsections can be created. This may be desirable when the subgraph’s source is a buffer containing several headlines.
- The
#+INCLUDE
directives are expanded. - A reference to the appropriate notes section is supplied for each paper citation. These references will conveniently become hyperlinks in the exported document.
- Links to PDF annotations and citation functions are handled just like during the basic export.
- The bibliography is created. The underlying bibliography file contains only the papers cited in the document.
literef-subgraph-image-file-link
function, which builds a subgraph, saves its graphical visualization into a temporary file and returns a link to that file along with the necessary attributes for export. Although this function takes quite a few arguments, LiteRef
makes things easy by providing the literef-insert-subgraph-image-file-link
command, which is basically a wizard for constructing a call to literef-subgraph-image-file-link
. Once the researcher provides the information requested by this command, the corresponding code block is inserted automatically.
Lastly, the user should remember that the export features discussed in this manual are not limited to exporting into LaTeX or PDF. In particular, the researcher can put exporting into HTML to good use for sharing his knowledge with students and colleagues.
Please use the instructions for automated installation, unless your system does not use theapt
manager or some other circumstances necessitate a manual install.
LiteRef
comes with the installaction script install.sh
. Simply run this script and you are all set. The script will:
- use the
apt
manager to install all the package dependencies of the server, - install the
pip
manager and use the latter to install all the neededPython
libraries and - set up Emacs configuration for
LiteRef
.
When you run Emacs
with the proper configuration (e.g. set up by the installation script), the needed Emacs packages will be installed automatically.
In case manual installation is required (e.g. if your system does not use the apt
manager), you will need to install the following packages (only the packages not installed by default in Ubuntu 18.04 LTS, as well as pip
, are listed). To install these packages, you will need to use the equivalent of the commands provided in parentheses.
- pip (
sudo apt install python-pip
) - Tkinter (
sudo apt install python-tk
) - pdfgrep (
sudo apt install pdfgrep
) - xsel (
sudo apt install xsel
) - Graph::Easy (
sudo apt install libgraph-easy-perl
) - Graphviz (
sudo apt install graphviz
) - epdfinfo (
sudo apt install elpa-pdf-tools-server
) - TexLive (
sudo apt install texlive-latex-base
) - TexLive extras (
sudo apt install texlive-latex-extra
) - bibtex (
sudo apt install texlive-binaries
) - ChromeDriver (download from here and put the executable into a folder listed in
PATH
) - Google Chrome (as detailed here)
- pyinotify (
sudo pip install pyinotify
) - flufl.enum (
sudo pip install flufl.enum
) - PybTex (
sudo pip install pybtex
) - requests (
sudo pip install requests
) - Selenium (
sudo pip install selenium
)
LiteRef
relies on the following Emacs
packages:
- org (version 9.0 or newer, so that the built-in package may not suffice)
- org-ref
- pdf-tools (you will need to run the
pdf-tools-install
interactive command inEmacs
after installing the package from the package manager) - smooth-scrolling
- company
The following lines need to appear in the Emacs
configuration file:
(require 'package)
(package-initialize)
(setq literef-directory "/home/meir/LiteRef/")
(add-to-list 'load-path (concat literef-directory "el/"))
(load-file (concat literef-directory "el/literef.el"))
Please make sure to edit the path in the definition of literef-directory
.
- Version: 1.0
- Author: Meir Goldenberg ([email protected])
- Copyright: GNU General Public License
The following API documentation follows Emacs Lisp
conventions:
- Function descriptions typeset formal arguments in all capital letters.
- Function descriptions describe the formal arguments inline rather than starting the description of each parameter on a separate line.
- Optional arguments are separated from the obligatory ones by the keyword
&optional
in the function signature. - The name of an unused formal argument begins with an underscore.
- The formal argument named
orig-fun
is accepted by functions that modify (see Advising Emacs Lisp Functions) existing functions. This argument stands for the original function.
The Emacs Lisp
terminology used most frequently:
- point – the position of the text cursor.
- cons – see Lists and Cons Cells.
- alist – see Association Lists.
- plist – see Property Lists.
t
– the value denotingTrue
.nil
– the value denoting empty list orFalse
.
Please follow this link to the documentation of the server API.
This module loads all the features of the system, starts the server and performs some general setting up tasks.
The LiteRef version of bibtex-completion-fallback-candidates
. It simply returns bibtex-completion-fallback-options
without appending this list by all the BibTeX files.
Install any missing packages. The code is taken from https://stackoverflow.com/a/10093312/2725810.
No variables are defined by this module.
This module defines the citation functions link and functions for computing its help echo and for providing a convenient completing read interface for entering the citation functions.
Annotate the currently active citation link with user-selected citation functions.
Compute the help echo that appears when hovering over a citation function link. This particular implementation only uses POSITION of the mouse. The technique is described at http://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/#org1c56ce9.
Prompt the user to input citation functions using the completing read interface. Returns the list of selected citation functions.
No variables are defined by this module.
This module contains functions that handle citation links and operations involving them: hovering over, clicking, splitting, ordering keys and others.
Return t
if point is after a citation link of any kind
(e.g. citeauthor:
) and nil
otherwise.
Return t
if point is after STRING and nil
otherwise.
Create an entry in the papers database from the BibTeX entry currently in the clipboard.
Handle following a citation link by offering a menu of actions that can be performed on the link.
Save the current key for later intelligent yanking.
The version of insert-for-yank
that handles the keys being yanked intelligently.
The STRING to be yanked is preceeded by the prefix computed as follows:
- Split the contents being yanked based on commas and analyze the first entry. If it is not a valid key, the prefix is empty. Otherwise, proceed to step 2.
- If over a citation key, go to its end and set the prefix to be comma.
- Otherwise, if the point is right after comma that follows a citation key or after a citation type (e.g.
citeauthor:
), the prefix is empty. - Otherwise, the prefix is “cite:”.
After the original function is called for the prefixed STRING, the current citation link (if the cursor is over one) is sorted subject to the value of the variable literef-sort-citation-links.
Compute a string consisting of title and author based on the KEY.
Sort keys in the current citation. The sorting criteria are read from the user, unless the optional NO-READ-CRITERIA is set. If NO-READ-CRITERIA is set, then, if CRITERIA is set as well, it is used as the sorting criteria. Otherwise, the value of the variable literef-citation-link-sorting-criteria is used as the sorting criteria.
Sort all citation links in the current buffer. The sorting criteria criteria are read from the user, unless the optional NO-READ-CRITERIA is set, in which case the value of the variable literef-citation-link-sorting-criteria is used as the sorting criteria.
Sort KEYS according to CRITERIA, which can be either a string or a list of characters as in the variable literef-citation-link-sorting-criteria.
Like literef-split-cite-title-author, but without prepending each citation with title and author.
Split the first multi-paper citation found on the current line, so that each paper is cited on a separate line, while the text preceeding and succeeding the original citation is duplicated on each line. Insert information about title and author before the key if INSERT-TITLE-AUTHOR is not nil
.
Split the first multi-paper citation found on the current line, so that each paper is cited on a separate line, preceeded by the information about title and author. The text preceeding and succeeding the original citation is duplicated on each line. Insert information about title and author before the key.
No variables are defined by this module.
This module defines the variables the control the functionalities of LiteRef and sets their values. It defines key shortcuts for frequently used commands as well. The user is welcome to set these variables and shortcuts to suit his needs and taste.
No functions are defined by this module.
The prefix used for the names of the special variables in the specification of the arc filter. See literef-arc-filter-variables and literef-arc-filter-temp-variable.
The bibliography package to be used for LaTeX export. If nil
, no
package specification is inserted into the document.
The bibliography style to be used for LaTeX export. If nil
, no
bibliography style specification is inserted into the document.
The color of citation function links.
The link name for specifying citation functions.
Types of citation functions used for annotating citations.
The sorting criteria for automatic sorting of citation links. It is a string consisting of comma-separated characters that stand for sorting criteria. The following characters in parentheses can be used: Key↑ (k), Key↓ (K), Creation Date↑ (d), Creation Date↓ (D), Author↑ (a), Author↓ (A), Title↑ (t), Title↓ (T), Venue↑ (v), Venue↓ (V), Venue Type↑ (w), Venue Type↓ (W), Year↑ (y), Year↓ (Y).
The default attributes for an inline image for HTML export. See https://www.gnu.org/software/emacs/manual/html_node/org/Images-in-HTML-export.html and https://orgmode.org/worg/org-tutorials/images-and-xhtml-export.html for the description of the possible attributes.
The default attributes for an inline image for LaTeX export. See https://www.gnu.org/software/emacs/manual/html_node/org/LaTeX-specific-attributes.html for the description of the possible attributes. Note that, when backslash is used, four backslashes need to be typed.
The folder for dropping new files, such as downloaded BibTeX entries and PDF files. LiteRef uses this folder for files representing server requests as well.
The number of seconds, within which creation timestamps of two papers database entries corresponding to two candidates in helm are considered to be same with respect to sorting the candidates.
The font height used in the textual visualization of the selected subgraph.
The folder containing the papers database.
The color of PDF annotation links.
The link name for citing a PDF annotation.
Determines whether citation links should be sorted on-the-fly.
Determines whether a node corresponding to the source buffer is to be shown in the subgraph visualization.
Determines whether the set of arcs in the visualization of the selected subgraph should be restricted to the arcs traversed by the uniform-cost search that built the subgraph.
The folder used by default for exporting the survey.
This module contains functions for creating the survey, including the the wizard for inserting subgraph visualizations.
Returns the file name for export without extension. ORIG-FILE-NAME is like FILE in org-export-to-file
. Thus, the file name may need to be computed from the selected subgraph’s source or input by the user.
The version of org-export-to-file
that supports exporting the selected subgraph. BACKEND and FILE are as in org-export-to-file
.
It performs some pre-processing and then calls ORIG-FUN, which is the original org-export-to-file
. When exporting the selected subgraph, the pre-processing includes computing the file name for export to be passed to org-export-to-file
.
For each citation in the current buffer, insert a reference to the sections corresponding to the keys in the selected subgraph. Properly handle comma-separated citations.
The interactive wizard for inserting the code block that calls literef-subgraph-image-file-link, with the purpose of having a subgraph visualization in the survey.
Return t
if the notes for KEY are valid notes that can be inserted into a survey and nil
otherwise. Currently the notes are considered valid if they are not empty.
Compute the list of keys whose notes are to be inserted into the survey.
Make the bibliography file named BIB-FILE-NAME containing only the entries for the keys appearing in the survey.
Compute text for the reference for the given KEYS, e.g. “[1,4,10]”.
Remove all citation function links and the spaces preceding them in the current buffer.
Return the contents of the source buffer, as follows:
- During basic export, i.e. if not exporting the selected subgraph, return contents of the current buffer.
- Otherwise, if the source is a paper or the whole citation graph, then return empty string.
- Otherwise, if the source buffer of the selected subgraph exists and is visiting the source file, then the source buffer’s contents is returned.
- Otherwise, return the source file’s contents if that file exists.
- Otherwise, abort the export and report an error.
The version of org-export-dispatch
that works with the selected subgraph.
7.5.a.12 literef-subgraph-image-file-link(key-or-file literef-subgraph-show-buffer buffer-node-name filter caption name attr-latex attr-html)
Create an image for the subgraph with the source specified by KEY-OR-FILE and the arcs filter string FILTER, while respecting the value of LITEREF-SUBGRAPH-SHOW-BUFFER (see the variable literef-subgraph-show-buffer) and BUFFER-NODE-NAME (see literef-select-subgraph-for-export and the variable literef-subgraph-show-buffer). Return a link to the created image. The caption, name and export attributes are set using the last three arguments.
Compute the file name for the image visualizing the subgraph. If FILE-NAME is under the LiteRef directory, return the ELisp expression that constructs the file name using the value of the variable literef-directory, which must be defined in Emacs
configuration (hence not linked in the HTML documentation). Otherwise, return FILE-NAME as is surrounded by quotes.
The value of this variable is inserted by the exporter before citations that should not be supplied by reference during the later phase of export. This trick is used to avoid inserting self-references in the section headings of the survey.
This module contains functions for both building the citation graph from scratch and updating it dynamically upon changes in the researcher’s notes. The updates take place whenever notes associated with a key are saved.
Add keys in CITATION-LINK and the citation FUNCTIONS to HASH, in which keys are keys of BibTeX entries and values are sets of citation functions corresponding to the keys. Return the resulting hash.
Compute the citation graph, with keys corresponding to all the papers in the papers database in the vertex set, from scratch.
Add an arc in GRAPH from FROM-KEY to TO-KEY labeled by CITATION-FUNCTIONS. If GRAPH is not specified, it is given by the current value of the variable literef-graph.
Add KEY to GRAPH. If GRAPH is not specified, it is given by the current value of the variable literef-graph.
Return the citation functions by which an arc in GRAPH from FROM-KEY to TO-KEY is labeled. If GRAPH is not specified, it is given by the current value of the variable literef-graph.
Return the set of arcs associated with KEY. If KEY is not in the citation graph, but is a valid key from the database, then add it to the citation graph. If KEY is not a valid key, then, throw fatal error instead, unless NO-ERROR is not nil
, in which case nil
is returned.
Update the citation graph based on the current version of the notes associated with KEY.
Initialize the citation graph using INIT-KEYS as the list of keys. If the optional INIT-KEYS is not specified, all of the keys in the papers database are used.
Compute the in-neighbors of KEY in GRAPH. If GRAPH is not specified, it is given by the current value of the variable literef-graph. If KEY is not in GRAPH, it is added.
Compute a mapping, where keys are citations in the notes associated with KEY and values are functions associated with each citation.
Compute the out-neighbors of KEY in GRAPH. If GRAPH is not specified, it is given by the current value of the variable literef-graph. If KEY is not in GRAPH, it is added.
For the current buffer, compute a mapping, where keys are citations (i.e. keys of the BibTeX entries of the cited papers) and values are functions associated with each citation.
This hook is called to update the citation graph whenever the notes associated with a key are saved.
This module contains functions that implement the formation of the candidate list of the helm
interface for searching in the papers database and handle actions associated with these candidates.
Transform the initial list of ACTIONS associated with the CANDIDATE.
Return the value in A-LIST (see https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html) associated with the PROPERTY of a candidate in helm
. If no value is associated with the PROPERTY, return nil
.
Compare the authors property of the candidates C1 and C2 using the inverse of literef-str-compare.
Compare the authors property of the candidates C1 and C2 using literef-str-compare.
Compute the string to be displayed in helm for the candidate C.
Return the PROPERTY of the candidate C or nil
if the candidate does not have such a property.
Transform the initial candidate list given by CANDIDATES.
Return the venue of the candidate C or nil
of this property is not specified.
Compute the venue type of the candidate C based on its key property.
Return the comparison function symbol corresponding to CHAR, which is assumed to be one of the characters as in the variable literef-citation-link-sorting-criteria. If CHAR is not one of those characters, then return nil
.
Compare the candidates C1 and C2 based on the value of the variable literef-criteria.
Compute the list of comparison functions from the list of characters CHARS as in the variable literef-citation-link-sorting-criteria.
Transform the candidates list CANDIDATES by sorting.
Computes the list of keys that are currently marked in helm
.
Compare the key property of the candidates C1 and C2 using the inverse of literef-str-compare.
Compare the key property of the candidates C1 and C2 using literef-str-compare.
The LiteRef version of helm-kill-ring-action-yank
, which performs intelligent yanking of keys.
Handle interactive input of the search criteria.
Compare the PROPERTY of the candidates C1 and C2. If the property is specified for both candidates, it is assumed to be of string type.
The version of org-ref-helm-cite
, in which the candidates are restricted to the selected subgraph.
Compare the candidates C1 and C2 based on timestamps of the corresponding entries in the papers database. Respect the value of the variable literef-equal-timestamps when deciding whether the two timestamps are equal.
Compare timestamps of the candidates C1 and C2 using the inverse of literef-timestamp-compare.
Compare timestamps of the candidates C1 and C2 using literef-timestamp-compare.
Compare the title property of the candidates C1 and C2 using the inverse of literef-str-compare.
Compare the title property of the candidates C1 and C2 using literef-str-compare.
Compare the venue property of the candidates C1 and C2 using the inverse of literef-raw-str-compare.
Compare the venue type property of the candidates C1 and C2 using literef-raw-str-compare.
Compare the venue property of the candidates C1 and C2 using the inverse of literef-raw-str-compare.
Compare the venue property of the candidates C1 and C2 using literef-raw-str-compare.
Compare the year property of the candidates C1 and C2 using the inverse of literef-str-compare.
Compare the year property of the candidates C1 and C2 using literef-str-compare.
The criteria for sorting candidates. See the variable literef-citation-link-sorting-criteria for the possible values.
This module contains mappings for handling accented characters and functions for correctly displaying BibTeX entries containing such characters.
The version of bibtex-completion-get-value
that maps accented characters. ARGS are simply forwarded to bibtex-completion-get-value
.
Apply the mapping given by the value of the variable literef-latex-map to translate escaped characters in the string STR.
This is a modified map from https://raw.githubusercontent.com/clarkgrubb/latex-input/master/latex.el.
The mapping to be used, must be either literef-latex-full-map or literef-latex-small-map.
A shorter version of the mapping contained in the variable literef-latex-full-map used for performance considerations. It can be shortened further if needed. See https://stackoverflow.com/a/4580132/2725810.
This module contains the definition of the PDF annotation link. It provides functions for inserting such links into the researcher’s notes and handling the operations associated with these links, including the translation of these links to page references during export. In addition, this module handles import of papers by letting the user select a region in the PDF, e.g. in the references section of a paper. Lastly, the module supports searching for keys whose PDF matches a search criteria and inserting those keys into the current notes buffer.
Compute the list of buffers that are currently in the major mode MODE.
Let the user choose an annotation in an open PDF of a paper by clicking on the annotation. Inserts a PDF annotation link corresponding to the chosen annotation into the active notes buffer. Only PDFs open in the PDFView mode are handled.
Return the first word in the string LINE.
Jump to the place in the PDF pointed to by PATH, which is the path component of a PDF annotation link.
Search for a BibTeX entry in the online sources based on the selected region in the paper PDF.
Determine whether a line ending with the word LINE1-LAST and hyphen and the line beginning with the word LINE2-FIRST should be glued without the use of a hyphen when presenting those two lines as a single line. This involves trying to glue them without a hyphen and checking whether the resulting string is a word in the dictionary. If both glued and non-glued variants are correct or wrong, then the user is prompted to make a choice.
Return the last word in the string LINE if it is followed by
hyphen. If LINE is not ended with word and hyphen, return nil
.
Compute the page reference string that is to be substituted during exporting the survey for PDF annotation link with the path component PATH.
Return the list of keys, whose corresponding PDF is currently open in a buffer. This is done by looping through the open buffers and checking for each buffer currently in the PDFView mode whether it corresponds to an entry in the papers database.
Yank into the current notes buffer the citation links for the keys
matched by searching for STRING in the first page of the PDFs in the
papers database. LiteRef’s intelligent yanking is used. The function
relies on the pdfgrep
shell command. The string STRING must be a
valid search pattern for that command.
Compute a single-line query based on the possibly multi-line QUERY for searching for a BibTeX entry in the online sources, while correctly handling hyphen at the end of lines.
No variables are defined by this module.
This module contains functions that handle communication with the Python server.
Compute the name of the next request file.
Submit request to the server. TYPE is either “getPdf” or “getBib”. If it is “getPdf”, then DATA is the key for which pdf is required. If it is “getBib”, then DATA is the search query.
No variables are defined by this module.
This module handles the whole process of building the citation subgraph, beginning with specifying the source and the arc filter and culminating in the uniform-cost search that builds the subgraph. It also handles building the subgraphs for the source blocks inserted into the researcher’s notes by the wizard. Lastly, it defines a minor mode for viewing the subgraph in a variety of formats.
Handle the arc represented by FROM-KEY and TO-KEY-CONS (consisting of a key and a plist). If the arc fits the filter, then both the sink key (i.e. the car component of TO-KEY-CONS) and the corresponding generating arc are inserted in the current subgraph. If, in addition, the duplicate detection is passed, then add the sink key to the keys for the next iteration.
Append spaces to all lines in the current buffer, so they become at least the given REQUIRED-LENGTH long.
The company-mode back-end for entering the filter with completion for citation functions. The technique is described at http://sixty-north.com/blog/writing-the-simplest-emacs-company-mode-backend.
Return t
if the current arc satisfies the filter and nil
otherwise. The implementation used for each particular building of the citation subgraph is formed by literef-make-arc-filter.
Return the symbol named literef-temp-<prefix>STR. The prefix is determined by the variable literef-arc-filter-variables-prefix.
Return the list of variables recognized by the arc filter. Respects the variable literef-arc-filter-variables-prefix.
Return t
if the arc from FROM-KEY to TO-KEY is a generating arc of the current subgraph and nil
otherwise.
Return t
if the arc represented by FROM-KEY and TO-KEY-CONS (consisting of a key and a plist) fits the arc filter and nil
otherwise.
The definition of the minor mode for viewing the selected subgraph.
Make and return a new subgraph consisting of all the keys in the citation graph.
Return t
if KEY is in the current subgraph and nil
otherwise.
Return t
if the LIST of citation functions satisfies the PREDICATE
and nil
otherwise.
Compute the length of the longest line in the current buffer.
Form and evaluate the function literef-arc-filter-p corresponding to the filter represented by the string STR.
Compute the neighbors pairs consisting of key and properties that fit the required DIRECTION of the arc. The properties are computed based on CUR-PROPERTIES of the key being expanded. Properties include depth, direction and citation functions.
Read the string representing an arc filter, while providing completion of citation functions. The recognized citation functions are given by the value of the variable literef-citation-functions. Prompt the user with the string PROMPT.
Select subgraph of the citation graph given by the variable literef-graph. If KEY is specified, it is considered to be the currently active key to be used as the source. All the information needed for building the subgraph, such as the arc filter, is requested from the user.
Select subgraph of the citation graph given by the value of the variable literef-graph for forming its visualization, with KEY-OR-FILE used as the source, FILTER used as the filter string and BUFFER-NODE-NAME used as the name of the buffer node in the visualization. In contrast to literef-select-subgraph, this function is non-interactive. It is to be called from a source block inserted into the survey by the wizard.
Return a string representation of the current subgraph in the given FORMAT.
For “txt” or “boxart” FORMAT, keys and labels are links. For non-clickable formats, such as “png”, links are not used to save space.
The function respects the values of the variable literef-subgraph-show-only-generating-arcs and the variable literef-subgraph-show-buffer.
Visualize the selected subgraph. Respects literef-subgraph-show-only-generating-arcs and literef-subgraph-show-buffer.
Compute the visualization of the selected subgraph using the “png” format and show it in a buffer. Respects the value of the variable literef-subgraph-show-only-generating-arcs and the variable literef-subgraph-show-buffer.
Compute the visualization of the selected subgraph using FORMAT, such as “boxart” or “png” and show it in a buffer. Respects the value of the variable literef-subgraph-show-only-generating-arcs and the variable literef-subgraph-show-buffer.
Add a generating arc from FROM-KEY to TO-KEY to the current subgraph.
Add KEY to the current-subgraph.
Build the current subgraph based on its source. If the source type is :buffer
, assumes that the source buffer is currently active.
Compute the list of keys for forming the subgraph. All the keys cited in the source are used. If the source is a buffer, it is assumed to be currently active.
Return the generating arcs component of the current subgraph.
Return the initial keys component of the current subgraph.
Return the keys component of the current subgraph.
Reset the subgraph selection to be the entire citation graph.
Save the visualization of the selected subgraph using FORMAT, such as “boxart” or “png” in a temporary file and return the file’s name. Respects the values of the variable literef-subgraph-show-only-generating-arcs and the variable literef-subgraph-show-buffer.
Compute the source for forming the current subgraph based on the optional arguments, as follows.
- If KEY is specified, it becomes the source. Otherwise,
- If some key is currently active, it becomes the source. Otherwise,
- If FILE is specified and the file exists, it becomes the source. Otherwise,
- The file returned by
buffer-file-name
becomes the source.
Set the initial keys component of the current subgraph to KEYS.
Set the property PROPERTY of the source of current subgraph to VALUE.
Return the source component of the current subgraph.
Return the value of the property PROPERTY of the source of current subgraph.
Build the current subgraph by performing uniform-cost search from INITIAL-KEYS while respecting the current arc filter. The search keeps direction. That is, if the current key was reached by following an outgoing arc, then only the out-neighbors of that key will be considered for the next iteration.
Non-=nil= if Literef-Graph mode is enabled. Use the command literef-graph-mode to change this variable.
Hook run after entering or leaving literef-graph-mode.
No problems result if this variable is not bound.
add-hook
automatically binds it. (This is true for all hook variables.)
The key map for the minor mode for viewing the selected subgraph literef-graph-mode.
The selected subgraph with the following components:
:keys – the hash of keys in the subgraph.
:initial-keys – the list of keys, which served as the root of the uniform-cost search that built the subgraph.
:generating-arcs – the arcs that were traversed by the uniform-cost search that built the subgraph.
:source – the source, based on which the subgraph was constructed. The source consists of:
- :source-type – the type of the source for building the graph. This can be
:all-keys
,:key
or:buffer
. - :source-name – the name of key or buffer.
- :buffer-node-name – the name to be used for the node corresponding to the buffer source in the visualization.
- :file-name – the file which the source buffer was visiting at the time of building the subgraph.
- :filter-string – the arcs filter that was used to construct the graph.
This module contains some helper functions to make working with links in the other modules convenient.
Compute the list of all links in the current buffer that satisfy a
given PREDICATE (if PREDICATE is nil
, all links are included). The
links are sorted by their begin positions. The :end
property is
substituted to be the actual end point of the link without spaces
after it.
Return t
if the LINK is a citation function link and nil
otherwise.
Compute the list of all citation function links in the current buffer, sorted by the begin position.
Return t
if the LINK is a citation link and nil
otherwise.
Return the citation link at point. If the cursor is not over a
citation link, return nil
.
Compute the list of all citation links in the current buffer, sorted by their begin positions.
Return the first citation link on the current line. If there is no citation link on the line, return nil
.
The beginning point of the LINK.
The end point of the LINK. The spaces following the link are not included.
Return the path component of the LINK.
Extract keys from the LINK’s path component.
The org-element adjacent and before the LINK.
Return the position of the first non-blank character before the LINK.
Determine which of the links LINK1 and LINK2 appears earlier in the buffer. The two links are assumed to appear in the same buffer. Return t
if LINK1 appears before LINK2 and nil
otherwise.
No variables are defined by this module.
This module contains some helper functions. Some of these, such as literef-xor, are not related to LiteRef functionalities per se and can be used by other projects. Others, such as literef-bib-files are LiteRef-specific, but are used by many modules and hence are separated out as utilities.
Compute the list of all keys in the papers database.
Compute the name of the BibTeX file based on KEY.
Compute the list of BibTeX files in the papers database.
Compute key based on the BUFFER visiting a file associated with a paper. If the buffer is not visiting a file associated with a paper, return nil
.
Compute the list of all keys cited in the current buffer, sorted and with duplicates removed.
Open PDFs for the keys contained in the list given by the value of the variable literef-needed-pdfs.
Compute the creation timestamp of the database entry corresponding to KEY as a floating-point number of seconds. We use the modification timestamp of the BibTeX file, since, in general, the creation timestamp might not be stored by the operating system and accessing the creation date for ext4 is not trivial.
Compute key of the paper whose associated file is being visited by
the current buffer. If the current buffer is not visiting a file
associated with a paper, return nil
.
Return the key at point. If there is no key under the cursor, then return the key whose associated file is being visited by the current buffer. If the current buffer is not visiting a file associated with a paper, return nil
.
Evaluate Emacs Lisp code given by STRING. The code is taken from https://emacs.stackexchange.com/a/19878/16048.
Compute key based on the name FILENAME of one of the files associated with a paper. If the file is not associated with a paper, return nil
.
Compute the name of a file with the extension EXT pertaining to a paper whose BibTeX entry’s key is KEY. Note that this file does not need to exist.
The version of find-file-other-window
that does not do anything if the file is already being visited in the current window.
Compute key based on a paper’s FOLDER in the papers database. If FOLDER does not correspond to a paper, return nil
.
Non-throwing version of org-ref-get-bibtex-key-under-cursor
. This version does not affect the current point in the buffer.
The version of bibtex-completion-get-entry1
with the only source set to the bib file corresponding to the given key, which is the entry-key argument contained in ARGS.
Return t
if HASH is empty and nil
otherwise.
Return a list of keys that are present in HASH1, but not in HASH2.
Return a list of keys in HASH.
Return a list of key-value pairs in HASH.
Join the list STRINGS of strings putting the SEPARATOR string between them.
Return t
if KEY exists and nil
otherwise.
Compute name of the notes file based on KEY.
Convert STRING to number. Return nil
if STRING does not represent a number.
Return t
if STRING represents a number and nil
otherwise.
Open the BibTeX file for the current key. See literef-current-key.
Open the researcher’s notes for KEY.
Open the PDF for KEY. This function should not be used directly.
Open the researcher’s notes for the current key. See literef-current-key.
Open the PDF for the current key. See literef-current-key.
Compute name of the PDF file based on KEY.
Just a shortcut for (setq plist (plist-put PLIST PROP VAL)).
Compare strings S1 and S2. Return -1 if S1 is smaller than S2, 1 if S2 is smaller than S1 and 0 if the strings are equal.
Read a char until one of the chars in LEGAL-CHARS is entered. Return the last read char. Prompt the user with PROMPT.
Read either a number or “nil” from the user and return it.
Like replace-in-string
, but replaces whole words. The code is taken from https://emacs.stackexchange.com/a/34665/16048.
Set org-ref-default-bibliography
to be the list of all the BibTeX files in the papers database.
If STRING is nil
, return “nil”, otherwise return STRING.
Return t
if WORD is spelled correctly and nil
otherwise. Adapted from flyspell-correct-word-before-point
.
Replace each occurrence of WHAT in the string IN with WITH. The code is taken from https://stackoverflow.com/a/17325791/2725810.
Executes BODY just like progn
but maintain the original buffer state. The code is taken from https://emacs.stackexchange.com/a/31763/16048.
Keys whose PDFs are currently being searched for in the online sources.
Please follow this link to the documentation of the server API.