[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org f8cd8a6 2/3: oc-biblatex: Generate cite styles dyna
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org f8cd8a6 2/3: oc-biblatex: Generate cite styles dynamically |
Date: |
Sun, 12 Dec 2021 10:57:25 -0500 (EST) |
branch: externals/org
commit f8cd8a6645828f8af7918b0a6ccce6e5ee5f098c
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>
oc-biblatex: Generate cite styles dynamically
* lisp/oc-biblatex.el (org-cite-biblatex-list-styles): New function.
Use it when registering `biblatex' citation processor.
---
lisp/oc-biblatex.el | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/lisp/oc-biblatex.el b/lisp/oc-biblatex.el
index 32fa69f..8fdb6eb 100644
--- a/lisp/oc-biblatex.el
+++ b/lisp/oc-biblatex.el
@@ -62,6 +62,7 @@
;; #+print_bibliography: :keyword abc,xyz :title "Primary Sources"
;;; Code:
+(require 'map)
(require 'org-macs)
(require 'oc)
@@ -291,6 +292,24 @@ non-nil, do not add optional arguments to the command."
variant)))
(_ (error "This should not happen"))))
+(defun org-cite-biblatex-list-styles ()
+ "List styles and variants supported in `biblatex' citation processor.
+The output format is appropriate as a value for `:cite-styles' keyword
+in `org-cite-register-processor', which see."
+ (let ((shortcuts (make-hash-table :test #'equal))
+ (variants (make-hash-table :test #'equal)))
+ (pcase-dolist (`(,name . ,full-name) org-cite-biblatex-style-shortcuts)
+ (push name (gethash full-name shortcuts)))
+ (pcase-dolist (`(,name ,variant . ,_) org-cite-biblatex-styles)
+ (unless (null variant) (push variant (gethash name variants))))
+ (map-apply (lambda (style-name variants)
+ (cons (cons (or style-name "nil")
+ (gethash style-name shortcuts))
+ (mapcar (lambda (v)
+ (cons v (gethash v shortcuts)))
+ variants)))
+ variants)))
+
;;; Export capability
(defun org-cite-biblatex-export-bibliography (_keys _files _style props &rest
_)
@@ -412,13 +431,7 @@ to the document, and set styles."
:export-bibliography #'org-cite-biblatex-export-bibliography
:export-citation #'org-cite-biblatex-export-citation
:export-finalizer #'org-cite-biblatex-prepare-preamble
- :cite-styles
- '((("author" "a") ("caps" "c") ("full" "f") ("caps-full" "cf"))
- (("locators" "l") ("bare" "b") ("caps" "c") ("bare-caps" "bc"))
- (("noauthor" "na") ("bare" "b"))
- (("nocite" "n"))
- (("text" "t") ("caps" "c"))
- (("nil") ("bare" "b") ("caps" "c") ("bare-caps" "bc"))))
+ :cite-styles #'org-cite-biblatex-list-styles)
(provide 'oc-biblatex)
;;; oc-biblatex.el ends here