emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* citations: rx problems with emacs-26.3
@ 2021-07-11 10:36 Maxim Nikulin
  2021-08-07 20:27 ` Nicolas Goaziou
  0 siblings, 1 reply; 10+ messages in thread
From: Maxim Nikulin @ 2021-07-11 10:36 UTC (permalink / raw)
  To: emacs-orgmode

I think citation support is a great feature. (Sorry, I do not work with 
references now, so I can tell nothing concerning implementation for org.)

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’")

It looks like (rx (regexp ...)) require namely literal, variables are 
not supported yet. In additional (rx (literal ...)) is not supported as 
well.

> Eager macro-expansion failure: (error "Unknown rx form ‘literal’")

In a couple of places `rx-to-string' likely could be used instead of 
just `rx'. I have no idea yet what could be done with (pcase-let* ((rx 
...))) in `org-cite-adjust-note'.

> diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el
> index 4e9d2e562..2ac601f34 100644
> --- a/lisp/oc-basic.el
> +++ b/lisp/oc-basic.el
> @@ -656,7 +656,7 @@ present in the citation."
>      (org-open-file file '(4))
>      (if (not (equal "json" (file-name-extension file)))
>          (bibtex-search-entry key)
> -      (let ((regexp (rx "\"id\":" (0+ (any "[ \t]")) "\"" (literal key) "\"")))
> +      (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-csl.el b/lisp/oc-csl.el
> index a7a2a6042..f3c2fd901 100644
> --- a/lisp/oc-csl.el
> +++ b/lisp/oc-csl.el
> @@ -248,10 +248,10 @@ 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)))
> +  (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 1d704fb03..43a3bb444 100644
> --- a/lisp/oc.el
> +++ b/lisp/oc.el
> @@ -924,7 +924,7 @@ 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))
> +                     (rx-to-string `(seq string-start ,final-punct) t)
>                       "" next)))
>                 (org-element-set-element previous new-prev)
>                 (org-element-set-element next new-next)

Maybe I have missed other similar problems.

Does someone have better ideas how to restore compatibility with older 
emacs versions? 24.3 is declared in org.el. Ubuntu 20.04 (latest long 
time support release) has 26.3.



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

end of thread, other threads:[~2021-08-11 16:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-11 10:36 citations: rx problems with emacs-26.3 Maxim Nikulin
2021-08-07 20:27 ` Nicolas Goaziou
2021-08-08 13:34   ` Maxim Nikulin
2021-08-08 14:14     ` Nicolas Goaziou
2021-08-09 17:18       ` Maxim Nikulin
2021-08-11  5:37         ` Axel Kielhorn
2021-08-11  9:33         ` Nicolas Goaziou
2021-08-11 16:24           ` Maxim Nikulin
2021-08-09 17:10   ` Maxim Nikulin
2021-08-11  9:18     ` Nicolas Goaziou

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