Subject: Re: bug#11966: 24.1; cperl-mode with evil-mode causes hang on syntax-propertize
From: Stefan Monnier <[email-masked]>
To: JC Petkovich <[email-masked]>
Cc: [email-masked], Ilya Zakharevich <[email-masked]>
Date: Wed, 18 Jul 2012 05:35:23 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Version:24.2

> Emacs hangs on the creation of a newline with evil-ret when in a cperl
> buffer with some POD documentation after the __END__. This doesn't
> appear to be a bug in evil, but instead a bug in cperl or
> syntax-propertize,

Indeed, I could reproduce it without evil.  It seems to be a bug in
cperl-mode, tho maybe it can only be triggered via syntax-propertize.
In any case, I've installed the patch below into the emacs-24 branch,
and that should fix it.  Thanks you,

        Stefan

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-07-09 13:54:50 +0000
+++ lisp/ChangeLog	2012-07-18 09:32:41 +0000
@@ -1,3 +1,8 @@
+2012-07-18  Stefan Monnier  <[email-masked]>
+
+	* progmodes/cperl-mode.el (cperl-unwind-to-safe): Don't inf-loop at end
+	of narrowed buffer (bug#11966).
+
 2012-07-09  Stefan Monnier  <[email-masked]>
 
 	* progmodes/sh-script.el (sh-syntax-propertize-function): Fix last

=== modified file 'lisp/progmodes/cperl-mode.el'
--- lisp/progmodes/cperl-mode.el	2012-06-21 16:49:21 +0000
+++ lisp/progmodes/cperl-mode.el	2012-07-18 09:31:14 +0000
@@ -3498,7 +3498,8 @@
     (if end
 	;; Do the same for end, going small steps
 	(save-excursion
-	  (while (and end (get-text-property end 'syntax-type))
+	  (while (and end (< end (point-max))
+		      (get-text-property end 'syntax-type))
 	    (setq pos end
 		  end (next-single-property-change end 'syntax-type nil (point-max)))
 	    (if end (progn (goto-char end)