Skip to content

Commit

Permalink
oc-basic.el: Stringify year from CSL-JSON date-parts
Browse files Browse the repository at this point in the history
* lisp/oc-basic.el (org-cite-basic--parse-json): Make sure year
extracted from date-parts is returned as string.  Raise error if
original type other than number or string.

The stringifiation is motivated by errors like the following on Emacs 28
with nativecomp:

Error during redisplay: (jit-lock-function 544) signaled
(wrong-type-argument "Argument is not a string or a secondary string:
2007")

Additionally, the type check will warn users about problems in their
CSL-JSON bibliographies.

Fixes https://list.orgmode.org/875ykv4k2q.fsf@localhost/T/#t

TINYCHANGE
  • Loading branch information
dlukes authored and yantar92 committed Jun 23, 2022
1 parent 02a22d6 commit 0dc27a8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lisp/oc-basic.el
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ Return a hash table with citation references as keys and fields alist as values.
(cons 'year
(cond
((consp date)
(caar date))
(let ((year (caar date)))
(cond
((numberp year) (number-to-string year))
((stringp year) year)
(t
(error
"First element of CSL-JSON date-parts should be a number or string, got %s: %S"
(type-of year) year)))))
((stringp date)
(replace-regexp-in-string
(rx
Expand Down

0 comments on commit 0dc27a8

Please sign in to comment.