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

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

[elpa] externals/org a6d93cf: oc-natbib: Refactor code to ease byte-comp


From: ELPA Syncer
Subject: [elpa] externals/org a6d93cf: oc-natbib: Refactor code to ease byte-compilation
Date: Sun, 8 Aug 2021 10:57:16 -0400 (EDT)

branch: externals/org
commit a6d93cfb621356893dc69fc779894c0984cedbd1
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>

    oc-natbib: Refactor code to ease byte-compilation
    
    * lisp/oc-natbib.el (org-cite-natbib--style-to-command): Refactor code
    so byte-compilation is faster, and, in some cases, do not end with
    Bytecode overflow error.
    
    Reported-by: Maxim Nikulin <manikulin@gmail.com>
    <http://lists.gnu.org/r/emacs-orgmode/2021-08/msg00100.html>
---
 lisp/oc-natbib.el | 52 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 22 deletions(-)

diff --git a/lisp/oc-natbib.el b/lisp/oc-natbib.el
index 59951c5..0b7af8d 100644
--- a/lisp/oc-natbib.el
+++ b/lisp/oc-natbib.el
@@ -78,32 +78,40 @@ If \"natbib\" package is already required in the document, 
e.g., through
   "Return command name to use according to STYLE pair."
   (pcase style
     ;; "author" style.
-    (`(,(or "author" "a") . ,(or "caps" "c"))           "\\Citeauthor")
-    (`(,(or "author" "a") . ,(or "full" "f"))           "\\citeauthor*")
-    (`(,(or "author" "a") . ,_)                         "\\citeauthor")
+    (`(,(or "author" "a") . ,variant)
+     (pcase variant
+       ((or "caps" "c")             "\\Citeauthor")
+       ((or "full" "f")             "\\citeauthor*")
+       (_                           "\\citeauthor")))
     ;; "noauthor" style.
-    (`(,(or "noauthor" "na") . ,(or "bare" "b"))        "\\citeyear")
-    (`(,(or "noauthor" "na") . ,_)                      "\\citeyearpar")
+    (`(,(or "noauthor" "na") . ,variant)
+     (pcase variant
+       ((or "bare" "b")             "\\citeyear")
+       (_                           "\\citeyearpar")))
     ;; "nocite" style.
-    (`(,(or "nocite" "n") . ,_)                         "\\nocite")
+    (`(,(or "nocite" "n") . ,_)     "\\nocite")
     ;; "text" style.
-    (`(,(or "text" "t") . ,(or "bare" "b"))             "\\citealt")
-    (`(,(or "text" "t") . ,(or "caps" "c"))             "\\Citet")
-    (`(,(or "text" "t") . ,(or "full" "f"))             "\\citet*")
-    (`(,(or "text" "t") . ,(or "bare-caps" "bc"))       "\\Citealt")
-    (`(,(or "text" "t") . ,(or "bare-full" "bf"))       "\\citealt*")
-    (`(,(or "text" "t") . ,(or "caps-full" "cf"))       "\\Citet*")
-    (`(,(or "text" "t") . ,(or "bare-caps-full" "bcf")) "\\Citealt*")
-    (`(,(or "text" "t") . ,_)                           "\\citet")
+    (`(,(or "text" "t") . ,variant)
+     (pcase variant
+       ((or "bare" "b")             "\\citealt")
+       ((or "caps" "c")             "\\Citet")
+       ((or "full" "f")             "\\citet*")
+       ((or "bare-caps" "bc")       "\\Citealt")
+       ((or "bare-full" "bf")       "\\citealt*")
+       ((or "caps-full" "cf")       "\\Citet*")
+       ((or "bare-caps-full" "bcf") "\\Citealt*")
+       (_ "\\citet")))
     ;; Default ("nil") style.
-    (`(,_ . ,(or "bare" "b"))                           "\\citealp")
-    (`(,_ . ,(or "caps" "c"))                           "\\Citep")
-    (`(,_ . ,(or "full" "f"))                           "\\citep*")
-    (`(,_ . ,(or "bare-caps" "bc"))                     "\\Citealp")
-    (`(,_ . ,(or "bare-full" "bf"))                     "\\citealp*")
-    (`(,_ . ,(or "caps-full" "cf"))                     "\\Citep*")
-    (`(,_ . ,(or "bare-caps-full" "bcf"))               "\\Citealp*")
-    (`(,_ . ,_)                                         "\\citep")
+    (`(,_ . ,variant)
+     (pcase variant
+       ((or "bare" "b")             "\\citealp")
+       ((or "caps" "c")             "\\Citep")
+       ((or "full" "f")             "\\citep*")
+       ((or "bare-caps" "bc")       "\\Citealp")
+       ((or "bare-full" "bf")       "\\citealp*")
+       ((or "caps-full" "cf")       "\\Citep*")
+       ((or "bare-caps-full" "bcf") "\\Citealp*")
+       (_                           "\\citep")))
     ;; This should not happen.
     (_ (error "Invalid style: %S" style))))
 



reply via email to

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