Subject: Re: bug#23445: 24.5; freeze in sh mode with show-paren-mode

From: Nicolas Richard <[email-masked]>
Date: Thu, 05 May 2016 07:30:59 +0200

Vincent Lefevre <[email-masked]> writes:

> On 2016-05-04 16:30:14 +0200, Nicolas Richard wrote:
>> Thanks for the report and the recipe. I can reproduce it on 24.5 but not
>> on the emacs-25 branch, so I guess this was fixed in the meantime and
>> I'm closing your report. Feel free to ask if you need more information.
>
> OK. If someone has a patch (or knows the commit the fixed the bug),
> I'd be interested.

Not sure, but it could be this one :

commit 1bab3cefc133e06aaf4a48efb1623d1b458ab212
Author: Tassilo Horn <[email-masked]>
Date:   Mon Oct 26 08:01:18 2015 +0100

    Fix infinite loop in sh-script's SMIE code
    
    * lisp/progmodes/sh-script.el (sh-smie-sh-forward-token): Fix infinite
    loop (bug#21747).

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index fbb4a90..baed27b 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1920,10 +1920,11 @@ Does not preserve point."
             ;; Pretend the here-document is a "newline representing a
             ;; semi-colon", since the here-doc otherwise covers the newline(s).
             ";")
-        (let ((semi (sh-smie--newline-semi-p)))
-          (forward-line 1)
-          (if (or semi (eobp)) ";"
-            (sh-smie-sh-forward-token))))
+        (unless (eobp)
+          (let ((semi (sh-smie--newline-semi-p)))
+            (forward-line 1)
+            (if (or semi (eobp)) ";"
+              (sh-smie-sh-forward-token)))))
     (forward-comment (point-max))
     (cond
      ((looking-at "\\\\\n") (forward-line 1) (sh-smie-sh-forward-token))