From 53e6c067e4897c5b6c1ac8201e2dbc49baa9e6e8 Mon Sep 17 00:00:00 2001 Message-Id: <53e6c067e4897c5b6c1ac8201e2dbc49baa9e6e8.1671006575.git.yantar92@posteo.net> From: Ihor Radchenko Date: Wed, 14 Dec 2022 11:28:03 +0300 Subject: [PATCH] org-update-radio-target-regexp: Try to get a shorter regexp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/ol.el (org-update-radio-target-regexp): Use `regexp-opt' to compact the resulting regexp as much as possible. Otherwise, some users hit regexp length limits when the number of radio targets approaches thousands. Reported-by: Rudolf Adamkovič Link: https://orgmode.org/list/m2lenax5m6.fsf@me.com --- lisp/ol.el | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 3ae8f8875..51ee028e4 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -2065,13 +2065,11 @@ (defun org-update-radio-target-regexp () (setq org-target-link-regexp (and targets (concat before-re - (mapconcat - (lambda (x) - (replace-regexp-in-string - " +" "\\s-+" (regexp-quote x) t t)) - targets - "\\|") - after-re))) + (replace-regexp-in-string + " +" "\\s-+" + (regexp-opt targets) + nil t) + after-re))) (unless (equal old-regexp org-target-link-regexp) ;; Clean-up cache. (let ((regexp (cond ((not old-regexp) org-target-link-regexp) -- 2.38.1