From: David Lukes <dafydd.lukes@gmail.com>
To: emacs-orgmode@gnu.org
Cc: David Lukes <dafydd.lukes@gmail.com>
Subject: [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts
Date: Tue, 21 Jun 2022 14:04:58 +0200 [thread overview]
Message-ID: <20220621120458.154859-1-dafydd.lukes@gmail.com> (raw)
* 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.
TINYCHANGE
---
lisp/oc-basic.el | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el
index a937f75..f10b95b 100644
--- a/lisp/oc-basic.el
+++ b/lisp/oc-basic.el
@@ -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
--
2.36.1
next reply other threads:[~2022-06-21 12:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 12:04 David Lukes [this message]
2022-06-23 13:25 ` [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts Ihor Radchenko
2022-06-24 11:58 ` David Lukeš
2022-06-24 12:14 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220621120458.154859-1-dafydd.lukes@gmail.com \
--to=dafydd.lukes@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).