alphapapa / alphapapa/prism.el

Error: "Invalid search bound (wrong side of point)"

未關閉
#27 9 則留言 2 個 reaction 已指派 1 人 已被 @alphapapa 認領 在 GitHub 檢視
bug
主要語言
Emacs Lisp
星號
334
分支
5
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。