X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=blobdiff_plain;f=org-ref.org;h=100f8da9f18d575bb5f1e9f375a02dc2adc482db;hp=6ecfc58b2ca1a6a64d23ddf6bbe348d02af17ade;hb=8e897eaae0ed4151ed7de671b7fd19837a4de21c;hpb=71e2eb117e7e73d0cd065646407a08b578b2b72d diff --git a/org-ref.org b/org-ref.org index 6ecfc58..100f8da 100644 --- a/org-ref.org +++ b/org-ref.org @@ -3449,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))