changeset 611:38db05db9cb5

[xemacs-hg @ 2001-06-08 12:21:09 by ben] ------ gc-in-window-procedure fixes ------ alloc.c: Create "post-gc actions", to avoid those dreaded "GC during window procedure" problems. event-msw.c: Abort, clean and simple, when GC in window procedure. We want to flush these puppies out. glyphs-msw.c: Use a post-gc action when destroying subwindows. lisp.h: Declare register_post_gc_action(). scrollbar-msw.c: Use a post-gc action when unshowing scrollbar windows, if in gc. redisplay.c: Add comment about the utter evilness of what's going down here. ------ cygwin setitimer fixes ------ Makefile.in.in: Compile profile.c only when HAVE_SETITIMER. nt.c: Style fixes. nt.c: Move setitimer() emulation to win32.c, because Cygwin needs it too. profile.c: Make sure we don't compile if no setitimer(). Use qxe_setitimer() instead of just plain setitimer(). signal.c: Define qxe_setitimer() as an encapsulation around setitimer() -- call setitimer() directly unless Cygwin or MS Win, in which case we use our simulated version in win32.c. systime.h: Prototype mswindows_setitimer() and qxe_setitimer(). Long comment about "qxe" and the policy regarding encapsulation. win32.c: Move setitimer() emulation here, so Cygwin can use it. Rename a couple of functions and variables to be longer and more descriptive. In setitimer_helper_proc(), send the signal using either mswindows_raise() or (on Cygwin) kill(). If for some reason we are still getting lockups, we'll change the kill() to directly invoke the signal handlers. ------ windows shell fixes ------ callproc.c, ntproc.c: Comments about how these two files must die. callproc.c: On MS Windows, init shell-file-name from SHELL, then COMSPEC, not just COMSPEC. (more correct and closer to FSF.) Don't force a value for SHELL into the environment. (Comments added to explain why not.) nt.c: Don't shove a fabricated SHELL into the environment. See above. ------ misc fixes ------ glyphs-shared.c: Style correction. xemacs-faq.texi: Merge in the rest of Hrvoje's Windows FAQ. Redo section 7 to update current reality and add condensed versions of new changes for 21.1 and 21.4. (Not quite done for 21.4.) Lots more Windows updates. process.el: Need to quote a null argument, too. From Dan Holmsand. startup.el: startup.el: Call MS Windows init function. win32-native.el: Correct comments at top. Correctly handle passing arguments to Cygwin programs and to bash. Fix quoting of zero-length arguments (from Dan Holmsand). Set shell-command-switch based on shell-file-name, which in turn comes from env var SHELL.
author ben
date Fri, 08 Jun 2001 12:21:27 +0000
parents 45ba69404a1f
children ff0d9e7facba
files lisp/ChangeLog lisp/process.el lisp/startup.el lisp/win32-native.el man/ChangeLog man/xemacs-faq.texi src/ChangeLog src/Makefile.in.in src/alloc.c src/callproc.c src/event-msw.c src/glyphs-msw.c src/glyphs-shared.c src/lisp.h src/nt.c src/ntproc.c src/profile.c src/redisplay.c src/scrollbar-msw.c src/signal.c src/systime.h src/win32.c
diffstat 22 files changed, 1139 insertions(+), 361 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Jun 07 06:37:25 2001 +0000
+++ b/lisp/ChangeLog	Fri Jun 08 12:21:27 2001 +0000
@@ -1,3 +1,27 @@
+2001-06-08  Ben Wing  <ben@xemacs.org>
+
+	* process.el: comment about shell-command-switch.
+	* process.el (shell-quote-argument): Need to quote a null
+	argument, too.  From Dan Holmsand.
+	
+	* startup.el (normal-top-level): Delete some unused FSF junk.
+	* startup.el (command-line-early):
+	
+	* startup.el (command-line): Call MS Windows init function.
+	
+	* win32-native.el:
+	* win32-native.el (mswindows-system-shells): New.
+	* win32-native.el (mswindows-system-shell-p): New.
+	* win32-native.el (init-mswindows-at-startup): New.
+	* win32-native.el (mswindows-quote-one-vc-runtime-arg):
+	* win32-native.el (mswindows-quote-one-simple-arg):
+	* win32-native.el (mswindows-quote-one-command-arg):
+	* win32-native.el (mswindows-construct-process-command-line-alist):
+	Correct comments at top.  Correctly handle passing arguments
+	to Cygwin programs and to bash.  Fix quoting of zero-length
+	arguments (from Dan Holmsand).  Set shell-command-switch based
+	on shell-file-name, which in turn comes from env var SHELL.
+
 2001-06-03  William M. Perry  <wmperry@gnu.org>
 
 	* dialog-gtk.el (popup-builtin-open-dialog): Yikes - don't forget
--- a/lisp/process.el	Thu Jun 07 06:37:25 2001 +0000
+++ b/lisp/process.el	Fri Jun 08 12:21:27 2001 +0000
@@ -53,6 +53,7 @@
   "Executing external commands."
   :group 'processes)
 
+;; This may be changed to "/c" in win32-native.el.
 
 (defvar shell-command-switch "-c"
   "Switch used to have the shell execute its command line argument.")
@@ -446,15 +447,17 @@
       ;; around shell metachars gets through the last two, and applying
       ;; the normal VC runtime quoting works with practically all apps.
       (mswindows-quote-one-vc-runtime-arg argument t)
-    ;; Quote everything except POSIX filename characters.
-    ;; This should be safe enough even for really weird shells.
-    (let ((result "") (start 0) end)
-      (while (string-match "[^-0-9a-zA-Z_./]" argument start)
-	(setq end (match-beginning 0)
-	      result (concat result (substring argument start end)
-			     "\\" (substring argument end (1+ end)))
-	      start (1+ end)))
-      (concat result (substring argument start)))))
+    (if (equal argument "")
+	"\"\""
+      ;; Quote everything except POSIX filename characters.
+      ;; This should be safe enough even for really weird shells.
+      (let ((result "") (start 0) end)
+	(while (string-match "[^-0-9a-zA-Z_./]" argument start)
+	  (setq end (match-beginning 0)
+		result (concat result (substring argument start end)
+			       "\\" (substring argument end (1+ end)))
+		start (1+ end)))
+	(concat result (substring argument start))))))
 
 (defun shell-command-to-string (command)
   "Execute shell command COMMAND and return its output as a string."
--- a/lisp/startup.el	Thu Jun 07 06:37:25 2001 +0000
+++ b/lisp/startup.el	Fri Jun 08 12:21:27 2001 +0000
@@ -481,24 +481,10 @@
 
     (if load-user-init-file-p
 	(maybe-migrate-user-init-file))
-    ;;####FSFmacs junk
-    ;;      (or menubar-bindings-done
-    ;;	  (precompute-menubar-bindings))
+    ;; FSF calls precompute-menubar-bindings.  We don't mix menubars
+    ;; and keymaps.
     ))
 
-;;####FSFmacs junk
-;;; Precompute the keyboard equivalents in the menu bar items.
-;;(defun precompute-menubar-bindings ()
-;;  (if (eq window-system 'x)
-;;      (let ((submap (lookup-key global-map [menu-bar])))
-;;	(while submap
-;;	  (and (consp (car submap))
-;;	       (symbolp (car (car submap)))
-;;	       (stringp (car-safe (cdr (car submap))))
-;;	       (keymapp (cdr (cdr (car submap))))
-;;	       (x-popup-menu nil (cdr (cdr (car submap)))))
-;;	  (setq submap (cdr submap))))))
-
 (defun command-line-early (args)
   ;; This processes those switches which need to be processed before
   ;; starting up the window system.
@@ -614,6 +600,9 @@
       ;; handled here instead of down in C.
       (setq command-line-args-left (command-line-early command-line-args-left))
 
+      (when (eq system-type 'windows-nt)
+	(init-mswindows-at-startup))
+
       ;; Setup the toolbar icon directory
       (when (featurep 'toolbar)
 	(init-toolbar-location))
--- a/lisp/win32-native.el	Thu Jun 07 06:37:25 2001 +0000
+++ b/lisp/win32-native.el	Fri Jun 08 12:21:27 2001 +0000
@@ -1,4 +1,4 @@
-;;; win32-native.el --- Lisp routines for MS Windows.
+;;; win32-native.el --- Lisp routines when running on native MS Windows.
 
 ;; Copyright (C) 1994 Free Software Foundation, Inc.
 ;; Copyright (C) 2000 Ben Wing.
@@ -23,24 +23,26 @@
 ;; Free Software Foundation, 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: Not synched with FSF.  Almost completely divergent.
+;;; Synched up with: Not in FSF.
 ;;; (FSF has stuff in w32-fns.el and term/w32-win.el.)
 
 ;;; Commentary:
 
 ;; This file is dumped with XEmacs for MS Windows (without cygwin).
+;; It is for stuff that is used specifically when `system-type' eq
+;; `windows-nt' (i.e. also applies to MinGW), and has nothing to do
+;; with the `mswindows' device type.  Thus, it probably applies in
+;; non-interactive mode as well, and it DOES NOT APPLY to Cygwin.
 
-;; Based on NT Emacs version by Geoff Voelker (voelker@cs.washington.edu)
+;; Based (originally) on NT Emacs version by Geoff Voelker
+;; (voelker@cs.washington.edu)
 ;; Ported to XEmacs by Marc Paquette <marcpa@cam.org>
 ;; Largely modified by Kirill M. Katsnelson <kkm@kis.ru>
+;; Rewritten from scratch by Ben Wing <ben@xemacs.org>.  No code in common
+;; with FSF.
 
 ;;; Code:
 
-;; The cmd.exe shell uses the "/c" switch instead of the "-c" switch
-;; for executing its command line argument (from simple.el).
-;; #### Oh if we had an alist of shells and their command switches.
-(setq shell-command-switch "/c")
-
 ;; For appending suffixes to directories and files in shell
 ;; completions.  This screws up cygwin users so we leave it out for
 ;; now. Uncomment this if you only ever want to use cmd.
@@ -61,6 +63,27 @@
 (setq grep-regexp-alist
   '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3)))
 
+(defvar mswindows-system-shells '("cmd" "cmd.exe" "command" "command.com"
+				  "4nt" "4nt.exe" "4dos" "4dos.exe"
+				  "ndos" "ndos.exe")
+  "List of strings recognized as Windows NT/9X system shells.
+These are shells with native semantics, e.g. they use `/c', not '-c',
+to pass a command in.")
+
+(defun mswindows-system-shell-p (shell-name)
+  (member (downcase (file-name-nondirectory shell-name)) 
+	  mswindows-system-shells))
+
+(defun init-mswindows-at-startup ()
+  ;; shell-file-name is initialized in the C code (callproc.c) from
+  ;; SHELL or COMSPEC.
+  ;; #### If only shell-command-switch could be a function.  But there
+  ;; is code littered around that uses it.
+  ;; #### Maybe we should set a symbol-value handler on `shell-file-name'
+  ;; that automatically sets shell-command-switch?
+  (if (mswindows-system-shell-p shell-file-name)
+      (setq shell-command-switch "/c")))
+
 ;;----------------------------------------------------------------------
 ;; Quoting process args
 ;;--------------------
@@ -76,28 +99,32 @@
   ;; we also include shell metachars if asked.
   ;; note that \ is NOT included!  it's perfectly OK to include an
   ;; arg like c:\ or c:\foo.
-  (if (string-match (if quote-shell "[ \t\n\r\f*?\"<>|&^%]" "[ \t\n\r\f*?\"]")
-		    arg)
-      (progn
-	;; handle nested quotes, possibly preceded by backslashes
-	(setq arg (replace-in-string arg "\\([\\]*\\)\"" "\\1\\1\\\\\""))
-	;; handle trailing backslashes
-	(setq arg (replace-in-string arg "\\([\\]+\\)$" "\\1\\1"))
-	(concat "\"" arg "\""))
-    arg))
+  (cond ((equal arg "") "\"\"")
+	((string-match
+	  (if quote-shell "[ \t\n\r\f*?\"<>|&^%]" "[ \t\n\r\f*?\"]")
+	  arg)
+	 ;; handle nested quotes, possibly preceded by backslashes
+	 (setq arg (replace-in-string arg "\\([\\]*\\)\"" "\\1\\1\\\\\""))
+	 ;; handle trailing backslashes
+	 (setq arg (replace-in-string arg "\\([\\]+\\)$" "\\1\\1"))
+	 (concat "\"" arg "\""))
+	(t arg)))
 
 (defun mswindows-quote-one-simple-arg (arg &optional quote-shell)
   ;; just put double quotes around args with spaces (and maybe shell
   ;; metachars).
-  (if (string-match (if quote-shell "[ \t\n\r\f*?\"<>|&^%]" "[ \t\n\r\f*?]")
-		    arg)
-      (concat "\"" arg "\"")
-    arg))
+  (cond ((equal arg "") "\"\"")
+	((string-match
+	  (if quote-shell "[ \t\n\r\f*?\"<>|&^%]" "[ \t\n\r\f*?]")
+	  arg)
+	 (concat "\"" arg "\""))
+	(t arg)))
 
 (defun mswindows-quote-one-command-arg (arg)
   ;; quote an arg to get it past COMMAND.COM/CMD.EXE: need to quote shell
   ;; metachars with ^.
-  (replace-in-string "[<>|&^%]" "^\\1" arg))
+  (cond ((equal arg "") "\"\"")
+	(t (replace-in-string "[<>|&^%]" "^\\1" arg))))
 
 (defun mswindows-construct-verbatim-command-line (program args)
   (mapconcat #'identity args " "))
@@ -198,7 +225,11 @@
    args " "))
 
 (defvar mswindows-construct-process-command-line-alist
-  '(("[\\/].?.?sh\\." . mswindows-construct-verbatim-command-line)
+  '(
+    ;; at one point (pre-1.0), this was required for Cygwin bash.
+    ;; evidently, Cygwin changed its arg handling to work just like
+    ;; any standard VC program, so we no longer need it.
+    ;;("[\\/].?.?sh\\." . mswindows-construct-verbatim-command-line)
     ("[\\/]command\\.com$" . mswindows-construct-command-command-line)
     ("[\\/]cmd\\.exe$" . mswindows-construct-command-command-line)
     ("" . mswindows-construct-vc-runtime-command-line))
