[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 31c07bd 1/5: oc: rx compatibility with Emacs < 27.1
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 31c07bd 1/5: oc: rx compatibility with Emacs < 27.1 |
Date: |
Wed, 11 Aug 2021 05:57:19 -0400 (EDT) |
branch: externals/org
commit 31c07bd3bd900984de2bc0486673a1f0d5b402ab
Author: Max Nikulin <manikulin@gmail.com>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>
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 c46e7a7..6d625e4 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 5a9c304..c82a770 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 5e0e272..c08adc4 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 3383481..53eafb3 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)