From a68349f9503f2bb74321fe9a8a422d1e81400c2e Mon Sep 17 00:00:00 2001 From: John Kitchin Date: Tue, 3 Mar 2015 16:50:42 -0500 Subject: [PATCH] add prefix arg to replace keywords --- org-ref.org | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) 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)) -- 2.39.2