summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-01-09 03:30:13 -0500
committerKyle Meyer <kyle@kyleam.com>2016-01-09 03:30:13 -0500
commit96fb1f48553b073b4b9a3c56343a75657b4ca494 (patch)
tree3db14f73d868f8c5c31e9e23f277ec72cf31d9bb /lisp
parent2f8756246fd3edbd12daf8997bd0a831ca905e8c (diff)
downloademacs.d-96fb1f48553b073b4b9a3c56343a75657b4ca494.tar.gz
bibtex-clean-entry-hook: Delete unwanted fields
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-bib.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/init-bib.el b/lisp/init-bib.el
index 67148eb..b998c6a 100644
--- a/lisp/init-bib.el
+++ b/lisp/init-bib.el
@@ -44,6 +44,7 @@
(add-hook 'bibtex-clean-entry-hook 'km/bibtex-downcase-entry)
(add-hook 'bibtex-clean-entry-hook 'km/bibtex-downcase-keys)
(add-hook 'bibtex-clean-entry-hook 'km/bibtex-downcase-author-and)
+(add-hook 'bibtex-clean-entry-hook 'km/bibtex-delete-article-fields)
(defvar km/bibtex-unimportant-title-words
'("a" "aboard" "about" "above" "absent" "across" "after" "against"
@@ -181,6 +182,24 @@ to
(bibtex-end-of-text-in-field bounds) t)
(replace-match (downcase (match-string 0)) 'fixedcase)))))))
+(defvar km/bibtex-article-fields-to-delete
+ '("abstract" "issn" "pubmedid" "url" "eprint" "keywords"))
+
+(defun km/bibtex-delete-article-fields ()
+ (save-excursion
+ (when (and (bibtex-beginning-of-entry)
+ (looking-at bibtex-entry-maybe-empty-head)
+ (string= (downcase (bibtex-type-in-head)) "article"))
+ (dolist (f km/bibtex-article-fields-to-delete)
+ (let (bounds)
+ ;; Make sure field is removed even if it is repeated.
+ (while (progn (bibtex-beginning-of-entry)
+ (setq bounds (bibtex-search-forward-field f t)))
+ (goto-char (bibtex-end-of-field bounds))
+ (skip-chars-backward " \t\n")
+ (delete-region (bibtex-start-of-field bounds)
+ (point))))))))
+
(defun km/browse-doi (doi)
"Open DOI in browser.
When called interactively, take the DOI from the text under