--- a/man/ChangeLog	Thu Jun 07 06:37:25 2001 +0000
+++ b/man/ChangeLog	Fri Jun 08 12:21:27 2001 +0000
@@ -1,3 +1,30 @@
+2001-06-08  Ben Wing  <ben@xemacs.org>
+
+	* xemacs-faq.texi (Top):
+	* xemacs-faq.texi (MS Windows):
+	* xemacs-faq.texi (Q6.2.1):
+	* xemacs-faq.texi (Q6.2.2):
+	* xemacs-faq.texi (Q6.2.3):
+	* xemacs-faq.texi (Q6.2.4):
+	* xemacs-faq.texi (Q6.2.5):
+	* xemacs-faq.texi (Q6.3.1):
+	* xemacs-faq.texi (Q6.3.2):
+	* xemacs-faq.texi (Q6.3.3):
+	* xemacs-faq.texi (Q6.3.4):
+	* xemacs-faq.texi (Q6.4.1):
+	* xemacs-faq.texi (Q6.4.2):
+	* xemacs-faq.texi (Current Events):
+	* xemacs-faq.texi (Q7.0.1):
+	* xemacs-faq.texi (Q7.0.2):
+	* xemacs-faq.texi (Q7.0.3):
+	* xemacs-faq.texi (Q7.0.4):
+	* xemacs-faq.texi (Q7.0.5):
+	* xemacs-faq.texi (Q7.0.6):
+	Merge in the rest of Hrvoje's Windows FAQ.  Redo section 7
+	to update current reality and add condensed versions of
+	new changes for 21.1 and 21.4. (Not quite done for 21.4.)
+	Lots more Windows updates.
+
 2001-05-29  Alexey Mahotkin  <alexm@hsys.msk.ru>
 
 	* xemacs/custom.texi: Documented keyboard shortcut.
--- a/man/xemacs-faq.texi	Thu Jun 07 06:37:25 2001 +0000
+++ b/man/xemacs-faq.texi	Fri Jun 08 12:21:27 2001 +0000
@@ -7,7 +7,7 @@
 @finalout
 @titlepage
 @title XEmacs FAQ
-@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 2001/05/31 12:45:30 $
+@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 2001/06/08 12:21:15 $
 @sp 1
 @author Tony Rossini <rossini@@biostat.washington.edu>
 @author Ben Wing <ben@@xemacs.org>
@@ -378,7 +378,7 @@
 
 General Info:
 * Q6.0.1::      What is the status of the XEmacs port to Windows?
-* Q6.0.2::      What flavors of MS Windows are supported?
+* Q6.0.2::      What flavors of MS Windows are supported?  The list name implies NT only.
 * Q6.0.3::      Are binaries available?
 * Q6.0.4::      Can I build XEmacs on MS Windows with X support?  Do I need to?
 * Q6.0.5::      I'd like to help out.  What do I do?
@@ -398,21 +398,27 @@
 * Q6.2.1::      How does the port cope with differences in the Windows user interface?
 * Q6.2.2::      How do I change fonts in XEmacs on MS Windows?
 * Q6.2.3::      Where do I put my @file{init.el}/@file{.emacs} file?
+* Q6.2.4::      How do I get Windows Explorer to associate a file type with XEmacs?
+* Q6.2.5::      Is it possible to print from XEmacs?
 
 Miscellaneous:
-* Q6.3.1::      Does XEmacs rename all the win32-* symbols to w32-*?
+* Q6.3.1::      Does XEmacs rename all the @samp{win32-*} symbols to @samp{w32-*}?
 * Q6.3.2::      What are the differences between the various MS Windows emacsen?
-* Q6.3.3::      What is the porting team doing at the moment?
+* Q6.3.3::      XEmacs 21.1 on Windows used to spawn an ugly console window on every startup.  Has that been fixed?
+* Q6.3.4::      What is the porting team doing at the moment?
 
 Troubleshooting:
-* Q6.4.1::      XEmacs won't start on Windows. (NEW)
+* Q6.4.1::      XEmacs won't start on Windows.
+* Q6.4.2::      Why do I get a blank toolbar on Windows 95?
+
 
 Current Events:
-
-* Q7.0.1::      What is new in 20.2?
-* Q7.0.2::      What is new in 20.3?
-* Q7.0.3::      What is new in 20.4?
-* Q7.0.4::      Procedural changes in XEmacs development.
+* Q7.0.1::      What new features will be in XEmacs soon?
+* Q7.0.2::      What's new in XEmacs 21.4?
+* Q7.0.3::      What's new in XEmacs 21.1?
+* Q7.0.4::      What's new in XEmacs 20.4?
+* Q7.0.5::      What's new in XEmacs 20.3?
+* Q7.0.6::      What's new in XEmacs 20.2?
 @end detailmenu
 @end menu
 
@@ -5854,17 +5860,16 @@
 port of XEmacs.
 
 @menu
-
 General Info
 * Q6.0.1::      What is the status of the XEmacs port to Windows?
-* Q6.0.2::      What flavors of MS Windows are supported?
-* Q6.0.3::      Where are the XEmacs on MS Windows binaries?
+* Q6.0.2::      What flavors of MS Windows are supported?  The list name implies NT only.
+* Q6.0.3::      Are binaries available?
 * Q6.0.4::      Can I build XEmacs on MS Windows with X support?  Do I need to?
 * Q6.0.5::      I'd like to help out.  What do I do?
 * Q6.0.6::      What are Cygwin and MinGW, and do I need them to run XEmacs?
 * Q6.0.7::      What exactly are all the different ways to build XEmacs under Windows?
 
-Building XEmacs on MS Windows
+Building XEmacs on MS Windows:
 * Q6.1.1::      What compiler/libraries do I need to compile XEmacs?
 * Q6.1.2::      How do I compile the native port?
 * Q6.1.3::      What do I need for Cygwin?
@@ -5873,19 +5878,22 @@
 * Q6.1.6::      I decided to run with X.  Where do I get an X server?
 * Q6.1.7::      How do I compile with X support?
 
-Customization and User Interface
+Customization and User Interface:
 * Q6.2.1::      How does the port cope with differences in the Windows user interface?
 * Q6.2.2::      How do I change fonts in XEmacs on MS Windows?
 * Q6.2.3::      Where do I put my @file{init.el}/@file{.emacs} file?
-
-Miscellaneous
-* Q6.3.1::      Does XEmacs rename all the win32-* symbols to w32-*?
+* Q6.2.4::      How do I get Windows Explorer to associate a file type with XEmacs?
+* Q6.2.5::      Is it possible to print from XEmacs?
+
+Miscellaneous:
+* Q6.3.1::      Does XEmacs rename all the @samp{win32-*} symbols to @samp{w32-*}?
 * Q6.3.2::      What are the differences between the various MS Windows emacsen?
-* Q6.3.3::      What is the porting team doing at the moment?
+* Q6.3.3::      XEmacs 21.1 on Windows used to spawn an ugly console window on every startup.  Has that been fixed?
+* Q6.3.4::      What is the porting team doing at the moment?
 
 Troubleshooting:
-* Q6.4.1::      XEmacs won't start on Windows. (NEW)
-
+* Q6.4.1::      XEmacs won't start on Windows.
+* Q6.4.2::      Why do I get a blank toolbar on Windows 95?
 @end menu
 
 @node Q6.0.1, Q6.0.2, MS Windows, MS Windows
@@ -6190,22 +6198,23 @@
 @unnumberedsec 6.2: Customization and User Interface
 @unnumberedsubsec Q6.2.1: How does the port cope with differences in the Windows user interface?
 
