From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KBZLIelhEWHrWAEAgWs5BA (envelope-from ) for ; Mon, 09 Aug 2021 19:12:09 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KLM0HelhEWGEfgAA1q6Kng (envelope-from ) for ; Mon, 09 Aug 2021 17:12:09 +0000 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 A6CF82BBFD for ; Mon, 9 Aug 2021 19:12:08 +0200 (CEST) Received: from localhost ([::1]:50214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD8op-0001JD-Ac for larch@yhetil.org; Mon, 09 Aug 2021 13:12:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD8o6-0001Hx-Gc for emacs-orgmode@gnu.org; Mon, 09 Aug 2021 13:11:22 -0400 Received: from ciao.gmane.io ([116.202.254.214]:53262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD8o4-0002wA-P7 for emacs-orgmode@gnu.org; Mon, 09 Aug 2021 13:11:22 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mD8o2-000A6Z-P1 for emacs-orgmode@gnu.org; Mon, 09 Aug 2021 19:11:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Maxim Nikulin Subject: Re: citations: rx problems with emacs-26.3 Date: Tue, 10 Aug 2021 00:10:25 +0700 Message-ID: References: <87sfzlc850.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------84ED1EB333823E3C8CA27B6A" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <87sfzlc850.fsf@nicolasgoaziou.fr> Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, NICE_REPLY_A=-0.001, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628529129; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=uVxyipkZIUTwT4QVKKYoP8CZzmlgySHbfFBQPydJDoQ=; b=Q7LFn12ylb3flMTePeDXlDj9MR7wPAwo3OvGCVCKEyLWEBWgZN/5Y/KbQwKtzLjT+riwk0 tclfF6nJCxzFsQc/JF0qYquDjBK1fae8d9lcajoFAwZz8Le09n6bqsDAdTrUYEtao0hGPB PRbqG7UuklFaSEPk866VaGWNT4su7VcEyg4zKkjg2IkDRa4cJWS8SKMx+BFfvaGNZTkA3Q z8m15k14Kq1t5kh4Jer6SHh3c+OX7lm59qOrehJ+fYqkTO59rqMCXH+0yT5kbEzmKp5t2d 3GDI9HtVypkdsygToF6TSFsZjYxdlBEIFBEOpxuOlFVnjZeLIYHVGon5S8PDxw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628529129; a=rsa-sha256; cv=none; b=Uy2KwYA+Gwq5fkxP8bploImp0ooPu1ge6VwHFxE09zgDtD6k+vRQU/HmYJVwDtgSqaDbWF vL/z/G4cEEDo+FNcIcFk9gTCGuuyTV9zOltgcaTzLVK51GHZgLgahqsM1q5hhifSHXxPSQ YKxLhhl/w1tnQ1zm+dqYZpsxPFxGCumgY3Jt+ubDRdMtherYRqGOrZ/b+YaC/wFBQF46IS 8UruFtHOL88DksNvpjXDdkK2fsWzasRoBHgrcOTiTcNfOqUNrq+z358DhDMFhFtj3d+K+n eoqx7/glldT+A2RunpbkjafTSSl8pdXA4IUNIbxfaGOXydiJ56BFPPwYaGxVUA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.81 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: A6CF82BBFD X-Spam-Score: -1.81 X-Migadu-Scanner: scn0.migadu.com X-TUID: lEbO5yNyoKD8 This is a multi-part message in MIME format. --------------84ED1EB333823E3C8CA27B6A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 08/08/2021 03:27, Nicolas Goaziou wrote: > > Maxim Nikulin writes: > >> It seems, rx e.g. in emacs-26.3 does not support all features used in >> oc.el and oc-csl.el. Loading an org file using git master, I get >> a warning >> >>> Eager macro-expansion failure: (error "rx form ‘regexp’ requires args satisfying ‘stringp’") > > Thanks. Could you send the patch again with a proper commit message, > using git format-patch? With the attached patches I do not see warnings any more while org is loading. On the other hand I am not an org-cite user, so I am not sure that nothing is broken by these patches. --------------84ED1EB333823E3C8CA27B6A Content-Type: text/x-patch; charset=UTF-8; name="0001-oc-rx-compatibility-with-Emacs-27.1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-oc-rx-compatibility-with-Emacs-27.1.patch" >From 151191d0283cb55e719c9c01459de02dfb584e02 Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Mon, 9 Aug 2021 23:59:41 +0700 Subject: [PATCH 1/2] oc: rx compatibility with Emacs < 27.1 * lisp/oc.el (org-cite-adjust-note): * lisp/oc-basic.el (org-cite-basic-goto): * lisp/oc-biblatex.el (org-cite-biblatex-prepare-preamble): * lisp/oc-csl.el (org-cite-csl--label-regexp): Avoid `rx' forms introduced in Emacs-27.1 to keep compatibility with older versions. Use `rx-to-string' instead of `rx' due to lack of support of `regexp' and `literal' forms with a variable as an argument. --- lisp/oc-basic.el | 4 +++- lisp/oc-biblatex.el | 2 +- lisp/oc-csl.el | 11 +++++++---- lisp/oc.el | 21 ++++++++++++++------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el index c46e7a715..6d625e4a5 100644 --- a/lisp/oc-basic.el +++ b/lisp/oc-basic.el @@ -667,7 +667,9 @@ present in the citation." (org-open-file file '(4)) (pcase (file-name-extension file) ("json" - (let ((regexp (rx "\"id\":" (0+ (any "[ \t]")) "\"" (literal key) "\""))) + ;; `rx' can not be used with Emacs <27.1 since `literal' form + ;; is not supported. + (let ((regexp (rx-to-string `(seq "\"id\":" (0+ (any "[ \t]")) "\"" ,key "\"") t))) (goto-char (point-min)) (re-search-forward regexp) (search-backward "{"))) diff --git a/lisp/oc-biblatex.el b/lisp/oc-biblatex.el index 5a9c304a3..c82a77046 100644 --- a/lisp/oc-biblatex.el +++ b/lisp/oc-biblatex.el @@ -260,7 +260,7 @@ to the document, and set styles." ;; Then set options. (goto-char (match-beginning 0)) (let ((re (rx "\\usepackage" - (opt (group "[" (*? anychar) "]")) + (opt (group "[" (*? anything) "]")) "{biblatex}"))) (cond ;; No "biblatex" package loaded. Insert "usepackage" command diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el index 5e0e27211..c08adc430 100644 --- a/lisp/oc-csl.el +++ b/lisp/oc-csl.el @@ -253,10 +253,13 @@ If nil then the Chicago author-date style is used as a fallback.") "Alist mapping locator names to locators.") (defconst org-cite-csl--label-regexp - (rx word-start - (regexp (regexp-opt (mapcar #'car org-cite-csl--label-alist) t)) - (0+ digit) - (or word-start line-end (any ?\s ?\t))) + ;; Prior to Emacs-27.1 argument of `regexp' form must be a string literal. + ;; It is the reason why `rx' is avoided here. + (rx-to-string `(seq word-start + (regexp ,(regexp-opt (mapcar #'car org-cite-csl--label-alist) t)) + (0+ digit) + (or word-start line-end (any ?\s ?\t))) + t) "Regexp matching a label in a citation reference suffix. Label is in match group 1.") diff --git a/lisp/oc.el b/lisp/oc.el index 338348116..53eafb3bd 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -878,14 +878,19 @@ the same object, call `org-cite-adjust-punctuation' first." (when org-cite-adjust-note-numbers (pcase-let* ((rule (or rule (org-cite--get-note-rule info))) (punct-re (regexp-opt (or punct org-cite-punctuation-marks))) + ;; with Emacs <27.1. Argument of `regexp' form (PUNCT-RE this case) + ;; must be a string literal. (previous-punct-re - (rx (opt (group (0+ (any blank ?\n)) (regexp punct-re))) - (opt (0+ (any blank ?\n)) (group ?\")) - (opt (group (1+ (any blank ?\n)))) - string-end)) + (rx-to-string `(seq (opt (group (regexp ,(rx (0+ (any blank ?\n)))) + (regexp ,punct-re))) + (regexp ,(rx (opt (0+ (any blank ?\n)) (group ?\")) + (opt (group (1+ (any blank ?\n)))) + string-end))) + t)) (next-punct-re - (rx string-start - (group (0+ (any blank ?\n)) (regexp punct-re)))) + (rx-to-string `(seq string-start + (group (0+ (any blank ?\n)) (regexp ,punct-re))) + t)) (next (org-export-get-next-element citation info)) (final-punct (and (stringp next) @@ -928,7 +933,9 @@ the same object, call `org-cite-adjust-punctuation' first." (concat final-punct "\"") previous nil nil 2)) (new-next (replace-regexp-in-string - (rx string-start (literal final-punct)) + ;; Before Emacs-27.1 `literal' `rx' form with a variable + ;; as an argument is not available. + (rx-to-string `(seq string-start ,final-punct) t) "" next))) (org-element-set-element previous new-prev) (org-element-set-element next new-next) -- 2.25.1 --------------84ED1EB333823E3C8CA27B6A Content-Type: text/x-patch; charset=UTF-8; name="0002-oc-Add-missing-require.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-oc-Add-missing-require.patch" >From 19261fcf089deba09250117fc1beb6a8aef69450 Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Tue, 10 Aug 2021 00:03:25 +0700 Subject: [PATCH 2/2] oc: Add missing `require' * lisp/oc.el: * lisp/oc-basic.el: Add some `require' to avoid compile warnings. --- lisp/oc-basic.el | 3 +++ lisp/oc.el | 1 + 2 files changed, 4 insertions(+) diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el index 6d625e4a5..66f8c069f 100644 --- a/lisp/oc-basic.el +++ b/lisp/oc-basic.el @@ -65,7 +65,10 @@ ;;; Code: (require 'bibtex) +(require 'json) (require 'oc) +(require 'org) +(require 'seq) (declare-function org-open-at-point "org" (&optional arg)) diff --git a/lisp/oc.el b/lisp/oc.el index 53eafb3bd..f8cc7829c 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -57,6 +57,7 @@ (require 'org-compat) (require 'org-macs) +(require 'seq) (declare-function org-at-heading-p "org" (&optional _)) (declare-function org-collect-keywords "org" (keywords &optional unique directory)) -- 2.25.1 --------------84ED1EB333823E3C8CA27B6A--