summaryrefslogtreecommitdiff
path: root/lisp/km-bib.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-04-14 22:19:31 -0400
committerKyle Meyer <kyle@kyleam.com>2016-04-14 22:19:31 -0400
commitf098d071cb4ce72bafb41ca7ab3a3849ba1928b0 (patch)
tree20b29e0a94ad5cbcc9a879005b32303dee41c0a4 /lisp/km-bib.el
parent26514848928d8a94cddb3eb8ae241e724e4611ae (diff)
downloademacs.d-f098d071cb4ce72bafb41ca7ab3a3849ba1928b0.tar.gz
bib: Add bibtex-sub-journal command
Diffstat (limited to 'lisp/km-bib.el')
-rw-r--r--lisp/km-bib.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/km-bib.el b/lisp/km-bib.el
index b7b7946..5eb7bdd 100644
--- a/lisp/km-bib.el
+++ b/lisp/km-bib.el
@@ -144,6 +144,24 @@ to
(bibtex-end-of-text-in-field bounds) t)
(replace-match (downcase (match-string 0)) 'fixedcase)))))))
+(defun km/bibtex-sub-journal ()
+ (when (boundp 'km/bibtex-journal-substitutions)
+ (save-excursion
+ (bibtex-beginning-of-entry)
+ (let* ((bounds (bibtex-search-forward-field "journal" t))
+ (beg (1+ (bibtex-start-of-text-in-field bounds)))
+ (end (1- (bibtex-end-of-text-in-field bounds))))
+ (when bounds
+ (let* ((journ (replace-regexp-in-string
+ "[ \n]+" " "
+ (buffer-substring-no-properties beg end)))
+ (sub (assoc-string journ km/bibtex-journal-substitutions)))
+ (when sub
+ (goto-char beg)
+ (delete-region beg end)
+ (insert (cdr sub))
+ (fill-paragraph))))))))
+
(defvar km/bibtex-article-fields-to-delete
'("abstract" "issn" "pubmedid" "url" "eprint" "keywords"))