-XEmacs (and Emacs in general) UI is pretty different from what is
-expected of a typical MS Windows program.  How does the MS Windows port
-cope with it?
+The XEmacs (and Emacs in general) user interface is pretty different
+from what is expected of a typical MS Windows program.  How does the MS
+Windows port cope with it?
 
 As a general rule, we follow native MS Windows conventions as much as
-possible.  In cases where there's a clear UI conflict, we currently use
-normal Unix XEmacs behavior by default, but make sure the MS Windows
-"look and feel" (mark via shift-arrow, self-inserting deletes region,
-Alt selects menu items, etc.) is easily configurable (respectively:
-using the variable @code{shifted-motion-keys-select-region} in 21.4 and
-above [it's in fact the default in these versions], or the
-@file{pc-select} package; using the @file{pending-del} package; and
-setting the variable @code{menu-accelerator-enabled} to
-@code{menu-force} in 21.4 and above).  In fact, if you use the sample
-@file{init.el} file as your init file, you will get all these behaviors
-automatically turned on.
+possible.  21.4 is a fairly complete Windows application, supporting
+native printing, system file dialog boxes, tool tips, etc.  In cases
+where there's a clear UI conflict, we currently use normal Unix XEmacs
+behavior by default, but make sure the MS Windows "look and feel" (mark
+via shift-arrow, self-inserting deletes region, Alt selects menu items,
+etc.) is easily configurable (respectively: using the variable
+@code{shifted-motion-keys-select-region} in 21.4 and above [it's in fact
+the default in these versions], or the @file{pc-select} package; using
+the @file{pending-del} package; and setting the variable
+@code{menu-accelerator-enabled} to @code{menu-force} in 21.4 and above).
+In fact, if you use the sample @file{init.el} file as your init file,
+you will get all these behaviors automatically turned on.
 
 In future versions, some of these features might be turned on by
 default in the MS Windows environment.
@@ -6214,8 +6223,8 @@
 @node Q6.2.2, Q6.2.3, Q6.2.1, MS Windows
 @unnumberedsubsec Q6.2.2: How do I change fonts in XEmacs on MS Windows?
 
-In 21.4 and above, use the font menu.  In all versions, you can change
-font manually. For example:
+In 21.4 and above, you can use the "Options" menu to change the font.
+You can also do it in your init file, e.g. like this:
 
 @display
     (set-face-font 'default "Lucida Console:Regular:10")
@@ -6223,40 +6232,115 @@
 @end display
 
 
-@node Q6.2.3, Q6.3.1, Q6.2.2, MS Windows
+@node Q6.2.3, Q6.2.4, Q6.2.2, MS Windows
 @unnumberedsubsec Q6.2.3: Where do I put my @file{init.el}/@file{.emacs} file?
 
 @file{init.el} is the name of the init file starting with 21.4, and is
 located in the subdirectory @file{.xemacs/} of your home directory.  In
 prior versions, the init file is called @file{.emacs} and is located in
 your home directory.  Your home directory under Windows is determined by
-the HOME environment variable.  If this is not set, it defaults to
-`C:\'.
-
-@node Q6.3.1, Q6.3.2, Q6.2.3, MS Windows
+the @samp{HOME} environment variable.  If this is not set, it defaults to
+@samp{C:\}.
+
+To set this variable, modify @file{AUTOEXEC.BAT} under Windows 95/98, or
+select @samp{Control Panel->System->Advanced->Environment Variables...}
+under Windows NT/2000.
+
+
+@node Q6.2.4, Q6.2.5, Q6.2.3, MS Windows
+@unnumberedsubsec Q6.2.4: How do I get Windows Explorer to associate a file type with XEmacs?
+
+@unnumberedsubsubsec Associating a new file type with XEmacs.
+
+In Explorer select @samp{View/Options/File Types}, press @samp{[New
+Type...]} and fill in the dialog box, e.g.:
+
+@example
+        Description of type:    Emacs Lisp source
+        Associated extension:   el
+        Content Type (MIME):    text/plain
+@end example
+
+then press @samp{[New...]} and fill in the @samp{Action} dialog box as
+follows:
+
+@example
+        Action:
+        Open
+
+        Application used to perform action:
+        D:\Full\path\for\xemacs.exe "%1"
+
+        [x] Use DDE
+
+        DDE Message:
+        open("%1")
+
+        Application:
+        <leave blank>
+
+        DDE Application Not Running:
+        <leave blank>
+
+        Topic:
+        <leave blank>
+@end example
+
+@unnumberedsubsubsec Associating an existing file type with XEmacs.
+
+In Explorer select @samp{View/Options/File Types}.  Click on the file
+type in the list and press @samp{[Edit...]}.  If the file type already
+has an @samp{Open} action, double click on it and fill in the
+@samp{Action} dialog box as described above; otherwise create a new
+action.
+
+If the file type has more than one action listed, you probably want to
+make the @samp{Open} action that you just edited the default by clicking on
+it and pressing @samp{Set Default}.
+
+Note for Windows 2000 users: Under Windows 2000, get to @samp{File Types}
+using @samp{Control Panel->Folder Options->File Types}.
+
+
+@node Q6.2.5, Q6.3.1, Q6.2.4, MS Windows
+@unnumberedsubsec Q6.2.5: Is it possible to print from XEmacs?
+
+As of 21.4, printing works on Windows, using simply @samp{File->Print},
+and can be configured with @samp{File->Page Setup}.
+
+Prior to 21.4, there is no built-in support, but there are some clever
+hacks out there.  If you know how, please let us know and we'll put it
+here.
+
+
+@node Q6.3.1, Q6.3.2, Q6.2.5, MS Windows
 @unnumberedsec 6.3: Miscellaneous
-@unnumberedsubsec Q6.3.1: Does XEmacs rename all the win32-* symbols to w32-*?
-
-In his flavor of Emacs 20, Richard Stallman has renamed all the win32-*
-symbols to w32-*.  Does XEmacs do the same?
-
-We consider such a move counter-productive, thus we will not use the
-`w32' prefix.  However, we do recognize that Win32 name is little more
-than a marketing buzzword (will it be Win64 in the next release?), so
-we decided not to use it.  Using `windows-' would be wrong because the
-term is too generic, which is why we settled on a compromise
-`mswindows' term.
-
-Thus all the XEmacs variables and functions directly related to Win32
-are prefixed `mswindows-'.  The user-variables shared with NT Emacs
-will be provided as compatibility aliases.
-
-Architectural note: We believe that there should be a very small number
-of window-systems-specific variables, and we provide generic interfaces
-whenever possible.  Thus, most of the equivalents of GNU Emacs `w32-*'
-functions and variables (as well as the corresponding `x-*' versions)
-are non-window-system-specific in XEmacs, and the issue of `mswindows-*'
-vs. `w32-*' does not come up much.
+@unnumberedsubsec Q6.3.1: Does XEmacs rename all the @samp{win32-*} symbols to @samp{w32-*}?
+
+In his flavor of Emacs 20, Richard Stallman has renamed all the @samp{win32-*}
+symbols to @samp{w32-*}.  Does XEmacs do the same?
+
+We consider such a move counter-productive, thus we do not use the
+@samp{w32} prefix. (His rather questionable justification was that he
+did not consider Windows to be a "winning" platform.) However, the name
+@samp{Win32} is not particularly descriptive outside the Windows world,
+and using just @samp{windows-} would be too generic.  So we chose a
+compromise, the prefix @samp{mswindows-} for Windows-related variables
+and functions.
+
+Thus all the XEmacs variables and functions directly related to either
+the Windows GUI or OS are prefixed @samp{mswindows-} (except for a
+couple of debugging variables, prefixed @samp{debug-mswindows-}).  From
+an architectural perspective, however, we believe that this is mostly a
+non-issue because there should be a very small number of
+window-systems-specific variables anyway.  Whenever possible, we try to
+provide generic interfaces that apply to all window systems.
+
+@c not true:
+@c The user variables
+@c that share functionality with existing NT Emacs variables are be named
+@c with our convention, but we provide the GNU Emacs names as
+@c compatibility aliases.
 
 
 @node Q6.3.2, Q6.3.3, Q6.3.1, MS Windows
@@ -6278,7 +6362,7 @@
 Beginning with XEmacs 19.12, XEmacs' architecture was redesigned
 in such a way to allow clean support of multiple window systems.  At
 this time the TTY support was added, making X and TTY the first two
-"window systems" XEmacs supported.  The 19.12 design is the basis for
+"window systems" supported by XEmacs.  The 19.12 design is the basis for
 the current native MS Windows code.
 
 @item
@@ -6293,9 +6377,9 @@
 support for menubars, subprocesses and network, as well as loads of
 other code), Andy Piper (ported XEmacs to Cygwin environment,
 contributed Windows unexec, Windows-specific glyphs and toolbars code,
-and more), Ben Wing (loads of improvements; currently the most active MS
-Windows developer), Jeff Sparkes (contributed scrollbars support) and
-many others.
+and more), Ben Wing (loads of improvements; primary MS Windows developer
+since 2000), Jeff Sparkes (contributed scrollbars support) and many
+others.
 @end itemize
 
 @item
@@ -6314,7 +6398,7 @@
 @iftex
 @*
 @end iftex
-@uref{http://www.cs.washington.edu/homes/voelker/ntemacs.html}.
+@uref{http://www.gnu.org/software/emacs/windows/ntemacs.html}.
 @end itemize
 
 @item
@@ -6336,9 +6420,9 @@
 
 @item
 GNU Emacs features support for MS-DOS and DJGPP (D.J. Delorie's DOS
-port of Gcc).  Such an Emacs is heavily underfeatured, because it does
+port of GCC).  Such an Emacs is heavily underfeatured, because it does
 not support long file names, lacks proper subprocesses support, and
-is far too big compared to typical DOS editors.
+is far too big compared with typical DOS editors.
 @end itemize
 
 @item
@@ -6349,16 +6433,67 @@
 @item
 Starting with version 19.30, it has been possible to compile GNU Emacs
 under MS Windows using the DJGPP compiler and X libraries.  The result
-is is very similar to GNU Emacs compiled under MS DOS, only it
-supports longer file names, etc.  This "port" is similar to the "X"
-flavor of XEmacs on MS Windows.
+is very similar to GNU Emacs compiled under MS DOS, only it works
+somewhat better because it runs in 32-bit mode, makes use of all the
+system memory, supports long file names, etc.
 @end itemize
 
 @end itemize
 
 
-@node Q6.3.3, Q6.4.1, Q6.3.2, MS Windows
-@unnumberedsubsec Q6.3.3: What is the porting team doing at the moment?
+@node Q6.3.3, Q6.3.4, Q6.3.2, MS Windows
+@unnumberedsubsec Q6.3.3: XEmacs 21.1 on Windows used to spawn an ugly console window on every startup.  Has that been fixed?
+
+Yes.
+
+The console was there because @file{temacs} (and in turn, @file{xemacs})
+was a console application, and Windows typically creates a new
+console for a console process unless the creating process requests that
+one isn't created.  This used to be fixed with @file{runemacs}, a small
+Windows application that existed merely to start @file{xemacs}, stating
+that it didn't want a console.
+
+XEmacs 21.4 fixes this cleanly by the virtue of being a true "GUI"
+application.  The explanation of what that means is included for
+educational value.
+
+When building an application to be run in a Win32 environment, you must
+state which sub-system it is to run in.  Valid subsystems include
+"console" and "gui".  The subsystem you use affects the run time
+libraries linked into your application, the start up function that is
+run before control is handed over to your application, the entry point
+to your program, and how Windows normally invokes your program. (Console
+programs automatically get a console created for them at startup if
+their stdin/stdout don't point anywhere useful, which is the case when
+run from the GUI.  This is a stupid design, of course -- instead, the
+console should get created only when the first I/O actually occurs!
+GUI programs have an equally stupid design: When called from
+@file{CMD.EXE}/@file{COMMAND.COM}, their stdin/stdout will be set to
+point nowhere useful, even though the command shell has its own
+stdin/stdout.  It's as if someone who had learned a bit about stdio but
+had no actual knowledge of interprocess communication designed the
+scheme; unfortunately, the whole process-communication aspect of the
+Win32 API is equally badly designed.) For example, the entry point for a
+console app is "main" (which is what you'd expect for a C/C++ program),
+but the entry point for a "gui" app is "WinMain".  This confuses and
+annoys a lot of programmers who've grown up on Unix systems, where the
+kernel doesn't really care whether your application is a gui program or
+not.
+
+For reasons not altogether clear, and are lost in the mists of time and
+tradition, XEmacs on Win32 started out as a console application, and
+therefore a console was automatically created for it. (It may have been
+made a console application partly because a console is needed in some
+circumstances, especially under Win95, to interrupt, terminate, or send
+signals to a child process, and because of the bogosity mentioned above
+with GUI programs and the standard command shell.  Currently, XEmacs
+just creates and immediately hides a console when necessary, and
+works around the "no useful stdio" problem by creating its own console
+window as necessary to display messages in.)
+
+
+@node Q6.3.4, Q6.4.1, Q6.3.3, MS Windows
+@unnumberedsubsec Q6.3.4: What is the porting team doing at the moment?
 
 (as of June 2001)
 
@@ -6369,9 +6504,10 @@
 elements).
 
 
-@node Q6.4.1, ,Q6.3.3, MS Windows
+
+@node Q6.4.1, Q6.4.2, Q6.3.4, MS Windows
 @unnumberedsec 6.3: Troubleshooting
-@unnumberedsubsec Q6.4.1 XEmacs won't start on Windows. (NEW)
+@unnumberedsubsec Q6.4.1 XEmacs won't start on Windows.
 
 XEmacs relies on a process called "dumping" to generate a working
 executable. Under MS-Windows this process effectively fixes the memory
@@ -6390,39 +6526,313 @@
 binaries, but you can use the 21.1 binaries if you are very paranoid
 about stability.  @xref{Q6.0.3}.
 
+@node Q6.4.2, , Q6.4.1, MS Windows
+@unnumberedsubsec Q6.4.2 Why do I get a blank toolbar on Windows 95?
+
+You need at least version 4.71 of the system file @file{comctl32.dll}.
+The updated version is supplied with Internet Explorer 4 and later but if
+you are avoiding IE you can also download it from the Microsoft web
+site.  Go into support and search for @file{comctl32.dll}.  The download
+is a self-installing executable.
+
+
 
 @node Current Events,  , MS Windows, Top
 @unnumbered 7 What the Future Holds
 
 This is part 7 of the XEmacs Frequently Asked Questions list.  This
-section will change monthly, and contains any interesting items that have
-transpired over the previous month.  If you are reading this from the
-XEmacs distribution, please see the version on the Web or archived at the
-various FAQ FTP sites, as this file is surely out of date.
+section will change frequently, and (in theory) should contain any
+interesting items that have transpired recently. (But in practice it's
+not getting updated like this.)
+
+This section also contains descriptions of the new features in all the
+recent releases of XEmacs.  For the most part, the information below is
+a synopsis of the more complete information that can be found in the
+file @file{NEWS} in the @file{etc} directory of the XEmacs distribution.
+You can view this file in XEmacs using @kbd{C-h n} or the @samp{Help}
+menu.
+
+Information on older versions of XEmacs can be find in @file{ONEWS} in
+the same directory, or @file{OONEWS} for really old versions.
+
 
 @menu
-* Q7.0.1::      What is new in 20.2?
-* Q7.0.2::      What is new in 20.3?
-* Q7.0.3::      What is new in 20.4?
-* Q7.0.4::      Procedural changes in XEmacs development.
+* Q7.0.1::      What new features will be in XEmacs soon?
+* Q7.0.2::      What's new in XEmacs 21.4?
+* Q7.0.3::      What's new in XEmacs 21.1?
+* Q7.0.4::      What's new in XEmacs 20.4?
+* Q7.0.5::      What's new in XEmacs 20.3?
+* Q7.0.6::      What's new in XEmacs 20.2?
 @end menu
 
 @node Q7.0.1, Q7.0.2, Current Events, Current Events
 @unnumberedsec 7.0: Changes
-@unnumberedsubsec Q7.0.1: What is new in 20.2?
-
-The biggest changes in 20.2 include integration of EFS (the next
-generation of ange-ftp) and AUC Tex (the Emacs subsystem that includes a
-major mode for editing Tex and LaTeX, and a lot of other stuff).  Many
-bugs from 20.0 have been fixed for this release.  20.2 also contains a
-new system for customizing XEmacs options, invoked via @kbd{M-x
-customize}.
-
-XEmacs 20.2 is the development release (20.0 was beta), and is no longer
-considered unstable.
+@unnumberedsubsec Q7.0.1: What new features will be in XEmacs soon?
+
+Not yet written.
 
 @node Q7.0.2, Q7.0.3, Q7.0.1, Current Events
-@unnumberedsubsec Q7.0.2: What is new in 20.3?
+@unnumberedsubsec Q7.0.2: What's new in XEmacs 21.4?
+
+21.4 was the "stable" version of the 21.2 series, which was considered
+"experimental" throughout its life; thus there were no "official"
+releases at all.  In essence, XEmacs is now following the "alternating"
+scheme of Linux, where at any point there are at least two different
+development branches, one "stable" and one "experimental".  Periodic
+releases happen in both branches, but those in the experimental branch
+are not tested as well, and there's no guarantee they will work at all.
+The experiemental branch is open to any and all code that's acceptable
+to the developers; the stable branch, however, is in general limited
+only to bug fixes, and all contributions are carefully reviewed to make
+sure they will increase and not decrease stability.
+
+21.3 never existed at all; it was decided to follow the Linux scheme
+exactly, where odd-numbered series are experimental and even-numbered
+ones stable.
+
+The following lists summarizes the essential changes made in this
+version.  For a fuller list, see the @file{NEWS} in the @file{etc}
+directory of the XEmacs distribution, or use @kbd{C-h n} or the
+@samp{Help} menu to view this file inside of XEmacs.
+
+@unnumberedsubsubsec User-visible changes
+
+@itemize @bullet
+
+@item
+The delete key now deletes forward by default.
+@item
+Shifted motion keys now select text by default.
+@item
+You can now build XEmacs with support for GTK+ widget set.
+@item
+~/.xemacs/init.el is now the preferred location for the init
+file. (XEmacs now supports a `~/.xemacs/init.el' startup file. Custom
+file will move to ~/.xemacs/custom.el.)
+@item
+Much-improved sample init.el, showing how to use many useful features.
+@item
+XEmacs support for menu accelerators has been much improved.
+@item
+Default menubar improvements. (Default menubar has many new commands and
+better organization.  The font-menu is now available under MS Windows.)
+@item
+Dialog box improvements, including a real file dialog box. (XEmacs now has a proper file dialog box under MS Windows (and GTK)!  The old clunky file dialog box is improved.  Keyboard traversal now works correctly in MS Windows dialog boxes.  There is a Search dialog box available from Edit->Find...)
+@item
+New buffer tabs.
+@item
+There is a new MS Windows installer, netinstall, ported from Cygwin.
+@item
+The subprocess quote-handling mechanism under Windows is much improved.
+@item
+Printing support now available under MS Windows.
+@item
+Selection improvements. (Kill and yank now interact with the clipboard under Windows.  MS Windows support for selection is now much more robust.  Motif selection support is now more correct (but slower).)
+@item
+Mail spool locking now works correctly.
+@item
+International support changes. (The default coding-priority-list is now
+safer.  International keysyms are now supported under X.  MS Windows
+1251 code page now supported.  Czech, Thai, Cyrillic-KOI8, Vietnamese,
+Ethiopic now supported.  Proper support for words in Latin 3 and Latin
+4.)
+@item
+Help buffers contain hyperlinks, and other changes.
+@item
+The modeline's text is now scrollable.
+@item
+The mouse wheel under MS Windows now functions correctly.
+@item
+Interactive searching and matching case improvements. (Incremental search will now highlight all visible matches.  Interactive searches always respect uppercase characters.)
+@item
+Rectangle functions rewritten to avoid inserting extra spaces.
+@item
+New command `kill-entire-line' that always kills the entire line.
+@item
+Default values correctly stored in minibuffer histories.
+@item
+You can now create "indirect buffers", like in GNU Emacs.
+@item
+Pixel-based scrolling has been implemented.
+@item
+Operation progress can be displayed using graphical widgets.
+@item
+User names following a tilde can now be completed at file name prompts.
+@item
+XEmacs can now play sound using Enlightenment Sound Daemon (ESD).
+@item
+X-Face support is now available under MS Windows.
+@item
+The PostgreSQL Relational Database Management System is now supported.
+@item
+Indentation no longer indents comments that begin at column zero.
+@item
+Face and variable settings can have comments in Customize.
+@item
+New locations for early package hierarchies.
+@item
+The `auto-save' library has been greatly improved.
+@item
+New variable `mswindows-alt-by-itself-activates-menu'.
+@item
+Other init-file-related changes. (Init file in your home directory may be called `.emacs.el'.  New command-line switches -user-init-file and -user-init-directory.)
+@item
+Etags changes.  See @file{NEWS} for full details.
+@end itemize
+
+@unnumberedsubsubsec Lisp and internal changes
+
+Not yet written.
+
+@itemize @bullet
+@end itemize
+
+@node Q7.0.3, Q7.0.4, Q7.0.2, Current Events
+@unnumberedsubsec Q7.0.3: What's new in XEmacs 21.1?
+
+21.1 was the "stable" version of "experimental" 21.0 series.
+@xref{Q7.0.2}.
+
+The following lists summarizes the essential changes made in this
+version.  For a fuller list, see the @file{NEWS} in the @file{etc}
+directory of the XEmacs distribution, or use @kbd{C-h n} or the
+@samp{Help} menu to view this file inside of XEmacs.
+
+@unnumberedsubsubsec User-visible changes
+
+@itemize @bullet
+
+@item
+XEmacs is now supported under Microsoft Windows 95/98 and Windows NT
+operating systems.  To discuss Windows-specific issues, subscribe to the
+mailing list at @email{xemacs-nt-request@@xemacs.org}.
+
+@item
+XEmacs has been unbundled into constituent installable packages.
+
+@item
+@strong{Other notable changes}: The @samp{Options} menu has been ported to
+Custom; XEmacs now is able to choose X visuals and use private
+colormaps; You can drag the vertical divider of "horizontally"
+(side-by-side) split windows.
+
+@item
+@strong{Building changes}: XEmacs can be built with support for 31-bit Lisp
+integers and 32-bit pointers (previously, it was 28-bit integers and
+pointers); XEmacs can be built with LDAP support; @file{dir} files can be
+removed in the Info subsystem, and will be regenerated on-the-fly.
+
+@item
+@strong{New packages}: @file{imenu}, @file{popper}, @file{gdb-highlight}
+
+@item
+@strong{Package changes}: Many changes to @file{cc-mode}, @file{gnus},
+@file{gnuclient}.  See @file{NEWS} for full details.
+
+@item
+@strong{New commands, variables and functions}:
+@code{center-to-window-line} (like @code{recenter} but doesn't force a
+redisplay); variable @code{user-full-name} (customize what your full
+name looks like in mail); @kbd{M-x customize-changed-options} (customize
+options whose default values changes because you upgraded your XEmacs);
+@kbd{M-x add-log-convert} (converts an old-style ChangeLog buffer to
+new-style); @kbd{M-x zap-up-to-char} (like @code{zap-to-char} but
+doesn't delete the char searched for); commands to store, retrieve and
+increment numbers in registers, useful for macros.
+
+@item
+@strong{Changes to commands, variables, and functions}: @kbd{M-x
+query-replace} and friends operate only on the region when it's active;
+@code{echo-keystrokes} can now be a floating-point number; @kbd{M-.}
+searches exact tag matches before inexact ones; function
+@code{user-full-name} with no arguments returns the var
+@code{user-full-name}; a prefix arg to @kbd{M-:} and @kbd{C-h c} inserts
+the result in the current buffer.
+ 
+@item
+@strong{Other changes}: Under X, new application class @samp{XEmacs};
+byte-compilation of user-specs now works.
+
+@item
+@strong{XEmacs/Mule (internationalization) changes}: Mule support now
+works on TTY's; Egg/SJ3 input method now officially supported (Quail and
+Egg/Skk already available through LEIM since 20.3); localized Japanese
+menubars if XEmacs is built with the right support.
+
+@end itemize
+
+@unnumberedsubsubsec Lisp and internal changes
+
+@itemize @bullet
+
+@item
+@strong{Specifier changes}: The window locale now has a higher
+precedence than the buffer locale when instantiating; new macro
+@code{let-specifier}; new specifiers
+@code{vertical-scrollbar-visible-p}, horizontal-scrollbar-visible-p',
+@code{scrollbar-on-left-p}, @code{scrollbar-on-top-p},
+@code{vertical-divider-always-visible-p},
+@code{vertical-divider-shadow-thickness},
+@code{vertical-divider-line-width}, @code{vertical-divider-spacing};
+specifiers and symbols whose value is a specifier allowed as modeline
+specifications.
+
+@item
+@strong{Frame focus changes}: @code{focus-follows-mouse} works like FSF,
+prevents any attempt to permanently change the selected frame; new
+function @code{focus-frame} sets the window system focus a frame; new
+special forms @code{save-selected-frame} and @code{with-selected-frame}.
+
+@item
+@strong{Window function changes}: @code{select-window} now has optional
+argument @var{NORECORD} to inhibit recording a buffer change;
+@code{vertical-motion} now correctly handles optional @var{WINDOW}
+argument and has new optional argument @var{PIXELS}, to have the
+returned values be in pixels; new function
+@code{vertical-motion-pixels}; new functions
+@code{window-text-area-pixel-@{width,height,edges@}}; new functions
+@code{shrink-window-pixels} and @code{enlarge-window-pixels}; new
+function @code{window-displayed-text-pixel-height}.
+
+@item
+@strong{Other function changes}: Arithmetic comparison functions
+@code{<}, @code{>}, @code{=}, @code{/=} now accept a variable number of
+arguments; hashtables now have a consistent read/print syntax; keyword
+symbols cannot be set to a value other than themselves; @code{concat} no
+longer accepts integer arguments; new function @code{string}, like
+@code{list}, @code{vector}, etc.; new function @code{temp-directory}
+(OS-independent way to get a temp directory); @code{load-average} has
+optional argument @var{USE-FLOATS}; @code{make-event} implemented
+completely; new function @code{function-interactive} (returns a
+function's interactive spec); new functions @code{lmessage},
+@code{lwarn} (printf-like versions of @code{display-wessage},
+@code{display-warning}); new keyword @code{:version} to
+@code{defcustom}.
+
+@item
+@strong{Performance}: when the new GNU Malloc aka Doug Lea Malloc is
+available, it will be used (better performance on libc6 Linux systems);
+tracking line-numbers in modeline is now efficient; profiling records a
+call-count of all called functions, retrievable through
+@code{profile-call-count-results}.
+
+@item
+@strong{Startup and path searching}: code to assemble paths at startup
+rewritten for new package system; new function @code{split-path} (splits
+by @code{path-separator}); @code{Info-default-directory-list} obsolete,
+use @code{Info-directory-list} instead; site-lisp is deprecated and no
+longer on the load-path by default.
+
+@end itemize
+
+@node Q7.0.4, Q7.0.5, Q7.0.3, Current Events
+@unnumberedsubsec Q7.0.4: What's new in XEmacs 20.4?
+
+XEmacs 20.4 is a bugfix release with no user-visible changes.
+@c Filled in from NEWS file of 20.5-b33
+
+@node Q7.0.5, Q7.0.6, Q7.0.4, Current Events
+@unnumberedsubsec Q7.0.5: What's new in XEmacs 20.3?
 
 XEmacs 20.3 was released in November 1997. It contains many bugfixes,
 and a number of new features, including Autoconf 2 based configuration,
@@ -6441,45 +6851,20 @@
 XEmacs 20.3 is the first non-beta v20 release, and will be the
 basis for all further development.
 
-@node Q7.0.3, Q7.0.4, Q7.0.2, Current Events
-@unnumberedsubsec Q7.0.3: What's new in XEmacs 20.4?
-
-XEmacs 20.4 is a bugfix release with no user-visible changes.
-@c Filled in from NEWS file of 20.5-b33
-
-
-@node Q7.0.4,  , Q7.0.3, Current Events
-@unnumberedsubsec Q7.0.4: Procedural changes in XEmacs development.
-
-@enumerate
-@item
-Discussion about the development of XEmacs occurs on the xemacs-beta
-mailing list.  Subscriptions to this list will now be fully automated
-instead of being handled by hand.  Send a mail message to
-@email{xemacs-beta-request@@xemacs.org} with @samp{subscribe} as the
-BODY of the message to join the list.  Please note this is a developers
-mailing list for people who have an active interest in the development
-process.
-
-The discussion of NT XEmacs development is taking place on a separate
-mailing list.  Send mail to
-@iftex
-@*
-@end iftex
-@email{xemacs-nt-request@@xemacs.org} to
-subscribe.
-
-@item
-Due to the long development cycle in between releases, it has been
-decided that intermediate versions will be made available in source only
-form for the truly interested.
-
-XEmacs 19.16 was the last 19 release, basically consisting of 19.15 plus
-the collected bugfixes.
-
-@item
-As of December 1996, @email{steve@@xemacs.org, Steve Baur} has become
-the lead maintainer of XEmacs.
-@end enumerate
+@node Q7.0.6, , Q7.0.5, Current Events
+@unnumberedsubsec Q7.0.6: What's new in XEmacs 20.2?
+
+The biggest changes in 20.2 include integration of EFS (the next
+generation of ange-ftp) and AUC Tex (the Emacs subsystem that includes a
+major mode for editing Tex and LaTeX, and a lot of other stuff).  Many
+bugs from 20.0 have been fixed for this release.  20.2 also contains a
+new system for customizing XEmacs options, invoked via @kbd{M-x
+customize}.
+
+XEmacs 20.2 is the development release (20.0 was beta), and is no longer
+considered unstable.
+
+For older news, see the file @file{ONEWS} in the @file{etc} directory of
+the XEmacs distribution.
 
 @bye
--- a/src/ChangeLog	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/ChangeLog	Fri Jun 08 12:21:27 2001 +0000
@@ -1,3 +1,106 @@
+2001-06-08  Ben Wing  <ben@xemacs.org>
+
+	------ gc-in-window-procedure fixes ------
+	
+	* alloc.c:
+	* alloc.c (struct post_gc_action):
+	* alloc.c (register_post_gc_action):
+	* alloc.c (run_post_gc_actions):
+	* alloc.c (garbage_collect_1):
+	Create "post-gc actions", to avoid those dreaded "GC during window
+	procedure" problems.
+
+	* event-msw.c:
+	Abort, clean and simple, when GC in window procedure.  We want
+	to flush these puppies out.
+
+	* glyphs-msw.c:
+	* glyphs-msw.c (finalize_destroy_window):
+	* glyphs-msw.c (mswindows_finalize_image_instance):
+	Use a post-gc action when destroying subwindows.
+
+	* lisp.h:
+	Declare register_post_gc_action().
+
+	* scrollbar-msw.c:
+	* scrollbar-msw.c (unshow_that_mofo):
+	Use a post-gc action when unshowing scrollbar windows, if in gc.
+
+	* redisplay.c (mark_redisplay):
+	Add comment about the utter evilness of what's going down here.
+
+	------ cygwin setitimer fixes ------
+	
+	* Makefile.in.in (sheap_objs):
+	* Makefile.in.in (profile_objs):
+	* Makefile.in.in (objs):
+	Compile profile.c only when HAVE_SETITIMER.
+	
+	* nt.c (mswindows_sigset):
+	* nt.c (mswindows_sighold):
+	* nt.c (mswindows_sigrelse):
+	* nt.c (mswindows_sigpause):
+	* nt.c (mswindows_raise):
+	* nt.c (close_file_data):
+	Style fixes.
+	
+	* nt.c:
+	Move setitimer() emulation to win32.c, because Cygwin needs it too.
+	
+	* profile.c:
+	* profile.c (Fstart_profiling):
+	* profile.c (Fstop_profiling):
+	Make sure we don't compile if no setitimer().  Use qxe_setitimer()
+	instead of just plain setitimer().
+	
+	* signal.c:
+	* signal.c (set_one_shot_timer):
+	* signal.c (alarm):
+	Define qxe_setitimer() as an encapsulation around setitimer() --
+	call setitimer() directly unless Cygwin or MS Win, in which case
+	we use our simulated version in win32.c.
+	
+	* systime.h:
+	* systime.h (struct itimerval):
+	* systime.h (ITIMER_REAL):
+	Prototype mswindows_setitimer() and qxe_setitimer().  Long
+	comment about "qxe" and the policy regarding encapsulation.
+
+	* win32.c:
+	* win32.c (setitimer_helper_proc):
+	* win32.c (setitimer_helper_period):
+	* win32.c (setitimer_helper):
+	* win32.c (mswindows_setitimer):
+	Move setitimer() emulation here, so Cygwin can use it.
+	Rename a couple of functions and variables to be longer and more
+	descriptive.  In setitimer_helper_proc(), send the signal
+	using either mswindows_raise() or (on Cygwin) kill().  If for
+	some reason we are still getting lockups, we'll change the kill()
+	to directly invoke the signal handlers.
+
+	------ windows shell fixes ------
+	
+	* callproc.c:
+	* ntproc.c:
+	Comments about how these two files must die.
+
+	* callproc.c (init_callproc):
+	On MS Windows, init shell-file-name from SHELL, then COMSPEC,
+	not just COMSPEC. (more correct and closer to FSF.) Don't
+	force a value for SHELL into the environment. (Comments added
+	to explain why not.)
+	
+	* nt.c (init_user_info):
+	Don't shove a fabricated SHELL into the environment.  See above.
+
+	------ misc fixes ------
+
+	* glyphs-shared.c (read_bitmap_data): static.
+	* glyphs-shared.c (read_bitmap_data_from_file):
+	Style correction.
+	
+	
+
 2001-06-06  Ben Wing  <ben@xemacs.org>
 
 	* emodules.c (emodules_load):
--- a/src/Makefile.in.in	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/Makefile.in.in	Fri Jun 08 12:21:27 2001 +0000
@@ -141,6 +141,10 @@
 win32_objs=win32.o xemacs_res.o
 #endif
 
+#ifdef HAVE_SETITIMER
+profile_objs=profile.o
+#endif
+
 ## -Demacs is needed to make some files produce the correct version
 ## for use in Emacs.
 
@@ -194,7 +198,7 @@
  gui.o gutter.o $(gui_objs) hash.o imgproc.o indent.o insdel.o intl.o\
  keymap.o $(RTC_patch_objs) line-number.o lread.o lstream.o\
  macros.o marker.o md5.o minibuf.o objects.o opaque.o\
- print.o process.o profile.o\
+ print.o process.o $(profile_objs)\
  rangetab.o redisplay.o redisplay-output.o regex.o\
  search.o select.o $(sheap_objs) signal.o sound.o\
  specifier.o strftime.o symbols.o syntax.o sysdep.o\
--- a/src/alloc.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/alloc.c	Fri Jun 08 12:21:27 2001 +0000
@@ -3240,6 +3240,61 @@
 /* Maybe we want to use this when doing a "panic" gc after memory_full()? */
 static int gc_hooks_inhibited;
 
+struct post_gc_action
+{
+  void (*fun) (void *);
+  void *arg;
+};
+
+typedef struct post_gc_action post_gc_action;
+
+typedef struct
+{
+  Dynarr_declare (post_gc_action);
+} post_gc_action_dynarr;
+
+static post_gc_action_dynarr *post_gc_actions;
+
+/* Register an action to be called at the end of GC.
+   gc_in_progress is 0 when this is called.
+   This is used when it is discovered that an action needs to be taken,
+   but it's during GC, so it's not safe. (e.g. in a finalize method.)
+
+   As a general rule, do not use Lisp objects here.
+   And NEVER signal an error.
+*/
+
+void
+register_post_gc_action (void (*fun) (void *), void *arg)
+{
+  post_gc_action action;
+
+  if (!post_gc_actions)
+    post_gc_actions = Dynarr_new (post_gc_action);
+
+  action.fun = fun;
+  action.arg = arg;
+
+  Dynarr_add (post_gc_actions, action);
+}
+
+static void
+run_post_gc_actions (void)
+{
+  int i;
+
+  if (post_gc_actions)
+    {
+      for (i = 0; i < Dynarr_length (post_gc_actions); i++)
+	{
+	  post_gc_action action = Dynarr_at (post_gc_actions, i);
+	  (action.fun) (action.arg);
+	}
+
+      Dynarr_reset (post_gc_actions);
+    }
+}
+
 
 void
 garbage_collect_1 (void)
@@ -3455,6 +3510,8 @@
 
   gc_in_progress = 0;
 
+  run_post_gc_actions ();
+
   /******* End of garbage collection ********/
 
   run_hook_trapping_errors ("Error in post-gc-hook", Qpost_gc_hook);
--- a/src/callproc.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/callproc.c	Fri Jun 08 12:21:27 2001 +0000
@@ -1,4 +1,4 @@
-/* Synchronous subprocess invocation for XEmacs.
+/* Old synchronous subprocess invocation for XEmacs.
    Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc.
 
 This file is part of XEmacs.
@@ -21,6 +21,16 @@
 /* Synched up with: Mule 2.0, FSF 19.30. */
 /* Partly sync'ed with 19.36.4 */
 
+
+/* #### This ENTIRE file is only used in batch mode.
+
+   We only need two things to get rid of both this and ntproc.c:
+
+   -- my `stderr-proc' ws, which adds support for a separate stderr
+      in asynch. subprocesses. (it's a feature in `old-call-process-internal'.)
+   -- a noninteractive event loop that supports processes.
+*/
+
 #include <config.h>
 #include "lisp.h"
 
@@ -879,13 +889,40 @@
   {
     /* Initialize shell-file-name from environment variables or best guess. */
 #ifdef WIN32_NATIVE
-    const char *shell = egetenv ("COMSPEC");
-    if (!shell) shell = "\\WINNT\\system32\\cmd.exe";
+    const char *shell = egetenv ("SHELL");
+    if (!shell) shell = egetenv ("COMSPEC");
+    /* Should never happen! */
+    if (!shell) shell = (GetVersion () & 0x80000000 ? "command" : "cmd");
 #else /* not WIN32_NATIVE */
     const char *shell = egetenv ("SHELL");
     if (!shell) shell = "/bin/sh";
 #endif
 
+#if 0 /* defined (WIN32_NATIVE) */
+    /* BAD BAD BAD.  We do not wanting to be passing an XEmacs-created
+       SHELL var down to some inferior Cygwin process, which might get
+       screwed up.
+	 
+       There are a few broken apps (eterm/term.el, eterm/tshell.el,
+       os-utils/terminal.el, texinfo/tex-mode.el) where this will
+       cause problems.  Those broken apps don't look at
+       shell-file-name, instead just at explicit-shell-file-name,
+       ESHELL and SHELL.  They are apparently attempting to borrow
+       what `M-x shell' uses, but that latter also looks at
+       shell-file-name.  What we want is for all of these apps to look
+       at shell-file-name, so that the user can change the value of
+       shell-file-name and everything will work out hunky-dorey.
+       */
+    
+    if (!egetenv ("SHELL"))
+      {
+	CBufbyte *faux_var = alloca_array (CBufbyte, 7 + strlen (shell));
+	sprintf (faux_var, "SHELL=%s", shell);
+	Vprocess_environment = Fcons (build_string (faux_var),
+				      Vprocess_environment);
+      }
+#endif /* 0 */
+
     Vshell_file_name = build_string (shell);
   }
 }
--- a/src/event-msw.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/event-msw.c	Fri Jun 08 12:21:27 2001 +0000
@@ -2061,13 +2061,9 @@
   struct frame *frame;
   struct mswindows_frame* msframe;
 
-  /* Not perfect but avoids crashes. There is potential for wierd
-     behavior here. */
-  if (gc_in_progress)
-    {
-      stderr_out ("Window procedure called during GC???????\n");
-      goto defproc;
-    }
+  /* If you hit this, rewrite the offending API call to occur after GC,
+     using register_post_gc_action(). */
+  assert (!gc_in_progress);
 
 #ifdef DEBUG_XEMACS
   if (debug_mswindows_events)
--- a/src/glyphs-msw.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/glyphs-msw.c	Fri Jun 08 12:21:27 2001 +0000
@@ -1778,6 +1778,12 @@
 #endif
 
 static void
+finalize_destroy_window (void *win)
+{
+  DestroyWindow ((HWND) win);
+}
+
+static void
 mswindows_finalize_image_instance (Lisp_Image_Instance *p)
 {
   if (!p->data)
@@ -1794,8 +1800,14 @@
 #endif
 	  if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
 	    {
-	      DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p));
-	      DestroyWindow (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p));
+	      /* DestroyWindow is not safe here, as it will send messages
+		 to our window proc. */
+	      register_post_gc_action
+		(finalize_destroy_window,
+		 (void *) (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)));
+	      register_post_gc_action
+		(finalize_destroy_window,
+		 (void *) (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p)));
 	      IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0;
 	    }
 	}
