emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 9b398ba 2/4: oc-basic: Add function to shorten name


From: ELPA Syncer
Subject: [elpa] externals/org 9b398ba 2/4: oc-basic: Add function to shorten names
Date: Sat, 20 Nov 2021 13:57:26 -0500 (EST)

branch: externals/org
commit 9b398ba626bd418fdb0dec2f95a2a1ca0a3b2439
Author: Bruce D'Arcus <bdarcus@gmail.com>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>

    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 | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el
index 8fba708..ffca49f 100644
--- a/lisp/oc-basic.el
+++ b/lisp/oc-basic.el
@@ -309,6 +309,20 @@ 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."
@@ -395,7 +409,8 @@ Optional argument INFO is the export state, as a property 
list."
       ("plain"
        (let ((year (org-cite-basic--get-year entry info 'no-suffix)))
          (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))
              (year (org-cite-basic--get-year entry info 'no-suffix)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]