emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "András Simonyi" <andras.simonyi@gmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: Bastien <bzg@gnu.org>, emacs-orgmode list <emacs-orgmode@gnu.org>,
	Nicolas Goaziou <mail@nicolasgoaziou.fr>
Subject: Re: [PATCH] oc-csl: Add support for the text and year citation styles
Date: Tue, 28 Sep 2021 18:39:37 +0200	[thread overview]
Message-ID: <CAOWRwxDTbW_YNa--GON4tSWCw5hh-zEL6Bg_4eDOigNcMMtpEg@mail.gmail.com> (raw)
In-Reply-To: <CAOWRwxA-PSZ93NC9RBVteicpa8EqBYG_MJaMQGhmk8S8-4vaGQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

Dear All,

I've attached a patch with the pcase pattern refactored following
Nicolas's example -- hopefully this solves the problem.

best wishes,
András

On Tue, 28 Sept 2021 at 17:16, András Simonyi <andras.simonyi@gmail.com> wrote:
>
> Thanks, I'll try to put together a patch fixing the problem and send it shortly.
> best wishes,
> András
>
> On Tue, 28 Sept 2021 at 17:03, Max Nikulin <manikulin@gmail.com> wrote:
> >
> > On 28/09/2021 21:40, Bastien wrote:
> > > András Simonyi writes:
> > >
> > >> the attached patch adds support for the text (textual) and year
> > >> (year-only) citation styles in the CSL org-cite processor.
> > >
> > > Applied, thank you very much!
> >
> > This patch has a problem similar to ones earlier fixed by Nicolas:
> > https://orgmode.org/list/seomi1$785$1@ciao.gmane.io "Re: citations: rx
> > problems with emacs-26.3" Sun, 8 Aug 2021 20:34:55 +0700
> >
> > Compiling single /home/ubuntu/org-mode/lisp/oc-csl.el...
> >
> > In toplevel form:
> > oc-csl.el:330:10:Error: Bytecode overflow
> > Makefile:59: recipe for target 'oc-csl.elc' failed
> > make[2]: [oc-csl.elc] Error 1 (ignored)
> >
> > It is for emacs-26.3 (Ubuntu-18.04 LTS bionic).

