@@ -191,6 +191,7 @@ references as a string."
191
191
(defcustom citar-display-transform-functions
192
192
; ; TODO change this name, as it might be confusing?
193
193
`((sn . (citar--shorten-names))
194
+ (fn . (citar--full-names))
194
195
(etal . (citar--shorten-names 3 " &" )))
195
196
" Configure transformation of field display values from raw values.
196
197
@@ -1416,20 +1417,14 @@ See the documentation for `citar-add-file-sources' for more details."
1416
1417
1417
1418
; ;; Format and display field values
1418
1419
1419
- (defun citar--shorten -name-position (namelist name )
1420
+ (defun citar--render -name-position (namelist name )
1420
1421
" Return NAME position in a NAMELIST."
1421
1422
(+ (seq-position namelist name) 1 ))
1422
1423
1423
- (defun citar--shorten-name ( name )
1424
- " Return family NAME in `family, given' string .
1424
+ (defun citar--render-names ( namestr name-func &optional truncate andstr )
1425
+ " Return a list of names from a list of full NAMESTR .
1425
1426
1426
- Otherwise, return as is."
1427
- (car (split-string name " , " )))
1428
-
1429
- (defun citar--shorten-names (namestr &optional truncate andstr )
1430
- " Return a list of family names from a list of full NAMESTR.
1431
- To better accommodate corporate names, this will only shorten
1432
- personal names of the form \" family, given\" .
1427
+ Each name will be processed by NAME-FUNC.
1433
1428
1434
1429
With an integer TRUNCATE, will shorten the list, and ANDSTR will
1435
1430
replace last comma."
@@ -1439,8 +1434,8 @@ replace last comma."
1439
1434
(tnamelength (length tnamelist)))
1440
1435
(mapconcat
1441
1436
(lambda (n )
1442
- (let* ((shortname (citar--shorten- name n))
1443
- (pos (citar--shorten -name-position tnamelist n))
1437
+ (let* ((name ( funcall name-func n))
1438
+ (pos (citar--render -name-position tnamelist n))
1444
1439
(suffix
1445
1440
(cond
1446
1441
; ; if last name in the list and we're truncating add et al.; otherwise, no suffix
@@ -1451,9 +1446,40 @@ replace last comma."
1451
1446
(concat " " andstr " " ))
1452
1447
; ; otherwise, use a comma
1453
1448
(t " , " ))))
1454
- (concat shortname suffix)))
1449
+ (concat name suffix)))
1455
1450
tnamelist " " )))
1456
1451
1452
+ (defun citar--shorten-name (name )
1453
+ " Return family NAME in `family, given' string.
1454
+
1455
+ Otherwise, return as is."
1456
+ (car (split-string name " , " )))
1457
+
1458
+ (defun citar--shorten-names (namestr &optional truncate andstr )
1459
+ " Return a list of family names from a list of full NAMESTR.
1460
+ To better accommodate corporate names, this will only shorten
1461
+ personal names of the form \" family, given\" .
1462
+
1463
+ With an integer TRUNCATE, will shorten the list, and ANDSTR will
1464
+ replace last comma."
1465
+ (citar--render-names namestr #'citar--shorten-name truncate andstr))
1466
+
1467
+ (defun citar--full-name (name )
1468
+ " Return `given family' in `family, given' string NAME.
1469
+
1470
+ Otherwise, return as is."
1471
+ (let ((split-names (split-string name " , " )))
1472
+ (if (> (length split-names) 1 )
1473
+ (concat (cadr split-names) " " (car split-names))
1474
+ name)))
1475
+
1476
+ (defun citar--full-names (namestr &optional truncate andstr )
1477
+ " Return a list of full names from a list of full NAMESTR.
1478
+
1479
+ With an integer TRUNCATE, will shorten the list, and ANDSTR will
1480
+ replace last comma."
1481
+ (citar--render-names namestr #'citar--full-name truncate andstr))
1482
+
1457
1483
(defun citar--fields-for-format (template )
1458
1484
" Return list of fields for TEMPLATE."
1459
1485
(mapcan (lambda (fieldspec ) (when (consp fieldspec) (cdr fieldspec)))
0 commit comments