elisp-format icon indicating copy to clipboard operation
elisp-format copied to clipboard

elisp-format-region might run into an infinite loop

Open ghost opened this issue 6 years ago • 3 comments

Hi there,

thank you very much for this package.

I encountered a small bug a few days ago. Formatting the code in the attached file will send elisp-format into an infinite loop (more precisely, the while loop in elisp-format-region never terminates). The occurence of the bug seems to depend on the value of elisp-format-column, which is 100 for me.

test.txt

ghost avatar Dec 03 '18 22:12 ghost

Sorry late reply. Recently, I don't write elisp codes...

If someone can make PR, then I can verify, and accept.

Yuki-Inoue avatar Mar 19 '20 01:03 Yuki-Inoue

I find the same bug.
When I run elisp-format-buffer in following buffer,

;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.

(use-package treemacs 
	:config (progn 
						(setq treemacs-goto-tag-strategy 'refetch-index
									treemacs-header-scroll-indicators '(nil . "asd"))))
(setq elisp-format-debug-mode t)
(setq elisp-format-column 100)

the formating seems not terminates.

This is the message output:


Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.

lihao2333 avatar Dec 31 '22 10:12 lihao2333

I find the same bug. When I run elisp-format-buffer in following buffer,

;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.

(use-package treemacs 
	:config (progn 
						(setq treemacs-goto-tag-strategy 'refetch-index
									treemacs-header-scroll-indicators '(nil . "asd"))))
(setq elisp-format-debug-mode t)
(setq elisp-format-column 100)

the formating seems not terminates.

This is the message output:


Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.
8
Format string at 8 completed.

It seems that some format process could not reduce the current-column so that the while loop never terminates. image

lihao2333 avatar Dec 31 '22 10:12 lihao2333