From c1b634f5c8a31ad98f7453b77fd45ab9322f9cf2 Mon Sep 17 00:00:00 2001 From: Bruce D'Arcus Date: Fri, 29 Oct 2021 08:42:27 -0400 Subject: [PATCH] oc-basic: Add function to shorten names * lisp/oc-basic.el (org-cite-basic--shorten-names): new function to shorten author names * lisp/oc-basic.el (org-cite-basic--print-entry): shorten author name list for the "plain" output style --- lisp/oc-basic.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el index 1c5634341..2000dafeb 100644 --- a/lisp/oc-basic.el +++ b/lisp/oc-basic.el @@ -309,6 +309,19 @@ non-nil." (org-export-raw-string value) value))) +(defun org-cite-basic--shorten-names (names) + "Return a list of family names from a list of full NAMES. + +To better accomomodate corporate names, this will only shorten +personal names of the form 'family, given'." + (when (stringp names) + (mapconcat + (lambda (name) + (if (eq 1 (length name)) + (cdr (split-string name " ")) + (car (split-string name ", ")))) + (split-string names " and ") ", "))) + (defun org-cite-basic--number-to-suffix (n) "Compute suffix associated to number N. This is used for disambiguation." @@ -384,7 +397,8 @@ Optional argument INFO is the export state, as a property list." (pcase style ("plain" (org-cite-concat - author ". " title (and from (list ", " from)) ", " year ".")) + (org-cite-basic--shorten-names author) + ". " title (and from (list ", " from)) ", " year ".")) ("numeric" (let ((n (org-cite-basic--key-number (cdr (assq 'id entry)) info))) (org-cite-concat -- 2.33.1