================================================================
Dear Bug Team!
What happens:
-------------
walk-windows hangs when its which-frames argument is for a different
frame than the selected frame at the time of the call to walk-windows.
How to reproduce:
-----------------
In a freshly-started xemacs with no init file (I ran with -q option),
in the *scratch* lisp-interaction buffer, type:
(setq aframe (make-frame))C-j
Now reselect the original frame that xemacs started with, and type
into the same *scratch* buffer there:
(walk-windows 'window-buffer t aframe)C-j
Xemacs enters an infinite loop, as can be verified by
critical-quitting into the debugger. I feel what should have happened
is for this call to return nil quickly, as of course there is only one
window in the frame aframe at this point.
My analysis offered for your consideration:
------------------------------------------
The definition of walk-windows is in lib/xemacs-21.4.12/lisp, and I
reproduce it here:
> (defun walk-windows (function &optional minibuf which-frames which-devices)
> "Cycle through all visible windows, calling FUNCTION for each one.
> FUNCTION is called with a window as argument.
>
> Optional second arg MINIBUF t means count the minibuffer window even
> if not active. MINIBUF nil or omitted means count the minibuffer iff
> it is active. MINIBUF neither t nor nil means not to count the
> minibuffer even if it is active.
>
> Several frames may share a single minibuffer; if the minibuffer
> counts, all windows on all frames that share that minibuffer count
> too. Therefore, when a separate minibuffer frame is active,
> `walk-windows' includes the windows in the frame from which you
> entered the minibuffer, as well as the minibuffer window. But if the
> minibuffer does not count, only the selected window counts.
>
> By default, only the windows in the selected frame are included.
> The optional argument WHICH-FRAMES changes this behavior:
> WHICH-FRAMES nil or omitted means cycle within the frames as specified above.
> WHICH-FRAMES = `visible' means include windows on all visible frames.
> WHICH-FRAMES = 0 means include windows on all visible and iconified frames.
> WHICH-FRAMES = t means include windows on all frames including invisible frames.
> Anything else means restrict to WINDOW's frame.
>
> The optional fourth argument WHICH-DEVICES further clarifies on which
> devices to search for frames as specified by WHICH-FRAMES. This value
> is only meaningful if WHICH-FRAMES is non-nil.
> If nil or omitted, search all devices on the selected console.
> If a device, only search that device.
> If a console, search all devices on that console.
> If a device type, search all devices of that type.
> If `window-system', search all devices on window-system consoles.
> Any other non-nil value means search all devices."
> ;; If we start from the minibuffer window, don't fail to come back to it.
> (if (window-minibuffer-p (selected-window))
> (setq minibuf t))
> ;; Note that, like next-window & previous-window, this behaves a little
> ;; strangely if the selected window is on an invisible frame: it hits
> ;; some of the windows on that frame, and all windows on visible frames.
> (let* ((walk-windows-start (selected-window))
> (walk-windows-current walk-windows-start))
> (while (progn
> (setq walk-windows-current
> (next-window walk-windows-current minibuf which-frames
> which-devices))
> (funcall function walk-windows-current)
> (not (eq walk-windows-current walk-windows-start))))))
The underlying problem is the following: if the class of windows
described by the three arguments passed through to next-window [namely
minibuf, which-frames, and which-devices] does not include the
(selected-window) at the time of the invocation of walk-windows, then
walk-windows-current can never end up eq to walk-windows-start as a
result of a call to next-window. Indeed, the special treatment of the
minibuf argument in the case that (selected-window) is
window-minibuffer-p is just a workaround to this same problem in the
case of minibuf status. But rather than altering the user's request so
that the (selected-window) is one of the potential outputs of
next-window, it seems preferable to me to use the first *output* of
next-window as the sentinel for being done, and leave the user's
request alone. Here is my suggested reimplementation of walk-window
which avoids the infinite loop in all cases in which the function
called does not alter the window configuration:
(defun walk-windows (function &optional minibuf which-frames which-devices)
"Cycle through all visible windows, calling FUNCTION for each one.
FUNCTION is called with a window as argument.
All of the remaining (optional) arguments MINIBUF, WHICH-FRAMES, and
WHICH-DEVICES are passed through to `next-window', which is used to
generate the windows to cycle through. Hence they have the same
interpretations as in `next-window', see their documentation there.
Note that if FUNCTION alters the configuration of windows,
`walk-windows' may miss windows and/or enter an infinite loop."
;; Note that, like next-window & previous-window, this behaves a little
;; strangely if the selected window is on an invisible frame: it hits
;; some of the windows on that frame, and all windows on visible frames.
(let* ((current (selected-window))
(sentinel nil)) ;; sentinel will be the first window we process;
;; next-window will eventually return to that
;; one unless function alters the window config
(while (progn
(setq current
(next-window current minibuf which-frames which-devices))
(funcall function current)
(if (eq current sentinel)
nil ;; i.e., done; otherwise, set sentinel on first iteration:
(if (not sentinel) (setq sentinel current) t))))))
Thanks for your consideration of this problem. As I don't have the
opportunity to read any xemacs newsgroups, I would appreciate it if
you had a chance to let me know what the response to this bug will be.
Thanks for all the great work on xemacs. It is part of my way of
life.:-)
Sincerely, Glen Whitney
================================================================
System Info to help track down your bug:
---------------------------------------
uname -a: SunOS gazelle 5.8 Generic_108528-16 sun4u sparc SUNW,Ultra-60
configure '--compiler=/opt/spro62/SUNWspro/bin/cc' '--with-gcc=no' '--prefix=/net/gazelle/export/local/sol2sun4m/products/xemacs/bld.SunOS.21.4.12.20030116' '--with-sparcworks' '--with-workshop' '--with-tooltalk' '--site-includes=/usr/local/ren/prod/include /usr/local/gnu/include /usr/local/include' '--infopath=/usr/local/info:usr/local/ren/prod/info:/usr/local/gnu/info' '--site-libraries=/usr/local/ren/prod/lib /usr/local/lib' '--with-xpm' '--with-ncurses=no' '--with-sound=native' '--with-jpeg=yes' '--with-png=yes' '--with-ldap=no' '--with-postgresql=no' '--with-menubars=lucid' '--with-scrollbars=lucid'
XEmacs 21.4.12 "Portable Code" configured for `sparc-sun-solaris2.8'.
Compilation / Installation:
Source code location: /scratch/bharry/src/xemacs/bld.SunOS.21.4.12.20030116/xemacs-21.4.12
Installation prefix: /net/gazelle/export/local/sol2sun4m/products/xemacs/bld.SunOS.21.4.12.20030116
Additional header files: /usr/local/ren/prod/include /usr/local/gnu/include /usr/local/include
Additional libraries: /usr/local/ren/prod/lib /usr/local/lib
Runtime library search path: /usr/local/ren/prod/lib:/usr/local/lib:/usr/dt/lib:/usr/openwin/lib:/opt/SUNWdt/lib
Operating system description file: `s/sol2.h'
Machine description file: `m/sparc.h'
Compiler: /opt/spro62/SUNWspro/bin/cc -v -xO4
Relocating allocator for buffers: yes
GNU version of malloc: yes
Window System:
Compiling in support for the X window system:
- X Windows headers location: /usr/dt/include /usr/openwin/include
- X Windows libraries location: /usr/dt/lib /usr/openwin/lib
- Handling WM_COMMAND properly.
Using Lucid menubars.
Using Lucid scrollbars.
Using Motif dialog boxes.
Using Motif native widgets.
TTY:
Images:
Compiling in support for GIF images (builtin).
Compiling in support for XPM images.
Compiling in support for PNG images.
Compiling in support for JPEG images.
Sound:
Compiling in support for sound (native).
Databases:
Compiling in support for Berkeley database.
Compiling in support for GNU DBM.
Internationalization:
Mail:
Compiling in support for "dot-locking" mail spool file locking method.
Other Features:
Inhibiting IPv6 canonicalization at startup.
Compiling in support for ToolTalk.
Compiling in support for Sun WorkShop.
Compiling in support for dynamic shared object modules.
Load-Path Lisp Shadows:
----------------------
(/usr/local/products/xemacs/bld.SunOS.21.4.12.20030116/lib/xemacs/xemacs-packages/lisp/build/build-report
/usr/local/products/xemacs/bld.SunOS.21.4.12.20030116/lib/xemacs-21.4.12/lisp/build-report)
Installed XEmacs Packages:
-------------------------
((zenirc:version 1.13 :type regular)
(xslt-process :version 1.11 :type regular)
(xslide :version 1.06 :type regular)
(xemacs-devel :version 1.55 :type single-file)
(xemacs-base :version 1.77 :type regular)
(x-symbol :version 1.04 :type regular)
(w3 :version 1.28 :type regular)
(vm :version 7.14 :type regular)
(viper :version 1.36 :type regular)
(view-process :version 1.12 :type regular)
(vhdl :version 1.16 :type regular)
(vc-cc :version 1.21 :type regular)
(vc :version 1.37 :type regular)
(tramp :version 1.12 :type regular)
(tpu :version 1.12 :type regular)
(tooltalk :version 1.13 :type regular)
(tm :version 1.36 :type regular)
(time :version 1.13 :type regular)
(textools :version 1.14 :type regular)
(text-modes :version 1.6 :type single-file)
(texinfo :version 1.24 :type regular)
(supercite :version 1.19 :type regular)
(strokes :version 1.08 :type regular)
(speedbar :version 1.26 :type regular)
(sounds-wav :version 1.1 :type regular)
(sounds-au :version 1.1 :type regular)
(sml-mode :version 0.09 :type regular)
(slider :version 1.13 :type regular)
(sieve :version 1.13 :type regular)
(sh-script :version 1.17 :type regular)
(sgml :version 1.08 :type regular)
(semantic :version 1.17 :type regular)
(scheme :version 1.13 :type regular)
(sasl :version 1.12 :type regular)
(ruby-modes :version 1.01 :type regular)
(rmail :version 1.13 :type regular)
(reftex :version 1.28 :type regular)
(python-modes :version 1.02 :type single-file)
(psgml-dtds :version 1.02 :type regular)
(psgml :version 1.4 :type regular)
(ps-print :version 1.08 :type regular)
(prog-modes
:version
1
.73
:type
single-file)
(pgg :version 1.03 :type regular)
(perl-modes :version 1.04 :type single-file)
(pcomplete :version 1.02 :type regular)
(pcl-cvs :version 1.64 :type regular)
(pc :version 1.25 :type single-file)
(os-utils :version 1.3 :type single-file)
(ocaml :version 0.04 :type regular)
(net-utils :version 1.32 :type single-file)
(mmm-mode :version 1.0 :type regular)
(misc-games :version 1.16 :type single-file)
(mine :version 1.14 :type regular)
(mh-e :version 1.23 :type regular)
(mew :version 1.17 :type regular)
(mailcrypt :version 2.12 :type regular)
(mail-lib :version 1.59 :type regular)
(liece :version 1.12 :type regular)
(jde :version 1.45 :type regular)
(ispell :version 1.24 :type regular)
(ilisp :version 1.32 :type regular)
(igrep :version 1.1 :type regular)
(idlwave :version 1.28 :type regular)
(ibuffer :version 1.08 :type regular)
(hm--html-menus :version 1.2 :type regular)
(haskell-mode :version 1.05 :type regular)
(gnus :version 1.71 :type regular)
(gnats :version 1.15 :type regular)
(games :version 1.13 :type regular)
(fsf-compat :version 1.12 :type single-file)
(frame-icon :version 1.09 :type regular)
(fortran-modes :version 1.02 :type single-file)
(forms :version 1.14 :type regular)
(footnote :version 1.15 :type regular)
(eudc :version 1.38 :type regular)
(eterm :version 1.13 :type regular)
(ess :version 1.03 :type regular)
(eshell :version 1.05 :type regular)
(emerge :version 1.09 :type regular)
(elib :version 1.1 :type single-file)
(eieio :version 1.04 :type regular)
(efs :version 1.29 :type regular)
(edt :version 1.12 :type regular)
(edit-utils :version 2.0 :type single-file)
(ediff :version 1.47 :type regular)
(edebug :version 1.17 :type regular)
(ecrypto :version 0.12 :type regular)
(ecb :version 1.06 :type regular)
(docbookide :version 0.06 :type regular)
(dired :version 1.13 :type regular)
(dictionary :version 1.11 :type regular)
(debug :version 1.16 :type regular)
(crisp :version 1.12 :type regular)
(cookie :version 1.14 :type regular)
(clearcase :version 1.06 :type regular)
(cc-mode :version 1.33 :type regular)
(calendar :version 1.19 :type regular)
(calc :version 1.23 :type regular)
(c-support :version 1.16 :type single-file)
(build :version 1.1 :type regular)
(bbdb :version 1.23 :type regular)
(auctex :version 1.35 :type regular)
(apel :version 1.26 :type regular)
(ada :version 1.13 :type regular)
(Sun :version 1.13 :type regular))
Installed Modules:
-----------------
Features:
--------
(view-less view ehelp electric mail-abbrevs xemacsbug shadow sendmail
rfc822 zenirc-autoloads xslt-process-autoloads xslide-autoloads
xemacs-devel-autoloads xemacs-base-autoloads x-symbol-autoloads
w3-autoloads vm-autoloads viper-autoloads view-process-autoloads
vhdl-autoloads vc-cc-autoloads vc-autoloads tramp-autoloads
tpu-autoloads tooltalk-autoloads tm-autoloads time-autoloads
textools-autoloads text-modes-autoloads texinfo-autoloads
supercite-autoloads strokes-autoloads speedbar-autoloads
sounds-wav-autoloads sounds-au-autoloads sml-mode-autoloads
slider-autoloads sieve-autoloads sh-script-autoloads sgml-autoloads
semantic-autoloads scheme-autoloads sasl-autoloads
ruby-modes-autoloads rmail-autoloads reftex-autoloads
python-modes-autoloads psgml-dtds-autoloads psgml-autoloads
ps-print-autoloads prog-modes-autoloads pgg-autoloads
perl-modes-autoloads pcomplete-autoloads pcl-cvs-autoloads
pc-autoloads os-utils-autoloads ocaml-autoloads net-utils-autoloads
mmm-mode-autoloads misc-games-autoloads mine-autoloads mh-e-autoloads
mew-autoloads mailcrypt-autoloads mail-lib-autoloads liece-autoloads
jde-autoloads ispell-autoloads ilisp-autoloads igrep-autoloads
idlwave-autoloads ibuffer-autoloads hm--html-menus-autoloads
haskell-mode-autoloads gnus-autoloads gnats-autoloads games-autoloads
fsf-compat-autoloads frame-icon-autoloads fortran-modes-autoloads
forms-autoloads footnote-autoloads eudc-autoloads eterm-autoloads
ess-autoloads eshell-autoloads emerge-autoloads elib-autoloads
eieio-autoloads efs-autoloads edt-autoloads edit-utils-autoloads
ediff-autoloads edebug-autoloads ecrypto-autoloads ecb-autoloads
docbookide-autoloads dired-autoloads dictionary-autoloads
debug-autoloads crisp-autoloads cookie-autoloads clearcase-autoloads
cc-mode-autoloads calendar-autoloads calc-autoloads
c-support-autoloads build-autoloads bbdb-autoloads auctex-autoloads
apel-autoloads ada-autoloads Sun-autoloads lisp-autoloads loadhist
auto-show fontl-hooks x-iso8859-1 gutter-items menubar-items x-menubar
mode-motion mouse itimer auto-save lisp-mode easymenu iso8859-1 page
buff-menu lib-complete help-nomule cus-file derived frame text-props
obsolete cus-start custom widget cl-extra mini-cl cl cl-19 packages
backquote very-early-lisp sparcworks tooltalk lucid-scrollbars
cut-buffer lucid-menubars motif-dialogs x c-balloon-help tty-frames
tty toolbar native-sound scrollbar unix-processes multicast
network-streams subprocesses modules menu-accelerator-support menubar
berkeley-db dbm md5 xemacs gutter png gif jpeg xpm xbm lisp-float-type
usg-unix-v dialog devices window-system base64)
Recent keystrokes:
-----------------
d o w s SPC o n SPC a n o t h e r SPC f r a m e RET
down down down down down down down down down down down
down down down down down down down down down down down
down up up up up up up up up up up up up misc-user
misc-user misc-user misc-user misc-user misc-user misc-user
misc-user misc-user misc-user misc-user misc-user misc-user
misc-user misc-user misc-user misc-user misc-user misc-user
misc-user misc-user misc-user misc-user misc-user misc-user
misc-user misc-user misc-user misc-user misc-user misc-user
misc-user misc-user button1 button1up C-x u C-x u C-x
k RET misc-user
Recent messages (most recent first):
-----------------------------------
No further undo information
Type C-c C-c to send the bug report, C-x k to cancel.
Leaving electric command loop because buffer has changed.
space = page forward; b = page back; h = help; q = quit.
Loading view-less...done
Loading view-less...
Loading ehelp...done
Loading ehelp...
Auto save file for draft message exists; consider M-x mail-recover
Parsing /home/glen/.mailrc... done
Parsing /home/glen/.mailrc...
Loading xemacsbug...done
Loading xemacsbug...