--- a/src/glyphs-shared.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/glyphs-shared.c	Fri Jun 08 12:21:27 2001 +0000
@@ -187,9 +187,10 @@
  * its arguments won't have been touched.  This routine should look as much
  * like the Xlib routine XReadBitmapfile as possible.
  */
-int read_bitmap_data (FILE* fstream, unsigned int *width,
-		      unsigned int *height, UChar_Binary **datap,
-		      int *x_hot, int *y_hot)
+static int
+read_bitmap_data (FILE *fstream, unsigned int *width,
+		  unsigned int *height, UChar_Binary **datap,
+		  int *x_hot, int *y_hot)
 {
     UChar_Binary *data = NULL;		/* working variable */
     char line[MAX_SIZE];		/* input line from file */
@@ -311,12 +312,13 @@
 }
 
 
-int read_bitmap_data_from_file (const char *filename,
-			       /* Remaining args are RETURNED */
-			       unsigned int *width,
-			       unsigned int *height,
-			       UChar_Binary **datap,
-			       int *x_hot, int *y_hot)
+int
+read_bitmap_data_from_file (const char *filename,
+			    /* Remaining args are RETURNED */
+			    unsigned int *width,
+			    unsigned int *height,
+			    UChar_Binary **datap,
+			    int *x_hot, int *y_hot)
 {
     FILE *fstream;
     int status;
--- a/src/lisp.h	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/lisp.h	Fri Jun 08 12:21:27 2001 +0000
@@ -2158,6 +2158,8 @@
 
 extern Lisp_Object_ptr_dynarr *staticpros;
 
+void register_post_gc_action (void (*fun) (void *), void *arg);
+
 /* Call staticpro (&var) to protect static variable `var'. */
 void staticpro (Lisp_Object *);
 
--- a/src/nt.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/nt.c	Fri Jun 08 12:21:27 2001 +0000
@@ -1,4 +1,4 @@
-/* Utility and Unix shadow routines for XEmacs on Windows NT.
+/* Utility and Unix shadow routines for XEmacs on MS Windows.
    Copyright (C) 1994, 1995 Free Software Foundation, Inc.
 
 This file is part of XEmacs.
@@ -248,12 +248,12 @@
   if (getenv ("HOME") == NULL)
     putenv ("HOME=c:/");
 #endif
-  if (getenv ("SHELL") == NULL)
-    putenv ((GetVersion () & 0x80000000) ? "SHELL=command" : "SHELL=cmd");
 
-  /* Set dir and shell from environment variables. */
+  /* Set dir from environment variables. */
   strcpy (the_passwd.pw_dir, (char *)get_home_directory());
-  strcpy (the_passwd.pw_shell, getenv ("SHELL"));
+  /* We used to set pw_shell here, but the order is wrong (SHELL gets
+     init in callproc.c, called later in the init process) and pw_shell
+     is not used anywhere. */
 }
 
 /* Normalize filename by converting all path separators to
@@ -1827,7 +1827,8 @@
 /* Signal pending mask: bit set to 1 means sig is pending */
 unsigned signal_pending_mask = 0;
 
