emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: "Rudolf Adamkovič" <salutis@me.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Radio links work only in small numbers
Date: Wed, 14 Dec 2022 08:30:08 +0000	[thread overview]
Message-ID: <87r0x2qtf3.fsf@localhost> (raw)
In-Reply-To: <m2lenax5m6.fsf@me.com>

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

Rudolf Adamkovič <salutis@me.com> writes:

> Greetings smart people!
>
> All [[link]]s in my notes perfectly match LEVEL-1 headings, so I figured
> that I may as well ask Org to make links for me.  So, I replaced all the
> ~4000 headings in my notes with radio <<<targets>>>.  However, Org now
> errors out with "Regular expression too big".
>
> Does anyone know how to overcome this limitation?  Or, perhaps someone
> has a patch in works that fixes it?  If so, please let me know!

This is C-level error emitted by Emacs' regexp engine.

Can you try the attached patch?

[-- Attachment #2: 0001-org-update-radio-target-regexp-Try-to-get-a-shorter-.patch --]
[-- Type: text/x-patch, Size: 1631 bytes --]

From 53e6c067e4897c5b6c1ac8201e2dbc49baa9e6e8 Mon Sep 17 00:00:00 2001
Message-Id: <53e6c067e4897c5b6c1ac8201e2dbc49baa9e6e8.1671006575.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
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č <salutis@me.com>
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


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

  reply	other threads:[~2022-12-14  8:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 23:10 Radio links work only in small numbers Rudolf Adamkovič
2022-12-14  8:30 ` Ihor Radchenko [this message]
2022-12-14 15:29   ` Rudolf Adamkovič
2022-12-14 15:47 ` Max Nikulin
2022-12-14 16:02   ` Ihor Radchenko
2022-12-20  3:21     ` Timothy
2022-12-20  1:00   ` Rudolf Adamkovič
2022-12-28  9:46 ` Daniel Clemente
2024-02-19  9:26 ` Ihor Radchenko
2024-02-28 16:33   ` nobiot
2024-02-28 17:14     ` Ihor Radchenko
2024-02-28 22:18       ` Noboru Ota
2024-02-29 11:11         ` Ihor Radchenko
2024-02-29 16:47           ` Noboru Ota
2024-02-29 17:21             ` Ihor Radchenko
2024-02-29 17:44               ` Noboru Ota
2024-04-04 20:20           ` Rudolf Adamkovič

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=87r0x2qtf3.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=salutis@me.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).