alphapapa / alphapapa/prism.el
Error: "Invalid search bound (wrong side of point)"
- Langage dominant
- Emacs Lisp
- Étoiles
- 334
- Forks
- 5
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hey, I've been having a great time with the package. Thanks for your great work!
I've been noticing some `jit-lock` errors and I narrowed it down to prism.
My setup is GNU Emacs 29.0.60, with Doom emacs, and prism v0.3.2
It's only with one emacs lisp file, and it's some weird combination of length of the file (like 600 lines) and a comment line. Bisecting the file itself hasn't gotten much info, but it *seems* like it only occurs when there's at least a full window of content and something to do with this starting section of the file:
```emacs-lisp
;;; -*- lexical-binding: t; -*-
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "Ketan Kanishka"
user-mail-address "ketan.kanishka@nyu.edu")
;;; Utility functions
;; Due to name visibility issues, this section needs to be at the top.
;; 12-hour time -> 24-hour time
(defun pm (hour) (mod (+ hour 12) 24))
(defun am (hour) hour)
(defun my/load-doom-theme (&optional theme)
"Load the currently set `doom-theme'. If THEME is provided, set it to `doom-theme' first."
(setq doom-theme (or theme doom-theme))
(load-theme doom-theme t nil))
(defun silently (fn)
"Run FN without showing any messages in echo area."
(let ((inhibit-message t))
(funcall fn)))
```
and especially this line - "Some functionality uses this to identify you, e.g. GPG configuration, email" seems to be causing issues.
Since this error was thrown by `jit-lock-mode`, I wasn't able to debug it very effectively.
However, I've narrowed it down to this [section](https://github.com/alphapapa/prism.el/blob/169b49afa91e69d35b8756df49ed3ca06f418d35/prism.el#L497C32-L502):
```emacs-lisp
(when (re-search-forward (rx (or (syntax string-quote)
(syntax comment-start)))
(or (ignore-errors
(scan-lists (point) 1 1))
limit)
t)
```
Specifically, it seems like `re-search-forward`, even when its `noerror` argument is true, raises an error when the current point is less than the `bound` argument.
After modifying the section to:
```emacs-lisp
when (condition-case err
(let ((regex (rx (or (syntax string-quote)
(syntax comment-start))))
(my-limit (or (ignore-errors
(scan-lists (point) 1 1))
limit)))
(message
"calling (re-search-forward :regex %S :limit %S 'noerror) [current-point: %S, limit: %S]"
regex my-limit (point) limit)
(re-search-forward regex my-limit t))
(error
(message "caught error! %S" err)
nil))
```
I get these logs:
```
...
calling (re-search-forward :regex "\\s\"\\|\\s<" :limit 1551 ’noerror) [current-point: 1492, limit: 1552]
calling (re-search-forward :regex "\\s\"\\|\\s<" :limit 1551 ’noerror) [current-point: 1550, limit: 1552]
calling (re-search-forward :regex "\\s\"\\|\\s<" :limit 1552 ’noerror) [current-point: 1553, limit: 1552]
caught error! (error "Invalid search bound (wrong side of point)")
```
So I think wrapping this (and maybe also the other) `re-search-forward` calls with `ignore-errors` will be at least a good band-aid fix. I'm not sure about the *true* cause of this though.
Best
Ketan
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.