Skip to content

Commit

Permalink
Add (optional) ebib support to bibtex layer
Browse files Browse the repository at this point in the history
  • Loading branch information
dalanicolai committed Jun 29, 2021
1 parent 64fed6f commit 61a9e63
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.develop
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ Other:
- Key bindings:
- Replaced =org-ref-helm-insert-cite-link= with =org-ref-insert-link=
(thanks to Tianshu Wang)
- Add [[https://joostkremers.github.io/ebib/ebib-manual.html][ebib]] support (thanks to Daniel Nicolai)
**** C-C++
- Breaking changes:
- Moved =cmake-ide= and cmake script support to separate =cmake= layer
Expand Down
58 changes: 57 additions & 1 deletion layers/+lang/bibtex/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- [[#features][Features:]]
- [[#install][Install]]
- [[#configuration][Configuration]]
- [[#ebib-and-biblio][Ebib and biblio]]
- [[#comment][Comment]]
- [[#key-bindings][Key bindings]]

* Description
Expand All @@ -22,6 +24,7 @@ This layer adds support to manipulate BibTeX and BibLaTeX files in Spacemacs.
- Syntax highlighting for BibTeX and BibLaTeX files.
- Utilities for automatically adding entries from different data sources.
- Support for inserting citations in various other modes.
- Optionally install full fledged [[https://joostkremers.github.io/ebib/ebib-manual.html][ebib reference manager]]

* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
Expand Down Expand Up @@ -54,7 +57,39 @@ to use Zathura:
#+END_SRC

More configuration options are available and are detailed in the =org-ref=,
=helm-bibtex= and =ivy-bibtex= package documentations.
=helm-bibtex=, =ivy-bibtex= and [[https://github.com/cpitclaudel/biblio.el][biblio]] package documentations.

** Ebib and biblio
To enable installation of the [[https://joostkremers.github.io/ebib/ebib-manual.html][ebib reference manager]] set the variable
=bibtex-enable-ebib-support= as shown in the following code block:
#+begin_src emacs-lisp :tangle yes
(bibtex :variables
bibtex-enable-ebib-support t
ebib-preload-bib-files '("path-to-bib-file.bib")
ebib-file-search-dirs '("/path-to-documents-directory")
ebib-import-directory "path-to-e.g.-download-directory")
#+end_src
The code block also shows how to set some optional [[https://joostkremers.github.io/ebib/ebib-manual.html][ebib]] variables.

With the installation of the =ebib= package, Spacemacs automatically loads the
[[https://joostkremers.github.io/ebib/ebib-manual.html#integration-with-the-biblio-package][ebib-biblio]] package that uses the [[https://github.com/cpitclaudel/biblio.el][biblio]] package to provide an easy way of
fetching citations from the web into the database (follow the links to the
packages additional descriptions and usage instructions).

*** Comment
If you prefer to use an additional external reference manager (e.g. for the
browser extension functionality), then note that [[https://www.jabref.org/][JabRef]] stores and manages
its database as .bib file, while [[https://www.zotero.org/][Zotero]] uses a sqlite database.
Additionally, JabRef does not require a running instance to use its
browser-extension. However, if you rely on the Zotero web-api, then you
might prefer to stay with Zotero and use the [[https://gitlab.com/fvdbeek/emacs-zotero][Emacs-zotero]] package.

To migrate from Zotero to =Ebib=, simply export your database including the
files. Then, to fix the file paths use the following *evil* replace regexp
pattern in the exported .bib file:
#+begin_src
:%s/^\t\(file = {\).*files\/\([0-9]+\/.+\.pdf\).*\(}\)/\1\2\3
#+end_src

* Key bindings
In a Bib(La)TeX file, the following key bindings are added:
Expand Down Expand Up @@ -82,3 +117,24 @@ key binding added:
| Key binding | Description |
|-------------+-----------------|
| ~SPC m i c~ | Insert citation |

*EBIB*

*Index buffer*
| Key Binding | Description |
|-----------------+-------------------------------------------------------|
| ~J/K~ | scroll page down/up |
| ~SPC m j~ | jump to entry (searches only author and title fields) |
| ~SPC u SPC m j~ | jump to entry (only) in current database |
| ~/~ | ebib-search (searches in all fields) |
| ~n~ | ebib-search-next |
| ~e~ | switch to entry buffer |
| ~SPC m k~ | delete current entry |
| ~SPC m b~ | fetch current entry bibtex from web |
| ~q~ | quit ebib |

*Entry buffer*
| ~q~ | quit entry buffer |

*Biblio selection buffer*
| ~e~ | import entry to current database |
49 changes: 48 additions & 1 deletion layers/+lang/bibtex/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
(ivy-bibtex :requires ivy)
markdown-mode
org
org-ref))
org-ref
biblio
(ebib :toggle bibtex-enable-ebib-support)))

(defun bibtex/post-init-auctex ()
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
Expand Down Expand Up @@ -110,3 +112,48 @@
"ld" 'doi-utils-add-bibtex-entry-from-doi
"li" 'isbn-to-bibtex
"lp" 'pubmed-insert-bibtex-from-pmid))))

(defun bibtex/init-ebib ()
(use-package ebib
:defer t
:init
(spacemacs/set-leader-keys "ate" 'ebib)
:config
(setq ebib-bibtex-dialect 'biblatex)

(evilified-state-evilify-map ebib-index-mode-map
:mode ebib-index-mode
:bindings
"j" 'ebib-next-entry
"k" 'ebib-prev-entry
"J" 'evil-scroll-page-down
"K" 'evil-scroll-page-up

"/" 'ebib-search
"n" 'ebib-search-next)

(spacemacs/set-leader-keys-for-major-mode 'ebib-index-mode
"j" 'ebib-jump-to-entry
"k" 'ebib-kill-entry
"b" 'biblio-lookup)

(evilified-state-evilify-map ebib-entry-mode-map
:mode ebib-entry-mode)

(evilified-state-evilify-map ebib-log-mode-map
:mode ebib-log-mode)

(use-package ebib-biblio
:after (ebib biblio)
:config
(evilified-state-evilify-map biblio-selection-mode-map
:mode biblio-selection-mode
:bindings
"e" 'ebib-biblio-selection-import
(kbd "C-j") 'biblio--selection-next
(kbd "C-k") 'biblio--selection-previous))
))

(defun bibtex/init-biblio()
(use-package biblio
:defer t))

0 comments on commit 61a9e63

Please sign in to comment.