X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=blobdiff_plain;f=org-ref.org;h=0cd567a69a30a6119015fbfd1b43acbecc031239;hp=9665744c85bcf662ef33af3e9fa5de3cd738bb73;hb=6aec29fe7b979fff8a62a992427d24a093afaaaa;hpb=4f162da7c56aee0d5593d51ded6dada7b316e492 diff --git a/org-ref.org b/org-ref.org index 9665744..0cd567a 100644 --- a/org-ref.org +++ b/org-ref.org @@ -3442,18 +3442,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))