From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QBQcDQ60sWJ8NQAAbAwnHQ (envelope-from ) for ; Tue, 21 Jun 2022 14:05:34 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iJ4JDA60sWKQTAAAG6o9tA (envelope-from ) for ; Tue, 21 Jun 2022 14:05:34 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B3BD1B6CE for ; Tue, 21 Jun 2022 14:05:33 +0200 (CEST) Received: from localhost ([::1]:39474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3cdQ-0005Ye-8m for larch@yhetil.org; Tue, 21 Jun 2022 08:05:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3cby-0005M9-K6 for emacs-orgmode@gnu.org; Tue, 21 Jun 2022 08:04:02 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:33506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o3cbx-0004ua-1w for emacs-orgmode@gnu.org; Tue, 21 Jun 2022 08:04:02 -0400 Received: by mail-ej1-x634.google.com with SMTP id mf9so6674125ejb.0 for ; Tue, 21 Jun 2022 05:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2M5UFz2+qn3aTc0O4aDnNkVmMRzDLOtMs1cUcZcjGlQ=; b=Yezp01TY91tSkAxp3ZO6X1BvT3r1JQJ4T9VmQOBj/3M/lSd1HVb0SJ6KE+ZuQe+XKp 7dz3FHThjXetOcEZeF9wbdJgx+L4a/4DsfzyKXa6Z7Bl8DZ/fMILcruOw1JRfeuXq2GX jN7ZWDPvVrPA6Cdm0L+6I4FmPHZqKIQqbyQVDC5jfTT2FkswX79f/YHlL0E3o0lmhBbh 1xJ/JtIE7ptu4S3olJy0bkt5HiZUS5XB+J5eIpOuRHaAoNv+lbeIENfLv2hcaRp/UMu7 UzSXGtxjKRd4oFmqeEtoDo/uiib+E4RRk/50PFlul/H6kD5vBl1Fnt1baI5HWcuVaN+M apFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2M5UFz2+qn3aTc0O4aDnNkVmMRzDLOtMs1cUcZcjGlQ=; b=qlEZInBqOOmzBysetFd/WudiT3EBIp5HLusNRxkii9mQz16hFIrwS1dVXN+Wb3q8Lx KqkC2DJjWG+Y/uaZMJ20MiujrtmbrESCx9QIyZVIECWVQvIBfzsB8yZmY3E+4Kb49V50 nkIh8K6plcKP/qamNuFcgp5DH7ZEhlnNLex5iZgX7Xv0x1FNKCVCjew/oqb10mBAkdts G+YBGy6D+nT7pTeqbYgP7kDXJVatFReIboaUhMM+lC/iPSX6boPJ8ViRKYV7bBvCFyaM 7t7IpaT89OulGmi+TTBS1+iSyluLAMfWiX65M0kBg0TQ17dnJXk2F0Ya9Reww/X87Up2 +mVQ== X-Gm-Message-State: AJIora+ZwAbC/56XpxpCeze4/nWUgHwVFYuA3lEa/fxVFsAdzv3aFAcj KVfRuHLzvf8WQqsbSKjrUkYDPWk89tc= X-Google-Smtp-Source: AGRyM1tRwUUZCbKjoZ8fpnMigPj1nDzFdBxKG2uIGftqfbnOHs6hloLCAvQQV4H/grPp3xDCYNViAQ== X-Received: by 2002:a17:907:c0f:b0:722:e690:7748 with SMTP id ga15-20020a1709070c0f00b00722e6907748mr1538363ejc.62.1655813038950; Tue, 21 Jun 2022 05:03:58 -0700 (PDT) Received: from localhost.localdomain ([2001:718:1e03:ffc2:fd72:a629:e6a5:7268]) by smtp.gmail.com with ESMTPSA id b9-20020a1709063ca900b0072232a898f1sm4636060ejh.103.2022.06.21.05.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 05:03:58 -0700 (PDT) From: David Lukes To: emacs-orgmode@gnu.org Cc: David Lukes Subject: [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts Date: Tue, 21 Jun 2022 14:04:58 +0200 Message-Id: <20220621120458.154859-1-dafydd.lukes@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=dafydd.lukes@gmail.com; helo=mail-ej1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655813134; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=2M5UFz2+qn3aTc0O4aDnNkVmMRzDLOtMs1cUcZcjGlQ=; b=Lh1iXprHW3n7B2ivbBxcG9Gu958DSmEjoh7VgWKBYmTdMr93r+EuyFRfr3ioHz6eiTdM3v 693hVxwJNbriTWrT3kU8B3mAVYRVvpp2vT3M1deC8wFY4sVeL1/eQ7KUC9GHn8q0GTTKv7 kocDhuPpQ8rJPTogn0P/hwhkG7iqGfzotDO6VXZBxz3f9M19WJgH+sk2NhF4QkR+hzhGPz awdgKsgrfvqhhxA3uswSVhBocNiExt7K6VrTWcWiai5CmdACDDpaSP4HSvTsu+gRdgK9ZG jf2rn0nqqoS1B818tCnMvmcgdMxYB0BJv05K0R37wzhsfvervp2E6QyACXZciA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655813134; a=rsa-sha256; cv=none; b=mDvAskppETx18JXkX6T2+/CvlgdlQZvHHgpIdekJZd2pdcWnaPMUB+K6z93f/sVLwUsqlh drkUbHCO3p823ykp8zGjNbz/doIsumdy1aJC8AJ92x3z43vGrVEMp7PdAImB98hMDWjZJr OqJKdCsmUu2dBNZx0TQ5tJbNNq2d09vjWgDCV+12H5kripQcTq0D47kyTCehvPOJbBW+Oh mp4bJG23tOjUAPHPyzLJuLR4o1Sti02vqLq/2QK6xP8UxoKs1iBSHIB2lbGC+lyvlDiFIY I6y9AOVz0vUmx+//LKp17k5ZLDZVRa7RcAUduTTfk3IfhWgAkE/wiaBGW2vQpw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Yezp01TY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.47 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Yezp01TY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: B3BD1B6CE X-Spam-Score: -3.47 X-Migadu-Scanner: scn1.migadu.com X-TUID: y9HURnnQNSb7 * 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