From: John Kitchin Date: Tue, 3 Mar 2015 21:50:42 +0000 (-0500) Subject: add prefix arg to replace keywords X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=commitdiff_plain;h=a68349f9503f2bb74321fe9a8a422d1e81400c2e add prefix arg to replace keywords --- 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))