]> git.donarmstrong.com Git - org-ref.git/blobdiff - org-ref.org
Merge branch 'master' of https://github.com/divinenephron/org-ref into divinenephron...
[org-ref.git] / org-ref.org
index 9665744c85bcf662ef33af3e9fa5de3cd738bb73..100f8da9f18d575bb5f1e9f375a02dc2adc482db 100644 (file)
@@ -28,11 +28,16 @@ With helm integration (default) you can:
 
 ** Header
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
-;;; org-ref.el --- setup bibliography, cite, ref and label org-mode links.
+;;; org-ref.el --- cite and cross-reference in org-mode
 
 ;; Copyright(C) 2014 John Kitchin
 
 ;; Author: John Kitchin <jkitchin@andrew.cmu.edu>
+;; URL: https://github.com/jkitchin/org-ref
+;; Version: 0.1
+;; Keywords: org-mode, cite, ref, label
+;; Package-Requires: ((dash) (helm) (helm-bibtex))
+
 ;; This file is not currently part of GNU Emacs.
 
 ;; This program is free software; you can redistribute it and/or
@@ -52,11 +57,13 @@ With helm integration (default) you can:
 
 ;;; Commentary:
 ;;
-;; Lisp code to setup bibliography cite, ref and label org-mode links.  also
-;; sets up reftex and helm for org-mode citations. The links are clickable and
-;; do things that are useful. You should really read org-ref.org for details.
+;; Lisp code to setup bibliography cite, ref and label org-mode links.
+;; also sets up reftex and helm for org-mode citations. The links are
+;; clickable and do things that are useful. You should really read
+;; org-ref.org for details.
 ;;
-;; Package-Requires: ((dash) (helm) (helm-bibtex))
+
+;;; Code:
 #+END_SRC
 
 ** requires
@@ -3442,18 +3449,24 @@ These are in the keywords field, and are comma or semicolon separated."
       keywords)))
 
 
-(defun org-ref-set-bibtex-keywords (keywords)
+(defun org-ref-set-bibtex-keywords (keywords &optional arg)
   "Add KEYWORDS to a bibtex entry.
-If KEYWORDS is a list, it is converted to a comma-separated string. The KEYWORDS are added to the beginning of the field. Otherwise KEYWORDS should be a string."
-  (interactive "sKeywords: ")
+If KEYWORDS is a list, it is converted to a comma-separated string. The KEYWORDS are added to the beginning of the field. Otherwise KEYWORDS should be a string of comma-separate keywords."
+  (interactive "sKeywords: \nP")
   (bibtex-set-field
    "keywords"
-   (concat
-    (if (listp keywords)
-       (mapconcat 'identity keywords ", ")
-      keywords)
-    (when (not (string= "" (bibtex-autokey-get-field "keywords")))
-      (concat ", "  (bibtex-autokey-get-field "keywords")))))
+   (if arg
+       ;; replace with arg
+       (if (listp keywords)
+          (mapconcat 'identity keywords ", ")
+        keywords)
+     ;; else concatentate
+     (concat
+      (if (listp keywords)
+         (mapconcat 'identity keywords ", ")
+        keywords)
+      (when (not (string= "" (bibtex-autokey-get-field "keywords")))
+       (concat ", "  (bibtex-autokey-get-field "keywords"))))))
   (save-buffer))
 
 
@@ -3813,6 +3826,8 @@ _o_: Open entry   _e_: Email entry and pdf
 * End of code
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
 (provide 'org-ref)
+
+;;; org-ref.el ends here
 #+END_SRC
 
 * Build                                                                   :noexport: