aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@rak.ac>2022-03-19 15:07:52 -0400
committerRyan Kavanagh <rak@rak.ac>2022-03-19 15:08:43 -0400
commite03f199154e881f128353e94561b2570dfd310cc (patch)
treea8d641f4072dde94c04d559495dbb2969dfa70ae
parentMailing lists (diff)
emacs config
Diffstat (limited to '')
-rw-r--r--dot_emacs153
1 files changed, 81 insertions, 72 deletions
diff --git a/dot_emacs b/dot_emacs
index 7e3aeda..44ec5a8 100644
--- a/dot_emacs
+++ b/dot_emacs
@@ -545,78 +545,6 @@ Returns a formatted BibTeX entry."
(use-package org-ref-bibtex
:ensure org-ref
- :config
- (defun my/org-ref-format-url-if-doi ()
- "Override built-in function. Originally, this reformatted
-the url to point to DOI. I would rather kill the URL field
-entirely if it contains the DOI. bibtex-clean-entry will then
-delete the field."
- (interactive)
- (save-excursion
- (bibtex-beginning-of-entry)
- (let ((doi (bibtex-autokey-get-field "doi")))
- (unless (string-empty-p doi)
- (when (string-match-p (regexp-quote (org-ref-bibtex-entry-doi))
- (bibtex-autokey-get-field "url"))
- (bibtex-set-field "url" ""))))))
- (defun my/org-ref-biblatex-journaltitle ()
- "Rename journal to journaltitle"
- (interactive)
- (save-excursion
- (bibtex-beginning-of-entry)
- (let ((journal (bibtex-autokey-get-field "journal"))
- (journaltitle (bibtex-autokey-get-field "journaltitle")))
- (when (and (string-empty-p journaltitle)
- (not (string-empty-p journal)))
- (bibtex-beginning-of-entry)
- (bibtex-set-field "journal" "")
- (bibtex-set-field "journaltitle" journal)))))
- (defun my/biblatex-date ()
- "Convert 'year' + 'month' fields to 'date' field"
- (interactive)
- (save-excursion
- (bibtex-beginning-of-entry)
- (let* ((year (bibtex-autokey-get-field "year"))
- (month (downcase (bibtex-autokey-get-field "month")))
- (nummonth (cond ((string= month "jan") "01")
- ((string= month "feb") "02")
- ((string= month "mar") "03")
- ((string= month "apr") "04")
- ((string= month "may") "05")
- ((string= month "jun") "06")
- ((string= month "jul") "07")
- ((string= month "aug") "08")
- ((string= month "sep") "09")
- ((string= month "oct") "10")
- ((string= month "nov") "11")
- ((string= month "dec") "12")
- (t "")))
- (olddate (bibtex-autokey-get-field "date"))
- (newdate (cond ((string-empty-p year) nil)
- ((string-empty-p nummonth) year)
- (t (concat year "-" nummonth)))))
- (when (and (string-empty-p olddate)
- (not (string-empty-p newdate)))
- (bibtex-beginning-of-entry)
- (bibtex-set-field "date" newdate)
- (bibtex-set-field "year" "")
- (bibtex-set-field "month" "")))))
- (defun my/orcb-check-journal ()
- "Check entry at point to see if journal exists in `org-ref-bibtex-journal-abbreviations'.
-If not, issue a warning."
- (interactive)
- (when
- (string= "article"
- (downcase
- (cdr (assoc "=type=" (bibtex-parse-entry)))))
- (save-excursion
- (bibtex-beginning-of-entry)
- (let* ((entry (bibtex-parse-entry t))
- (journal (replace-regexp-in-string "[[:space:]\n]+" " " (reftex-get-bib-field "journaltitle" entry))))
- (when (null journal)
- (error "Unable to get journal for this entry."))
- (unless (member journal (-flatten org-ref-bibtex-journal-abbreviations))
- (message "Journal \"%s\" not found in org-ref-bibtex-journal-abbreviations." journal))))))
:custom
(org-ref-title-case-types '(("article" "title")
("book" "booktitle" "title")
@@ -662,8 +590,13 @@ If not, issue a warning."
("Transactions of the American Mathematical Society")
("{ACM} {SIGACT} News" "ACM SIGACT News"))))
+(use-package reftex-cite
+ :ensure t)
+
(use-package org-ref-core
:ensure org-ref
+ :after org-ref-bibtex
+ :after reftex-cite
:after helm-bibtex
:bind (:map bibtex-mode-map
("C-c C-c" . org-ref-clean-bibtex-entry)
@@ -701,6 +634,77 @@ If not, issue a warning."
("′" . "'") ; PRIME
("”" . "''"))
org-ref-nonascii-latex-replacements))
+ (defun my/org-ref-format-url-if-doi ()
+ "Override built-in function. Originally, this reformatted
+the url to point to DOI. I would rather kill the URL field
+entirely if it contains the DOI. bibtex-clean-entry will then
+delete the field."
+ (interactive)
+ (save-excursion
+ (bibtex-beginning-of-entry)
+ (let ((doi (bibtex-autokey-get-field "doi")))
+ (unless (string-empty-p doi)
+ (when (string-match-p (regexp-quote (org-ref-bibtex-entry-doi))
+ (bibtex-autokey-get-field "url"))
+ (bibtex-set-field "url" ""))))))
+ (defun my/org-ref-biblatex-journaltitle ()
+ "Rename journal to journaltitle"
+ (interactive)
+ (save-excursion
+ (bibtex-beginning-of-entry)
+ (let ((journal (bibtex-autokey-get-field "journal"))
+ (journaltitle (bibtex-autokey-get-field "journaltitle")))
+ (when (and (string-empty-p journaltitle)
+ (not (string-empty-p journal)))
+ (bibtex-beginning-of-entry)
+ (bibtex-set-field "journal" "")
+ (bibtex-set-field "journaltitle" journal)))))
+ (defun my/biblatex-date ()
+ "Convert 'year' + 'month' fields to 'date' field"
+ (interactive)
+ (save-excursion
+ (bibtex-beginning-of-entry)
+ (let* ((year (bibtex-autokey-get-field "year"))
+ (month (downcase (bibtex-autokey-get-field "month")))
+ (nummonth (cond ((string= month "jan") "01")
+ ((string= month "feb") "02")
+ ((string= month "mar") "03")
+ ((string= month "apr") "04")
+ ((string= month "may") "05")
+ ((string= month "jun") "06")
+ ((string= month "jul") "07")
+ ((string= month "aug") "08")
+ ((string= month "sep") "09")
+ ((string= month "oct") "10")
+ ((string= month "nov") "11")
+ ((string= month "dec") "12")
+ (t "")))
+ (olddate (bibtex-autokey-get-field "date"))
+ (newdate (cond ((string-empty-p year) nil)
+ ((string-empty-p nummonth) year)
+ (t (concat year "-" nummonth)))))
+ (when (and (string-empty-p olddate)
+ (not (string-empty-p newdate)))
+ (bibtex-beginning-of-entry)
+ (bibtex-set-field "date" newdate)
+ (bibtex-set-field "year" "")
+ (bibtex-set-field "month" "")))))
+ (defun my/orcb-check-journal ()
+ "Check entry at point to see if journal exists in `org-ref-bibtex-journal-abbreviations'.
+If not, issue a warning."
+ (interactive)
+ (when
+ (string= "article"
+ (downcase
+ (cdr (assoc "=type=" (bibtex-parse-entry)))))
+ (save-excursion
+ (bibtex-beginning-of-entry)
+ (let* ((entry (bibtex-parse-entry t))
+ (journal (replace-regexp-in-string "[[:space:]\n]+" " " (reftex-get-bib-field "journaltitle" entry))))
+ (when (null journal)
+ (error "Unable to get journal for this entry."))
+ (unless (member journal (-flatten org-ref-bibtex-journal-abbreviations))
+ (message "Journal \"%s\" not found in org-ref-bibtex-journal-abbreviations." journal))))))
:custom
(org-ref-default-bibliography '("~/Documents/papers/library.bib"))
(org-ref-bibliography-notes "~/Documents/papers/notes.org")
@@ -737,6 +741,11 @@ If not, issue a warning."
(use-package org-ref-pdf
:ensure org-ref)
+(use-package ox-md
+ ;; org-mode to markdown exporter
+ :ensure org
+ :after (org))
+
(use-package outline
:ensure t
:hook (LaTeX-mode . outline-minor-mode))