-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This page is for tips and tricks for using Ebib, things that may be useful to others but haven't (yet) been added to Ebib. Anyone is welcome to edit this page and add tips.
Contributed by mardukbp.
(defun ebib-attach-file ()
"Attach file to gnus/mu4e composition buffer"
(interactive)
(ebib-execute-when
((entries)
(let ((filename (to-raw (car (ebib-get-field-value ebib-standard-file-field
(edb-cur-entry ebib-cur-db))))))
(if filename
(ebib-dired-attach filename)
(error "Field `%s' is empty" ebib-standard-file-field))))
((default)
(beep))))
(defun ebib-dired-attach (file)
"Attach FILENAME using gnus-dired-attach."
(let ((file-full-path
(or (locate-file file ebib-file-search-dirs)
(locate-file (file-name-nondirectory file) ebib-file-search-dirs)
(expand-file-name file))))
(if (file-exists-p file-full-path)
(progn
(gnus-dired-attach (cons file-full-path '()))
(ebib-lower))
(error "File not found: `%s'" file-full-path))))
Contributed by mardukbp.
One of the great features of Zotero is that with one click you get the citation and the PDF added to your library. Thanks to arxiv2bib, conkeror and emacsclient it takes one (emacs-ish) keystroke to accomplish the same thing.
The following Elisp code creates the command ebib-import-arxiv
:
(setq arxiv-dir "~/Papers/arxiv/") ; change dir as desired
(defun ebib-import-arxiv (arxiv-url)
(interactive)
(let ((tempbuff (get-buffer-create "*arxiv*"))
(arxiv-id (car (cdr (split-string arxiv-url "abs/"))))
(arxiv-pdf-url (concat (replace-regexp-in-string "abs" "pdf" arxiv-url) ".pdf")))
(call-process-shell-command "arxiv2bib.py" nil tempbuff nil arxiv-id)
(call-process-shell-command "links" nil nil nil
"-source" arxiv-pdf-url "> " (concat arxiv-dir arxiv-id ".pdf"))
(with-current-buffer tempbuff
(ebib-import))))
The following snippet should go into ~/.conkerorrc
:
function ebib_import_arxiv (url) {
var cmd_str = 'emacsclient -ne \'(ebib-import-arxiv \"' + url + '\")\'';
shell_command_blind(cmd_str);
}
interactive("arxiv2ebib", "Download PDF and add bibtex entry for current preprint to ebib",
function (I) {
ebib_import_arxiv(I.buffer.display_uri_string);
});
define_key(content_buffer_normal_keymap, "C-c c", "arxiv2ebib");
Contributed by mardukbp.
In addition to the previous tip, here is the corresponding code for importing a paper's citation in bibtex format directly from the journal's website. The following Elisp code defines the command ebib-import-bibtex
:
(require 'mm-url)
(defun ebib-import-bibtex (url)
(interactive)
(with-temp-buffer
(mm-url-insert-file-contents url)
(ebib-import)))
The following snippet should go into ~/.conkerorrc
:
function ebib_import_bibtex (url) {
var cmd_str = 'emacsclient -ne \'(ebib-import-bibtex \"' + url + '\")\'';
shell_command_blind(cmd_str);
}
interactive("bibtex2ebib", "Download PDF and add bibtex entry for current preprint to ebib",
function (I) {
ebib_import_bibtex(I.buffer.display_uri_string);
});
define_key(content_buffer_normal_keymap, "C-c f", "bibtex2ebib");
Contributed by kuerzn.
The function ebib-show-from-org-subtree
extracts all references (links to Ebib) from the current org subtree and filters the current database to display only those entries:
(defun ebib-show-from-org-subtree ()
(interactive)
(let ((keys (org-extract-references-from-subtree)))
(ebib-db-set-filter `(contains "=key=" ,(regexp-opt keys))
ebib--cur-db)
(ebib--redisplay)))
(defun org-extract-references-from-subtree ()
(let (res)
(org-map-tree
(lambda ()
(re-search-forward "^\\** \\(.*\\)$")
(goto-char (match-beginning 1))
(let* ((limit (match-end 1)))
(while (re-search-forward "\\<ebib:\\(\\w+\\)\\>" limit t)
(push (match-string-no-properties 1) res)))))
res))