-mswindows_sighandler mswindows_sigset (int nsig, mswindows_sighandler handler)
+mswindows_sighandler
+mswindows_sigset (int nsig, mswindows_sighandler handler)
 {
   /* We delegate some signals to the system function */
   if (nsig == SIGFPE || nsig == SIGABRT || nsig == SIGINT)
@@ -1847,40 +1848,43 @@
   }
 }
   
-int mswindows_sighold (int nsig)
+int
+mswindows_sighold (int nsig)
 {
   if (nsig < 0 || nsig > SIG_MAX)
     return errno = EINVAL;
 
-  signal_block_mask |= sigmask(nsig);
+  signal_block_mask |= sigmask (nsig);
   return 0;
 }
 
-int mswindows_sigrelse (int nsig)
+int
+mswindows_sigrelse (int nsig)
 {
   if (nsig < 0 || nsig > SIG_MAX)
     return errno = EINVAL;
 
-  signal_block_mask &= ~sigmask(nsig);
+  signal_block_mask &= ~sigmask (nsig);
 
-  if (signal_pending_mask & sigmask(nsig))
+  if (signal_pending_mask & sigmask (nsig))
     mswindows_raise (nsig);
 
   return 0;
 }
 
-int mswindows_sigpause (int nsig)
+int
+mswindows_sigpause (int nsig)
 {
-  /* This is currently not called, because the only
-     call to sigpause inside XEmacs is with SIGCHLD
-     parameter. Just in case, we put an assert here,
-     so anyone who will add a call to sigpause will
-     be surprised (or surprise someone else...) */
+  /* This is currently not called, because the only call to sigpause
+     inside XEmacs is with SIGCHLD parameter. Just in case, we put an
+     assert here, so anyone adds a call to sigpause will be surprised
+     (or surprise someone else...) */
   assert (0);
   return 0;
 }
 
