Yuki-Inoue / elisp-format

Originally from EmacsWiki
https://www.emacswiki.org/emacs/elisp-format.el
GNU General Public License v3.0
16 stars 3 forks source link

elisp-format-region might run into an infinite loop #3

Open ghost opened 5 years ago

ghost commented 5 years ago

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

Yuki-Inoue commented 4 years ago

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

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

lihao2333 commented 1 year ago

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 commented 1 year ago

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