emacs-fish icon indicating copy to clipboard operation
emacs-fish copied to clipboard

indentation causes infinite loop when first line in buffer is continued

Open paulmr opened this issue 3 years ago • 0 comments

If you start a new empty buffer in fish-mode and enter a continued line, such as:

echo hello \

then when you press enter at the end of the line, emacs will freeze until you quit with C-g.

Looking at the implementation of (fish-get-normal-indent) it looks like it is getting stuck in an infinite loop in (back-to-non-continued):

    (cl-labels ((back-to-non-continued
                 () (cl-loop do (forward-line -1)
                             while (line-continued-p)))
                (line-continued-p
                 () (save-excursion
                      (forward-line -1)
                      (looking-at-p (rx (1+ nonl) "\\" eol)))))

A simple fix for this is changing the while condition to:

(and (not (bobp)) (line-continued-p))

paulmr avatar Oct 14 '21 11:10 paulmr