-int mswindows_raise (int nsig)
+int
+mswindows_raise (int nsig)
 {
   /* We delegate some raises to the system routine */
   if (nsig == SIGFPE || nsig == SIGABRT || nsig == SIGINT)
@@ -1890,9 +1894,9 @@
     return errno = EINVAL;
 
   /* If the signal is blocked, remember to issue later */
-  if (signal_block_mask & sigmask(nsig))
+  if (signal_block_mask & sigmask (nsig))
     {
-      signal_pending_mask |= sigmask(nsig);
+      signal_pending_mask |= sigmask (nsig);
       return 0;
     }
 
@@ -1901,7 +1905,7 @@
 
   if (signal_handlers[nsig] != SIG_DFL)
     {
-      (*signal_handlers[nsig])(nsig);
+      (*signal_handlers[nsig]) (nsig);
       return 0;
     }
 
@@ -1913,122 +1917,6 @@
   return 0;
 }
 
-/*--------------------------------------------------------------------*/
-/* Async timers                                                       */
-/*--------------------------------------------------------------------*/
-
-/* We emulate two timers, one for SIGALRM, another for SIGPROF.
-
-   itimerproc() function has an implementation limitation: it does
-   not allow to set *both* interval and period. If an attempt is
-   made to set both, and then they are unequal, the function
-   asserts.
-
-   Minimum timer resolution on Win32 systems varies, and is greater
-   than or equal than 1 ms. The resolution is always wrapped not to
-   attempt to get below the system defined limit.
-   */
-
-/* Timer precision, denominator of one fraction: for 100 ms
-   interval, request 10 ms precision
-   */
-const int timer_prec = 10;
-
-/* Last itimervals, as set by calls to setitimer */
-static struct itimerval it_alarm;
-static struct itimerval it_prof;
-
-/* Timer IDs as returned by MM */
-MMRESULT tid_alarm = 0;
-MMRESULT tid_prof = 0;
-
-static void CALLBACK timer_proc (UINT uID, UINT uMsg, DWORD dwUser,
-				 DWORD dw1, DWORD dw2)
-{
-  /* Just raise a signal indicated by dwUser parameter */
-  mswindows_raise (dwUser);
-}
-
-/* Divide time in ms specified by IT by DENOM. Return 1 ms
-   if division results in zero */
-static UINT period (const struct itimerval* it, UINT denom)
-{
-  static TIMECAPS time_caps;
-
-  UINT res;
-  const struct timeval* tv = 
-    (it->it_value.tv_sec == 0 && it->it_value.tv_usec == 0)
-    ? &it->it_interval : &it->it_value;
-  
-  /* Zero means stop timer */
-  if (tv->tv_sec == 0 && tv->tv_usec == 0)
-    return 0;
-  
-  /* Convert to ms and divide by denom */
-  res = (tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000) / denom;
-  
-  /* Converge to minimum timer resolution */
-  if (time_caps.wPeriodMin == 0)
-      timeGetDevCaps (&time_caps, sizeof(time_caps));
-
-  if (res < time_caps.wPeriodMin)
-    res = time_caps.wPeriodMin;
-
-  return res;
-}
-
-static int setitimer_helper (const struct itimerval* itnew,
-			     struct itimerval* itold, struct itimerval* itcurrent,
-			     MMRESULT* tid, DWORD sigkind)
-{
-  UINT delay, resolution, event_type;
-
-  /* First stop the old timer */
-  if (*tid)
-    {
-      timeKillEvent (*tid);
-      timeEndPeriod (period (itcurrent, timer_prec));
-      *tid = 0;
-    }
-
-  /* Return old itimerval if requested */
-  if (itold)
-    *itold = *itcurrent;
-
-  *itcurrent = *itnew;
-
-  /* Determine if to start new timer */
-  delay = period (itnew, 1);
-  if (delay)
-    {
-      resolution = period (itnew, timer_prec);
-      event_type = (itnew->it_value.tv_sec == 0 && itnew->it_value.tv_usec == 0)
-	? TIME_ONESHOT : TIME_PERIODIC;
-      timeBeginPeriod (resolution);
-      *tid = timeSetEvent (delay, resolution, timer_proc, sigkind, event_type);
-    }
-
-  return !delay || *tid;
-}
- 
-int setitimer (int kind, const struct itimerval* itnew,
-	       struct itimerval* itold)
-{
-  /* In this version, both interval and value are allowed
-     only if they are equal. */
-  assert ((itnew->it_value.tv_sec == 0 && itnew->it_value.tv_usec == 0)
-	  || (itnew->it_interval.tv_sec == 0 && itnew->it_interval.tv_usec == 0)
-	  || (itnew->it_value.tv_sec == itnew->it_interval.tv_sec &&
-	      itnew->it_value.tv_usec == itnew->it_interval.tv_usec));
-
-  if (kind == ITIMER_REAL)
-    return setitimer_helper (itnew, itold, &it_alarm, &tid_alarm, SIGALRM);
-  else if (kind == ITIMER_PROF)
-    return setitimer_helper (itnew, itold, &it_prof, &tid_prof, SIGPROF);
-  else
-    return errno = EINVAL;
-}
-
 
 /*--------------------------------------------------------------------*/
 /*                        Memory-mapped files                         */
