prism.el icon indicating copy to clipboard operation
prism.el copied to clipboard

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

Open YueRen opened this issue 1 year ago • 4 comments

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.)

YueRen avatar Aug 28 '24 06:08 YueRen

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.

alphapapa avatar Aug 28 '24 16:08 alphapapa

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 avatar Aug 28 '24 17:08 YueRen

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")

YueRen avatar Aug 28 '24 17:08 YueRen

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")

alphapapa avatar Aug 28 '24 17:08 alphapapa