diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-03-29 00:37:55 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-03-30 01:43:22 -0400 |
commit | b6282c81f42327147da31650e3eff38e704ddbce (patch) | |
tree | 16d1cda89e1a4ffd1515883fddc8586c6e29c7a0 /lisp | |
parent | a142fe4f0084b4bda473993cc91cb7a8388ba428 (diff) | |
download | emacs.d-b6282c81f42327147da31650e3eff38e704ddbce.tar.gz |
Add bibtex-remove-doi-leader to clean hook
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/init-bib.el | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/init-bib.el b/lisp/init-bib.el index d0ad40d..1c44bbe 100644 --- a/lisp/init-bib.el +++ b/lisp/init-bib.el @@ -16,6 +16,7 @@ (add-hook 'bibtex-clean-entry-hook 'km/bibtex-use-title-case) (add-hook 'bibtex-clean-entry-hook 'km/bibtex-single-space-author-list) (add-hook 'bibtex-clean-entry-hook 'km/bibtex-pages-use-double-hyphen) +(add-hook 'bibtex-clean-entry-hook 'km/bibtex-remove-doi-leader) (defvar km/bibtex-unimportant-title-words '("a" "aboard" "about" "above" "absent" "across" "after" "against" @@ -101,6 +102,19 @@ all other words unless they are protected by brackets." (and (re-search-forward "[^A-z0-9]*-[^A-z0-9]*" end t) (replace-match "--")))))) +(defun km/bibtex-remove-doi-leader () + "Remove leading part (http:...) of doi URL." + (interactive) + (save-excursion + (bibtex-beginning-of-entry) + (let* ((text-bounds (cdr (bibtex-search-forward-field "doi" t))) + (beg (car text-bounds)) + (end (cadr text-bounds))) + (when text-bounds + (goto-char beg) + (and (re-search-forward "http://dx.doi.org/" end t) + (replace-match "")))))) + (defun km/browse-doi (doi) "Open DOI in browser. When called interactively, take the DOI from the text under |