@@ -2321,9 +2209,9 @@
 void
 close_file_data (file_data *p_file)
 {
-    UnmapViewOfFile (p_file->file_base);
-    CloseHandle (p_file->file_mapping);
-    CloseHandle (p_file->file);
+  UnmapViewOfFile (p_file->file_base);
+  CloseHandle (p_file->file_mapping);
+  CloseHandle (p_file->file);
 }
 
 void
--- a/src/ntproc.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/ntproc.c	Fri Jun 08 12:21:27 2001 +0000
@@ -1,4 +1,4 @@
-/* Process support for Windows NT port of XEMACS.
+/* Old process support under MS Windows, soon to die.
    Copyright (C) 1992, 1995 Free Software Foundation, Inc.
 
 This file is part of XEmacs.
@@ -24,6 +24,16 @@
 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
 /* Synced with FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
 
+/* #### This ENTIRE file is only around because of callproc.c, which
+   in turn is only used in batch mode.
+
+   We only need two things to get rid of both this and callproc.c:
+
+   -- my `stderr-proc' ws, which adds support for a separate stderr
+      in asynch. subprocesses. (it's a feature in `old-call-process-internal'.)
+   -- a noninteractive event loop that supports processes.
+*/
+
 #include <config.h>
 #undef signal
 #undef wait
--- a/src/profile.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/profile.c	Fri Jun 08 12:21:27 2001 +0000
@@ -30,6 +30,10 @@
 #include "syssignal.h"
 #include "systime.h"
 
+#ifndef HAVE_SETITIMER
+#error Sorry charlie.  We need a scalpel and all we have is a lawnmower.
+#endif
+
 /* We implement our own profiling scheme so that we can determine
    things like which Lisp functions are occupying the most time.  Any
    standard OS-provided profiling works on C functions, which is
@@ -192,7 +196,7 @@
   foo.it_interval = foo.it_value;
   profiling_active = 1;
   inside_profiling = 0;
-  setitimer (ITIMER_PROF, &foo, 0);
+  qxe_setitimer (ITIMER_PROF, &foo, 0);
   return Qnil;
 }
 
@@ -207,7 +211,7 @@
   foo.it_value.tv_sec = 0;
   foo.it_value.tv_usec = 0;
   foo.it_interval = foo.it_value;
-  setitimer (ITIMER_PROF, &foo, 0);
+  qxe_setitimer (ITIMER_PROF, &foo, 0);
   profiling_active = 0;
   signal (SIGPROF, fatal_error_signal);
   return Qnil;
--- a/src/redisplay.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/redisplay.c	Fri Jun 08 12:21:27 2001 +0000
@@ -7102,6 +7102,10 @@
   FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
     {
       struct frame *f = XFRAME (XCAR (frmcons));
+      /* #### urk!  this does tons o' crap, such as creating lots of
+	 structs, doing window system actions, etc.  we DO NOT want to
+	 be doing this -- marking should never change any state.
+	 i think we can just delete this. --ben */
       update_frame_window_mirror (f);
       mark_window_mirror (f->root_mirror);
       mark_gutters (f);
