alphapapa / prism.el

Disperse Lisp forms (and other languages) into a spectrum of colors by depth
GNU General Public License v3.0
285 stars 4 forks source link

`prism-whitespace-mode` freezes emacs when no space before line comment delimiters #33

Open YueRen opened 2 weeks ago

YueRen commented 2 weeks ago

Enabling prism-whitespace-mode in a buffer without spaces before line comment delimiter causes extreme slow downs. Here is an elisp example:

(defun my-delete-sentence (&optional arg);; <--- no space before ;; !!
  (interactive "p")
  (delete-region (point) (progn (forward-sentence arg) (point))))
(global-set-key (kbd "M-k") 'my-delete-sentence)

(defun my-delete-word (arg);; <--- no space before ;; !!
  (interactive "p")
  (delete-region (point) (progn (forward-word arg) (point))))
(global-set-key (kbd "M-d") 'my-delete-word)

(I'm not advocating for this style, but if you have enough students you will see all sorts of code.)

alphapapa commented 2 weeks ago

Why are you using prism-whitespace-mode in a Lisp buffer? That mode is for whitespace-sensitive languages like Python. prism-mode is for Lisp.

YueRen commented 2 weeks ago

Why are you using prism-whitespace-mode in a Lisp buffer? That mode is for whitespace-sensitive languages like Python. prism-mode is for Lisp.

Good question, I am not. My original example is in julia, but I just thought that finding an elisp example would make it easier to debug.

YueRen commented 2 weeks ago

Here is the same example in python:

def my_delete_sentence():# <--- no space before # !!
    for i in 1:3:
        print("hello world")
    print("goodbye world")

def my_delete_word()# <--- no space before # !!
    for i in 1:3:
        print("hello world")
    print("goodbye world")
alphapapa commented 2 weeks ago

Thanks. With that content in python-mode on Emacs 29.4, the messages buffer shows:

Error during redisplay: (jit-lock-function 148) signaled (error "prism: Infinite loop detected in ‘prism-match-whitespace’ (buffer:#<buffer prism-test.py> point:150).  Please report this bug")