Subject: bug#7736: closed (Re: bug#7736: 24.0.50; perl-mode infinite loop)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 24 Jan 2011 20:08:02 +0000

Your bug report

#7736: 24.0.50; perl-mode infinite loop

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
7736: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7736
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#7736: 24.0.50; perl-mode infinite loop
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Cc: [email-masked], [email-masked]
Date: Mon, 24 Jan 2011 15:13:07 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

> Man, you gotta see this. On this attached file,
> save in /tmp, and run emacs -Q -nw /tmp/r.pl

> Now move the cursor down and attempt to change shttp to s[http .
> As you insert the [ an infinite loop begins.

Indeed, thanks for that test case.  I've installed the patch below
which should fix the problem.

        Stefan

=== modified file 'lisp/progmodes/perl-mode.el'
--- lisp/progmodes/perl-mode.el	2011-01-14 17:18:41 +0000
+++ lisp/progmodes/perl-mode.el	2011-01-24 20:05:18 +0000
@@ -360,7 +360,8 @@
      (t
       ;; This is regexp like quote thingy.
       (setq char (char-after (nth 8 state)))
-      (let ((twoargs (save-excursion
+      (let ((startpos (point))
+            (twoargs (save-excursion
                        (goto-char (nth 8 state))
                        (skip-syntax-backward " ")
                        (skip-syntax-backward "w")
@@ -384,7 +385,8 @@
 			  (goto-char (1+ (nth 8 state)))
 			  (up-list 1)
 			  t)
-		      (scan-error nil))
+                      ;; In case of error, make sure we don't move backward.
+		      (scan-error (goto-char startpos) nil))
 		  (not (or (nth 8 (parse-partial-sexp
 				   (point) limit nil nil state 'syntax-table))
 			   ;; If we have a self-paired opener and a twoargs

Subject: 24.0.50; perl-mode infinite loop
From: [email-masked]
To: [email-masked]
Date: Sat, 25 Dec 2010 21:41:26 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Man, you gotta see this. On this attached file,
save in /tmp, and run emacs -Q -nw /tmp/r.pl

Now move the cursor down and attempt to change shttp to s[http .
As you insert the [ an infinite loop begins.
You probably can break out with a C-g, but you might need a
$ killall -HUP emacs

In GNU Emacs 24.0.50.1 (i486-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2010-12-14 on elegiac, modified by Debian
 (emacs-snapshot package, version 1:20101212-2)

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: zh_TW.UTF-8
  value of $LC_MESSAGES: C
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: C
  value of $LANG: zh_TW.UTF-8
  value of $XMODIFIERS: @im=SCIM
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t