--- a/src/scrollbar-msw.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/scrollbar-msw.c	Fri Jun 08 12:21:27 2001 +0000
@@ -89,9 +89,21 @@
 }
 
 static void
+unshow_that_mofo (void *handle)
+{
+  ShowScrollBar ((HWND) handle, SB_CTL, 0);
+}
+
+static void
 mswindows_release_scrollbar_instance (struct scrollbar_instance *sb)
 {
-  ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, 0);
+  if (gc_in_progress)
+    /* #### way bogus!  need to remove the offending call.
+       see mark_redisplay(). */
+    register_post_gc_action (unshow_that_mofo,
+			     (void *) SCROLLBAR_MSW_HANDLE (sb));
+  else
+    ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, 0);
   SCROLLBAR_MSW_SIZE (sb) = 0;
 }
 
--- a/src/signal.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/signal.c	Fri Jun 08 12:21:27 2001 +0000
@@ -28,12 +28,12 @@
 #include "events.h" /* for signal_fake_event() */
 #include "frame.h"
 #include "process.h"
+
 #include "sysdep.h"
+#include "sysfile.h"
 #include "syssignal.h"
 #include "systime.h"
 
-#include "sysfile.h"
-
 /* Set to 1 when a quit-check signal (either a SIGIO interrupt or
    the asynch. timeout for poll-for-quit) occurs.  The QUITP
    macro may look at this. */
@@ -109,7 +109,7 @@
   struct itimerval it;
   it.it_value = interval;
   EMACS_SET_SECS_USECS (it.it_interval, 0, 0);
-  setitimer (ITIMER_REAL, &it, 0);
+  qxe_setitimer (ITIMER_REAL, &it, 0);
 #else
   int secs;
   EMACS_TIME_TO_INT (interval, secs);
@@ -263,6 +263,7 @@
    crash). --ben */
 
 #ifdef HAVE_SETITIMER
+
 unsigned int
 alarm (unsigned int howlong)
 {
@@ -274,12 +275,27 @@
   new_it.it_value.tv_usec = 0;
   new_it.it_interval.tv_sec = 0;
   new_it.it_interval.tv_usec = 0;
-  setitimer (ITIMER_REAL, &new_it, &old_it);
+  qxe_setitimer (ITIMER_REAL, &new_it, &old_it);
 
   /* Never return zero if there was a timer outstanding. */
   return old_it.it_value.tv_sec + (old_it.it_value.tv_usec > 0 ? 1 : 0);
 }
+
+int
+qxe_setitimer (int kind, const struct itimerval *itnew,
+	       struct itimerval *itold)
+{
+#if defined (WIN32_NATIVE) || defined (CYGWIN)
+  /* setitimer() does not exist on native MS Windows, and appears broken
+     on Cygwin.  See win32.c. */
+  return mswindows_setitimer (kind, itnew, itold);
+#else
+  return setitimer (kind, itnew, itold);
 #endif
+}
+
+#endif /* HAVE_SETITIMER */
+
 
 DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, 0, 0, 0, /*
 Return non-nil if XEmacs is waiting for input from the user.
--- a/src/systime.h	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/systime.h	Fri Jun 08 12:21:27 2001 +0000
@@ -241,9 +241,9 @@
 void get_process_times (double *user_time, double *system_time,
 			double *real_time);
 
-#if defined(WIN32_NATIVE)
+#ifdef WIN32_NATIVE
 
-/* setitimer emulation for Win32 (see nt.c) */
+/* setitimer emulation for Win32 (see win32.c) */
 
 struct itimerval
 {
@@ -251,12 +251,46 @@
   struct timeval it_interval;
 };
 
-int setitimer (int kind, const struct itimerval* itnew,
-	       struct itimerval* itold);
-
 #define ITIMER_REAL 1
 #define ITIMER_PROF 2
 
 #endif /* WIN32_NATIVE */
 
+#if defined (WIN32_NATIVE) || defined (CYGWIN)
+
+int mswindows_setitimer (int kind, const struct itimerval *itnew,
+			 struct itimerval *itold);
+
+#endif /* defined (WIN32_NATIVE) || defined (CYGWIN) */
+
+/* #### Move this comment elsewhere when we figure out the place.
+
+   "qxe" is a unique prefix used to identify encapsulations of standard
+   library functions.  We used to play pre-processing games but in
+   general this leads to nothing but trouble because someone first
+   encountering the code will have no idea that what appears to be a
+   call to a library function has actually been redefined to be a call
+   somewhere else.  This is doubly true when the redefinition occurs
+   in out-of-the way s+m files and only on certainly systems.
+
+   By making the encapsulation explicit we might be making the code
+   that uses is slightly less pretty, but this is more than compensated
+   for by the huge increase in clarity.
+
+   "Standard library function" can refer to any function in any
+   standard library.  If we are explicitly changing the semantics
+   (e.g. Mule-encapsulating), we should use an extended version of
+   the prefix, e.g. perhaps "qxe_xlat_" for functions that Mule-
+   encapsulate, or "qxe_retry_" for functions that automatically
+   retry a system call interrupted by EINTR.  In general, if there
+   is no prefix extension, it means the function is trying to
+   provide (more or less) the same semantics as the standard library
+   function; but be aware that the reimplementation may be incomplete
+   or differ in important respects.  This is especially the case
+   when attempts are made to implement Unix functions on MS Windows.
+*/
+
+int qxe_setitimer (int kind, const struct itimerval *itnew,
+		   struct itimerval *itold);
+
 #endif /* INCLUDED_systime_h_ */
--- a/src/win32.c	Thu Jun 07 06:37:25 2001 +0000
+++ b/src/win32.c	Fri Jun 08 12:21:27 2001 +0000
@@ -22,6 +22,9 @@
 #include "lisp.h"
 
 #include "buffer.h"
+
+#include "syssignal.h"
+#include "systime.h"
 #include "syswindows.h"
 
 typedef BOOL (WINAPI *pfSwitchToThread_t) (VOID);
@@ -246,6 +249,141 @@
   return Qnil;
 }
 
+
+/*--------------------------------------------------------------------*/
+/*                               Async timers                         */
+/*--------------------------------------------------------------------*/
+
+/* setitimer() does not exist on native MS Windows, and appears broken
+   on Cygwin (random lockups when BROKEN_SIGIO is defined), so we
+   emulate in both cases by using multimedia timers. */
+
+/* We emulate two timers, one for SIGALRM, another for SIGPROF.
+
+   itimerproc() function has an implementation limitation: it does
+   not allow to set *both* interval and period. If an attempt is
+   made to set both, and then they are unequal, the function
+   asserts.
+
+   Minimum timer resolution on Win32 systems varies, and is greater
+   than or equal than 1 ms. The resolution is always wrapped not to
+   attempt to get below the system defined limit.
+   */
+
+/* Timer precision, denominator of one fraction: for 100 ms
+   interval, request 10 ms precision
+   */
+const int setitimer_helper_timer_prec = 10;
+
+/* Last itimervals, as set by calls to setitimer */
+static struct itimerval it_alarm;
+static struct itimerval it_prof;
+
+/* Timer IDs as returned by MM */
+MMRESULT tid_alarm = 0;
+MMRESULT tid_prof = 0;
+
+static void CALLBACK
+setitimer_helper_proc (UINT uID, UINT uMsg, DWORD dwUser,
+		       DWORD dw1, DWORD dw2)
+{
+  /* Just raise the signal indicated by the dwUser parameter */
+#ifdef CYGWIN
+  kill (getpid (), dwUser);
+#else
+  mswindows_raise (dwUser);
+#endif
+}
+
+/* Divide time in ms specified by IT by DENOM. Return 1 ms
+   if division results in zero */
+static UINT
+setitimer_helper_period (const struct itimerval* it, UINT denom)
+{
+  static TIMECAPS time_caps;
+
+  UINT res;
+  const struct timeval* tv = 
+    (it->it_value.tv_sec == 0 && it->it_value.tv_usec == 0)
+    ? &it->it_interval : &it->it_value;
+  
+  /* Zero means stop timer */
+  if (tv->tv_sec == 0 && tv->tv_usec == 0)
+    return 0;
+  
+  /* Convert to ms and divide by denom */
+  res = (tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000) / denom;
+  
+  /* Converge to minimum timer resolution */
+  if (time_caps.wPeriodMin == 0)
+      timeGetDevCaps (&time_caps, sizeof(time_caps));
+
+  if (res < time_caps.wPeriodMin)
+    res = time_caps.wPeriodMin;
+
+  return res;
+}
+
+static int
+setitimer_helper (const struct itimerval* itnew,
+		  struct itimerval* itold, struct itimerval* itcurrent,
+		  MMRESULT* tid, DWORD sigkind)
+{
+  UINT delay, resolution, event_type;
+
+  /* First stop the old timer */
+  if (*tid)
+    {
+      timeKillEvent (*tid);
+      timeEndPeriod (setitimer_helper_period (itcurrent,
+					      setitimer_helper_timer_prec));
+      *tid = 0;
+    }
+
+  /* Return old itimerval if requested */
+  if (itold)
+    *itold = *itcurrent;
+
+  *itcurrent = *itnew;
+
+  /* Determine if to start new timer */
+  delay = setitimer_helper_period (itnew, 1);
+  if (delay)
+    {
+      resolution = setitimer_helper_period (itnew,
+					    setitimer_helper_timer_prec);
+      event_type = (itnew->it_value.tv_sec == 0 &&
+		    itnew->it_value.tv_usec == 0)
+	? TIME_ONESHOT : TIME_PERIODIC;
+      timeBeginPeriod (resolution);
+      *tid = timeSetEvent (delay, resolution, setitimer_helper_proc, sigkind,
+			   event_type);
+    }
+
+  return !delay || *tid;
+}
+ 
+int
+mswindows_setitimer (int kind, const struct itimerval *itnew,
+		     struct itimerval *itold)
+{
+  /* In this version, both interval and value are allowed
+     only if they are equal. */
+  assert ((itnew->it_value.tv_sec == 0 && itnew->it_value.tv_usec == 0)
+	  || (itnew->it_interval.tv_sec == 0 &&
+	      itnew->it_interval.tv_usec == 0)
+	  || (itnew->it_value.tv_sec == itnew->it_interval.tv_sec &&
+	      itnew->it_value.tv_usec == itnew->it_interval.tv_usec));
+
+  if (kind == ITIMER_REAL)
+    return setitimer_helper (itnew, itold, &it_alarm, &tid_alarm, SIGALRM);
+  else if (kind == ITIMER_PROF)
+    return setitimer_helper (itnew, itold, &it_prof, &tid_prof, SIGPROF);
+  else
+    return errno = EINVAL;
+}
+
+
 void
 syms_of_win32 (void)
 {