changeset 111787:4ba82556d7dd

cl-macs `loop' fix for bug#7492. * lisp/emacs-lisp/cl-macs.el (cl-parse-loop-clause): Avoid infinite loop over windows.
author Glenn Morris <rgm@gnu.org>
date Thu, 02 Dec 2010 09:36:45 -0800
parents 1441c8ae52a0
children 8e746f396237
files lisp/ChangeLog lisp/emacs-lisp/cl-macs.el
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Dec 02 09:34:35 2010 -0800
+++ b/lisp/ChangeLog	Thu Dec 02 09:36:45 2010 -0800
@@ -1,5 +1,8 @@
 2010-12-02  Glenn Morris  <rgm@gnu.org>
 
+	* emacs-lisp/cl-macs.el (cl-parse-loop-clause):
+	Avoid infinite loop over windows.  (Bug#7492)
+
 	* progmodes/flymake.el (flymake-check-file-limit):
 	Allow nil to mean "no limit".
 	(flymake-check-patch-master-file-buffer): Update for above change.
--- a/lisp/emacs-lisp/cl-macs.el	Thu Dec 02 09:34:35 2010 -0800
+++ b/lisp/emacs-lisp/cl-macs.el	Thu Dec 02 09:36:45 2010 -0800
@@ -965,16 +965,25 @@
 
 	       ((memq word '(window windows))
 		(let ((scr (and (memq (car loop-args) '(in of)) (cl-pop2 loop-args)))
-		      (temp (make-symbol "--cl-var--")))
+		      (temp (make-symbol "--cl-var--"))
+		      (minip (make-symbol "--cl-minip--")))
 		  (push (list var (if scr
 				      (list 'frame-selected-window scr)
 				    '(selected-window)))
 			loop-for-bindings)
+		  ;; If we started in the minibuffer, we need to
+		  ;; ensure that next-window will bring us back there
+		  ;; at some point.  (Bug#7492).
+		  ;; (Consider using walk-windows instead of loop if
+		  ;; you care about such things.)
+		  (push (list minip `(minibufferp (window-buffer ,var)))
+			loop-for-bindings)
 		  (push (list temp nil) loop-for-bindings)
 		  (push (list 'prog1 (list 'not (list 'eq var temp))
 			      (list 'or temp (list 'setq temp var)))
 			loop-body)
-		  (push (list var (list 'next-window var)) loop-for-steps)))
+		  (push (list var (list 'next-window var minip))
+			loop-for-steps)))
 
 	       (t
 		(let ((handler (and (symbolp word)