Commits

Anonymous committed c925616

lazy-lock causes frame-selected-window to change

  • Participants
  • Parent commits a597072

Comments (0)

Files changed (2)

+2001-02-15  Martin Buchholz  <martin@xemacs.org>
+
+	Fix bug:
+	xemacs -q -no-site-file ~/.emacs -f font-lock-mode \
+	  -f turn-on-lazy-lock -f split-window-vertically -f make-frame
+	Then select upper window, move mouse to single-window frame, move
+	mouse back to split-window frame. Selected window will be lower one.
+	* lazy-lock.el:
+	(lazy-lock-pre-idle-fontify-windows): 
+	The idiom (with-selected-window x ...) only works if x is in the
+	same frame as the selected window - else the frame-selected window
+	of x's frame is not restored.
+	(lazy-lock-maybe-fontify-frame): New.
+
 2001-02-15  Martin Buchholz  <martin@xemacs.org>
 
 	* lazy-lock.el: Byte-compiler warning cleanup.

File lazy-lock.el

 taking longer to fontify, you could increase the value of this variable.
 See also `lazy-lock-stealth-load'."
   :type '(choice (const :tag "never" nil)
-		 (number :tag "seconds"))	  
+		 (number :tag "seconds"))
   :group 'lazy-lock)
 
 (defcustom lazy-lock-stealth-verbose (not (null font-lock-verbose))
   :type 'boolean
   :group 'lazy-lock)
 
-(defcustom lazy-lock-invisible-foreground "gray50" 
+(defcustom lazy-lock-invisible-foreground "gray50"
   "The foreground colour to use to display invisible text.
 If nil, the default foreground is used.  If t, the default background is used.
 If a string, it should be a colour to use (either its name or its RGB value).
 	    (and (eq lazy-lock-walk-windows t) (one-window-p t)))
        (or (window-minibuffer-p (selected-window))
 	    (lazy-lock-maybe-fontify-window (selected-window)))
-      (walk-windows #'lazy-lock-maybe-fontify-window
-		    'no-minibuf (eq lazy-lock-walk-windows 'all-frames)))))
+      (if (eq lazy-lock-walk-windows t)
+	  (lazy-lock-maybe-fontify-frame (selected-frame))
+	;; Do all visible non-minibuffer-only frames on the selected device.
+	(catch 'lazy-lock-frame-loop-done
+	  (let* ((old-frame (selected-frame))
+		 (frame old-frame))
+	    (while t
+	      (lazy-lock-maybe-fontify-frame frame)
+	      (setq frame (next-frame frame 'visible-nomini))
+	      (when (eq frame old-frame)
+		(throw 'lazy-lock-frame-loop-done t)))))))))
+
+(defun lazy-lock-maybe-fontify-frame (frame)
+  ;; Fontify the given frame if we need to.  We first check the
+  ;; appropriate frame-modified-tick to avoid changing global state.
+  (let ((tick (frame-modified-tick frame)))
+    (unless (eq tick (frame-property frame 'lazy-lock-modified-tick))
+      (set-frame-property frame 'lazy-lock-modified-tick tick)
+      (with-selected-frame frame
+	(walk-windows #'lazy-lock-maybe-fontify-window 'no-minibuf)))))
 
 (defun lazy-lock-after-change-function (beg end old-len)
-  (and lazy-lock-mode
-       (if (= beg end)
-	   (font-lock-after-change-function beg end old-len)
-	 (lazy-lock-put-text-property beg end 'lazy-lock-fontified nil))))
+  (when lazy-lock-mode
+    (if (= beg end)
+	(font-lock-after-change-function beg end old-len)
+      (lazy-lock-put-text-property beg end 'lazy-lock-fontified nil))))
 
 (defvar lazy-lock-timeout-id nil)
 
 
 (defun lazy-lock-maybe-fontify-window (window)
   ;; Fontify the given window if we need to.  We first check the
-  ;; buffer-local value of lazy-lock-mode and the appropriate
-  ;; frame-modified-tick to make sure we should do the more accurate
-  ;; (but semi-expensive) checks in lazy-lock-fontify-window.  In this
-  ;; function, we are extremely careful not to change any global state
-  ;; (e.g. select-window, which will trip frame-modified-tick) until
-  ;; we've verified that we need to proceed to lazy-lock-fontify-window.
+  ;; buffer-local value of lazy-lock-mode to make sure we should do
+  ;; the more accurate (but semi-expensive) checks in
+  ;; lazy-lock-fontify-window.  In this function, we are careful not
+  ;; to change any global state by calling select-window, which will
+  ;; trip frame-modified-tick, until we've verified that we need to
+  ;; proceed to lazy-lock-fontify-window.
   (when (symbol-value-in-buffer 'lazy-lock-mode (window-buffer window))
-    (let* ((frame (window-frame window))
-	   (tick (frame-modified-tick frame)))
-      (unless (eq tick (frame-property frame 'lazy-lock-modified-tick))
-	(set-frame-property frame 'lazy-lock-modified-tick tick)
-	(save-selected-window
-	  (select-window window)
-	  (lazy-lock-fontify-window))))))
+    (with-selected-window window
+      (lazy-lock-fontify-window))))
 
 (defun lazy-lock-fontify-window ()
   ;; Fontify the visible part of the buffer where necessary.