From a142fe4f0084b4bda473993cc91cb7a8388ba428 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 29 Mar 2015 00:37:49 -0400 Subject: Add bibtex-pages-use-double-hyphen to clean hook --- lisp/init-bib.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lisp/init-bib.el') diff --git a/lisp/init-bib.el b/lisp/init-bib.el index bcef8d0..d0ad40d 100644 --- a/lisp/init-bib.el +++ b/lisp/init-bib.el @@ -15,6 +15,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) (defvar km/bibtex-unimportant-title-words '("a" "aboard" "about" "above" "absent" "across" "after" "against" @@ -87,6 +88,19 @@ all other words unless they are protected by brackets." (goto-char beg) (fill-paragraph)))) +(defun km/bibtex-pages-use-double-hyphen () + "Use double hyphen for page range." + (interactive) + (save-excursion + (bibtex-beginning-of-entry) + (let* ((text-bounds (cdr (bibtex-search-forward-field "pages" t))) + (beg (car text-bounds)) + (end (cadr text-bounds))) + (when text-bounds + (goto-char beg) + (and (re-search-forward "[^A-z0-9]*-[^A-z0-9]*" end t) + (replace-match "--")))))) + (defun km/browse-doi (doi) "Open DOI in browser. When called interactively, take the DOI from the text under -- cgit v1.2.3