Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading a large number of user emoji can break emoji rendering Emacs wide #103

Open
matthew-piziak opened this issue Apr 7, 2022 · 1 comment

Comments

@matthew-piziak
Copy link

I use the emacs-slack package with a Slack team that uses a large number of emoji. I've actually managed to throw a low-level REG_ESIZE error from regex-emacs.c because the compiled regular expression is too big for emacs.

For example, here's the backtrace for (emojify-string "❄"):

Debugger entered--Lisp error: (invalid-regexp "Regular expression too big")
  search-forward-regexp("\\(?::\\(?:\\(?:\\+11\\|0\\(?:2_\\(?:b\\(?:\\(?:lin\\|ore\\)d..." 3 t)
  #f(compiled-function (regexp) #<bytecode 0xe297d60576a0c31>)("\\(?::\\(?:\\(?:\\+11\\|0\\(?:2_\\(?:b\\(?:\\(?:lin\\|ore\\)d...")
  mapc(#f(compiled-function (regexp) #<bytecode 0xe297d60576a0c31>) ("\\(?::\\(?:\\(?:\\+11\\|0\\(?:2_\\(?:b\\(?:\\(?:lin\\|ore\\)d..." ":[[:alnum:]+_-]+:" "\\(?:#⃣\\|\\*⃣\\|0⃣\\|1⃣\\|2⃣\\|3⃣\\|4⃣\\|5⃣\\|6⃣\\|7⃣\\|8⃣\\|9..." "\\(?:#\\(?:-?)\\)\\|%\\(?:-?)\\)\\|'\\(?::\\(?:-[()D]\\|[()D..."))
  seq-do(#f(compiled-function (regexp) #<bytecode 0xe297d60576a0c31>) ("\\(?::\\(?:\\(?:\\+11\\|0\\(?:2_\\(?:b\\(?:\\(?:lin\\|ore\\)d..." ":[[:alnum:]+_-]+:" "\\(?:#⃣\\|\\*⃣\\|0⃣\\|1⃣\\|2⃣\\|3⃣\\|4⃣\\|5⃣\\|6⃣\\|7⃣\\|8⃣\\|9..." "\\(?:#\\(?:-?)\\)\\|%\\(?:-?)\\)\\|'\\(?::\\(?:-[()D]\\|[()D..."))
  emojify-display-emojis-in-region(1 3 nil)
  emojify-string(" ❄")
  eval-expression((emojify-string " ❄") nil nil 127)
  funcall-interactively(eval-expression (emojify-string " ❄") nil nil 127)
  command-execute(eval-expression)

Is there any way I can limit the number of emoji, compile down the regex, or increase the allocated regex space?

@matthew-piziak
Copy link
Author

I see that this package already uses regexp-opt, that's good. I've created a kludge where I take only the first 2000 user emoji in emojify-set-emoji-data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant