wwwjfy / emacs-fish

fish-mode for emacs
99 stars 15 forks source link

indentation causes infinite loop when first line in buffer is continued #46

Closed paulmr closed 1 year ago

paulmr commented 3 years ago

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

Hello, just checking in. I have had the same error and funnily enough found the same solution. I have updated it in my local repo, but why is this fix not getting accepted?

wwwjfy commented 1 year ago

Sorry but I'm not actively using it and monitoring this repo any more. Applied the suggested fix. Thanks both