emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts
@ 2022-06-21 12:04 David Lukes
  2022-06-23 13:25 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: David Lukes @ 2022-06-21 12:04 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: David Lukes

* 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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts
  2022-06-21 12:04 [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts David Lukes
@ 2022-06-23 13:25 ` Ihor Radchenko
  2022-06-24 11:58   ` David Lukeš
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2022-06-23 13:25 UTC (permalink / raw)
  To: David Lukes; +Cc: emacs-orgmode

David Lukes <dafydd.lukes@gmail.com> writes:

> * 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.

Thanks!

Applied onto bugfix via 05626952b.

Note that the total LOC of your contributions is exceeding 20LOC
(depending how to count).

You may need to complete the copyright paperwork for future patches.
See https://orgmode.org/worg/org-contribute.html#copyright

Best,
Ihor


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts
  2022-06-23 13:25 ` Ihor Radchenko
@ 2022-06-24 11:58   ` David Lukeš
  2022-06-24 12:14     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: David Lukeš @ 2022-06-24 11:58 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Thanks! OK, will do, thanks for letting me know.

David


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts
  2022-06-24 11:58   ` David Lukeš
@ 2022-06-24 12:14     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-06-24 12:14 UTC (permalink / raw)
  To: David Lukeš; +Cc: emacs-orgmode

David Lukeš <dafydd.lukes@gmail.com> writes:

> Thanks! OK, will do, thanks for letting me know.

Note that FSF should reply within 5 working days. If they do not, feel
free to ask here for further assistance.

Best,
Ihor


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-24 12:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 12:04 [PATCH] oc-basic.el: Stringify year from CSL-JSON date-parts David Lukes
2022-06-23 13:25 ` Ihor Radchenko
2022-06-24 11:58   ` David Lukeš
2022-06-24 12:14     ` Ihor Radchenko

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).