[-- Attachment #2: 0002-oc-csl-Refactor-code-to-help-byte-compilation.patch --]
[-- Type: text/x-patch, Size: 4518 bytes --]

From 2ec9af9693c236b6afae7e3d286eb8c6c87283b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= <andras.simonyi@gmail.com>
Date: Tue, 28 Sep 2021 18:13:11 +0200
Subject: [PATCH 2/2] oc-csl: Refactor code to help byte-compilation

* lisp/oc-csl.el (org-cite-csl--create-structure-params): Refactor pcase pattern
to avoid slow or in some cases non-terminating byte compilation.
---
 lisp/oc-csl.el | 82 +++++++++++++++++++++++---------------------------
 1 file changed, 38 insertions(+), 44 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 51d3d3d8a..3c77e0354 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -284,50 +284,44 @@ INFO is the export state, as a property list."
   "Return citeproc structure creation params for CITATION object.
 STYLE is the citation style, as a string or nil. INFO is the export state, as
 a property list."
-  (let* ((style (org-cite-citation-style citation info)))
-   (pcase style
-     ;; "author" style.
-     (`(,(or "author" "a") . ,(or "caps" "c"))
-      '(:mode author-only :capitalize-first t :suppress-affixes t))
-     (`(,(or "author" "a") . ,(or "full" "f"))
-      '(:mode author-only :ignore-et-al t :suppress-affixes t))
-     (`(,(or "author" "a") . ,(or "caps-full" "cf"))
-      '(:mode author-only :capitalize-first t :ignore-et-al t :suppress-affixes t))
-     (`(,(or "author" "a") . ,_)
-      '(:mode author-only :suppress-affixes t))
-     ;; "noauthor" style.
-     (`(,(or "noauthor" "na") . ,(or "bare" "b"))
-      '(:mode suppress-author :suppress-affixes t))
-     (`(,(or "noauthor" "na") . ,(or "caps" "c"))
-      '(:mode suppress-author :capitalize-first t))
-     (`(,(or "noauthor" "na") . ,(or "bare-caps" "bc"))
-      '(:mode suppress-author :suppress-affixes t :capitalize-first t))
-     (`(,(or "noauthor" "na") . ,_)
-      '(:mode suppress-author))
-     ;; "year" style.
-     (`(,(or "year" "y") . ,(or "bare" "b"))
-      '(:mode year-only :suppress-affixes t))
-     (`(,(or "year" "y") . ,_)
-      '(:mode year-only))
-     ;; "text" style.
-     (`(,(or "text" "t") . ,(or "caps" "c"))
-      '(:mode textual :capitalize-first t))
-     (`(,(or "text" "t") . ,(or "full" "f"))
-      '(:mode textual :ignore-et-al t))
-     (`(,(or "text" "t") . ,(or "caps-full" "cf"))
-      '(:mode textual :ignore-et-al t :capitalize-first t))
-     (`(,(or "text" "t") . ,_)
-      '(:mode textual))
-     ;; Default "nil" style.
-     (`(,_ . ,(or "bare" "b"))
-      '(:suppress-affixes t))
-     (`(,_ . ,(or "caps" "c"))
-      '(:capitalize-first t))
-     (`(,_ . ,(or "bare-caps" "bc"))
-      '(:suppress-affixes t :capitalize-first t))
-     (`(,_ . ,_) nil)
-     ;; This should not happen.
-     (_ (error "Invalid style: %S" style)))))
+  (let ((style (org-cite-citation-style citation info)))
+    (pcase style
+      ;; "author" style.
+      (`(,(or "author" "a") . ,variant)
+       (pcase variant
+	 ((or "caps" "c") '(:mode author-only :capitalize-first t))
+	 ((or "full" "f") '(:mode author-only :ignore-et-al t))
+	 ((or "caps-full" "cf") '(:mode author-only :capitalize-first t :ignore-et-al t))
+	 (_ '(:mode author-only))))
+      ;; "noauthor" style.
+      (`(,(or "noauthor" "na") . ,variant)
+       (pcase variant
+	 ((or "bare" "b") '(:mode suppress-author :suppress-affixes t))
+	 ((or "caps" "c") '(:mode suppress-author :capitalize-first t))
+	 ((or "bare-caps" "bc")
+          '(:mode suppress-author :suppress-affixes t :capitalize-first t))
+	 (_ '(:mode suppress-author))))
+      ;; "year" style.
+      (`(,(or "year" "y") . ,variant)
+       (pcase variant
+	 ((or "bare" "b") '(:mode year-only :suppress-affixes t))
+	 (_ '(:mode year-only))))
+      ;; "text" style.
+      (`(,(or "text" "t") . ,variant)
+       (pcase variant
+         ((or "caps" "c") '(:mode textual :capitalize-first t))
+         ((or "full" "f") '(:mode textual :ignore-et-al t))
+         ((or "caps-full" "cf") '(:mode textual :ignore-et-al t :capitalize-first t))
+         (_ '(:mode textual))))
+      ;; Default "nil" style.
+      (`(,_ . ,variant)
+       (pcase variant
+         ((or "caps" "c") '(:capitalize-first t))
+         ((or "bare" "b") '(:suppress-affixes t))
+         ((or "bare-caps" "bc") '(:suppress-affixes t :capitalize-first t))
+         (_  nil)))
+      ;; This should not happen.
+      (_ (error "Invalid style: %S" style)))))
 
 (defun org-cite-csl--no-citelinks-p (info)
   "Non-nil when export BACKEND should not create cite-reference links."
-- 
2.25.1


  reply	other threads:[~2021-09-28 16:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 13:12 [PATCH] oc-csl: Add support for the text and year citation styles András Simonyi
2021-09-28 14:40 ` Bastien
2021-09-28 14:58   ` Nicolas Goaziou
2021-09-28 15:03   ` Max Nikulin
2021-09-28 15:16     ` András Simonyi
2021-09-28 16:39       ` András Simonyi [this message]
2021-09-28 16:54         ` Max Nikulin
2021-09-28 16:56         ` Bastien Guerry

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=CAOWRwxDTbW_YNa--GON4tSWCw5hh-zEL6Bg_4eDOigNcMMtpEg@mail.gmail.com \
    --to=andras.simonyi@gmail.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --cc=manikulin@gmail.com \
    /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).