changeset 707:a307f9a2021d

[xemacs-hg @ 2001-12-20 05:49:28 by andyp] sync with 21-4-6-windows
author andyp
date Thu, 20 Dec 2001 05:49:48 +0000
parents c9bf82d465b5
children 512e4a478e9d
files lisp/ChangeLog lisp/auto-autoloads.el lisp/cus-edit.el lisp/cus-face.el lisp/dialog-gtk.el lisp/faces.el lisp/font.el lisp/gtk-faces.el lisp/menubar.el lisp/package-get.el lisp/package-net.el lisp/printer.el man/lispref/glyphs.texi man/lispref/lispref.texi netinstall/ChangeLog netinstall/Makefile.in.in netinstall/desktop.cc netinstall/desktop.h netinstall/install.cc netinstall/source.cc netinstall/uninstall.cc netinstall/win32.h src/ChangeLog src/alloc.c src/buffer.c src/dialog-msw.c src/dired.c src/editfns.c src/event-msw.c src/event-stream.c src/fileio.c src/lisp.h src/menubar-msw.c src/nt.c src/ntheap.c src/scrollbar-msw.c src/search.c src/win32.c src/window.c
diffstat 39 files changed, 850 insertions(+), 261 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/ChangeLog	Thu Dec 20 05:49:48 2001 +0000
@@ -1,3 +1,96 @@
+2001-12-16  Andy Piper  <andy@xemacs.org>
+
+	* package-get.el (package-get-update-all): Make sure installed.db
+	gets updated after updating packages.
+
+2001-12-11  Andy Piper  <andy@xemacs.org>
+
+	* menubar.el (get-popup-menu-response): re-order so that it works
+	on more sane/facist window systems.
+
+2001-12-03  Andy Piper  <andy@xemacs.org>
+
+	* faces.el (frob-face-property): don't infloop in face frobbing
+	from Jan Vroonhof <jan@xemacs.org>.
+
+2001-11-30  Andy Piper  <andy@xemacs.org>
+
+	* printer.el (generic-print-region): fix for non-MS systems from
+	Mike Fabian.
+
+2001-11-30  Jan Vroonhof  <jan@xemacs.org>
+
+	* font.el (font-window-system-mappings): Add mapping for Gtk
+	(assume identical to X)	
+
+2001-11-30  Jan Vroonhof  <jan@xemacs.org>
+
+	* faces.el (frob-face-property): Follow face fall-back hierarchy
+	properly for face properties without an instance. Only do manual
+	copy form 'default in last resort. This handles in particular
+	the case where 'default itself has only a fall-back (which is
+	the case by default on windows).
+
+2001-11-24  Andy Piper  <andy@xemacs.org>
+
+	* printer.el (generic-print-region): set default-frame-plist to
+	nil while creating the printer frame so that sizes reflect the
+	printed page.
+
+	* faces.el (face-complain-about-font): Don't complain on printers.
+
+2001-11-21  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* package-net.el: Inadvertant synch with Windows branch.  From
+	Andy's log:
+	(package-net-kit-version): new variable.
+	(package-net-generate-bin-ini): use it. Remove unwanted functions.
+
+2001-11-28  Steve Youngs  <youngs@xemacs.org>
+
+	* package-get.el (package-get-locate-index-file): Also search the
+	core etc/ directory for the package index file if it can't be
+	found in ~/.xemacs/.
+
+2001-12-13  William Perry  <wmperry@gnu.org>
+
+	* dialog-gtk.el (popup-builtin-question-dialog):
+	Conform to API in gui.c.
+	
+2001-11-12  Andy Piper  <andy@xemacs.org>
+
+	* cus-edit.el (custom-save-face-internal): make sure we save
+	non-themed faces.
+	(custom-save-variables): ditto variables.
+
+2001-11-20  Stephen J. Turnbull  <stephen@xemacs.og>
+
+	* faces.el (make-face-family):
+	(make-face-size):
+	New face-modifying functions per Jan Vroonhof.
+
+	cus-face.el (custom-set-face-font-family):
+	(custom-set-face-font-size):
+	Use them.
+
+	* font.el (font-window-system-mappings): More precise docstring.
+
+	(font-create-name):
+	(font-create-object):
+	(tty-font-create-object):
+	(tty-font-create-plist):
+	(x-font-create-object):
+	(x-font-create-name):
+	(ns-font-create-name):
+	(mswindows-font-create-object):
+	(mswindows-font-create-name):
+	Add doctrings.
+
+2001-11-14  John Paul Wallington <jpw@shootybangbang.com>
+
+	* gtk-faces.el (gtk-init-device-faces): removed spurious
+	quote before let* expression.
+
 2001-12-19  Jan Vroonhof  <jan@xemacs.org>
 
 	* gtk-faces.el (gtk-init-device-faces): Fix missing close paren
--- a/lisp/auto-autoloads.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/auto-autoloads.el	Thu Dec 20 05:49:48 2001 +0000
@@ -887,7 +887,8 @@
 the tag.
 
 This version of this function supports multiple active tags tables,
-and completion.
+and completion. See also the commands `\\[push-tag-mark]' and
+`\\[pop-tag-mark]'.
 
 Variables of note:
 
@@ -1249,7 +1250,8 @@
 
 ;;;### (autoloads (x-font-build-cache font-default-size-for-device font-default-encoding-for-device font-default-registry-for-device font-default-family-for-device font-default-object-for-device font-default-font-for-device font-create-object) "font" "lisp/font.el")
 
-(autoload 'font-create-object "font" nil nil nil)
+(autoload 'font-create-object "font" "\
+Return a font descriptor object for FONTNAME, appropriate for DEVICE." nil nil)
 
 (autoload 'font-default-font-for-device "font" nil nil nil)
 
--- a/lisp/cus-edit.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/cus-edit.el	Thu Dec 20 05:49:48 2001 +0000
@@ -3392,7 +3392,7 @@
  	(princ "\n"))
        (princ "(custom-set-variables")
        (mapatoms (lambda (symbol)
- 		  (let ((spec (car-safe (get symbol 'theme-value)))
+		   (let ((spec (car-safe (get symbol 'theme-value)))
  			(requests (get symbol 'custom-requests))
  			(now (not (or (get symbol 'standard-value)
  				      (and (not (boundp symbol))
@@ -3400,7 +3400,9 @@
 						    'rogue))))))
 			(comment (get symbol 'saved-variable-comment)))
  		    (when (or (and spec (eq (car spec) 'user)
- 			       (eq (second spec) 'set)) comment)
+ 			       (eq (second spec) 'set)) comment
+			       ;; support non-themed vars
+			       (and (null spec) (get symbol 'saved-value)))
  		      (princ "\n '(")
  		      (prin1 symbol)
  		      (princ " ")
@@ -3431,9 +3433,12 @@
 		   (not (eq (get symbol 'force-face) 'rogue)))))))
     (when (or (and (not (memq symbol custom-save-face-ignoring))
 	       ;; Don't print default face here.
-	       theme-spec
-	       (eq (car theme-spec) 'user)
-	       (eq (second theme-spec) 'set)) comment)
+		   (or (and theme-spec
+			    (eq (car theme-spec) 'user)
+			    (eq (second theme-spec) 'set))
+		       ;; cope with non-themed faces
+		       (and (null theme-spec)
+			    (get symbol 'saved-face)))) comment)
       (princ "\n '(")
       (prin1 symbol)
       (princ " ")
--- a/lisp/cus-face.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/cus-face.el	Thu Dec 20 05:49:48 2001 +0000
@@ -200,13 +200,20 @@
     (and image
 	 (image-instance-file-name image))))
 
+;; This consistently fails to dtrt
+;;(defun custom-set-face-font-size (face size &optional locale tags)
+;;  "Set the font of FACE to SIZE."
+;;  ;; #### should this call have tags in it?
+;;  (let* ((font (apply 'face-font-name face (list locale)))
+;;	 ;; Gag
+;;	 (fontobj (font-create-object font)))
+;;    (set-font-size fontobj size)
+;;    (apply 'font-set-face-font face fontobj locale tags)))
+
+;; From Jan Vroonhof -- see faces.el
 (defun custom-set-face-font-size (face size &optional locale tags)
   "Set the font of FACE to SIZE."
-  (let* ((font (apply 'face-font-name face locale))
-	 ;; Gag
-	 (fontobj (font-create-object font)))
-    (set-font-size fontobj size)
-    (apply 'font-set-face-font face fontobj locale tags)))
+  (make-face-size face size locale tags))
 
 (defun custom-face-font-size (face &rest args)
   "Return the size of the font of FACE as a string."
@@ -215,13 +222,20 @@
 	 (fontobj (font-create-object font)))
     (format "%s" (font-size fontobj))))
 
+;; Jan suggests this may not dtrt
+;;(defun custom-set-face-font-family (face family &optional locale tags)
+;;  "Set the font of FACE to FAMILY."
+;;  ;; #### should this call have tags in it?
+;;  (let* ((font (apply 'face-font-name face (list locale)))
+;;	 ;; Gag
+;;	 (fontobj (font-create-object font)))
+;;    (set-font-family fontobj family)
+;;    (apply 'font-set-face-font face fontobj locale tags)))
+
+;; From Jan Vroonhof -- see faces.el
 (defun custom-set-face-font-family (face family &optional locale tags)
   "Set the font of FACE to FAMILY."
-  (let* ((font (apply 'face-font-name face locale))
-	 ;; Gag
-	 (fontobj (font-create-object font)))
-    (set-font-family fontobj family)
-    (apply 'font-set-face-font face fontobj locale tags)))
+  (make-face-family face family locale tags))
 
 (defun custom-face-font-family (face &rest args)
   "Return the name of the font family of FACE."
--- a/lisp/dialog-gtk.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/dialog-gtk.el	Thu Dec 20 05:49:48 2001 +0000
@@ -194,7 +194,9 @@
 	(dialog nil)			; GtkDialog
 	(buttons nil)			; List of GtkButton objects
 	(activep t)
+	(callback nil)
 	(flushrightp nil)
+	(length nil)
 	(errp t))
     (if (not buttons-descr)
 	(error 'syntax-error
@@ -220,28 +222,29 @@
 		    (if (not (vectorp button))
 			(error "Button descriptor is not a vector: %S" button))
 
-		    (if (< (length button) 3)
-			(error "Button descriptor is too small: %S" button))
+		    (setq length (length button))
+
+		    (cond
+		     ((= length 1)	; [ "name" ]
+		      (setq callback nil
+			    activep nil))
+		     ((= length 2)	; [ "name" callback ]
+		      (setq callback (aref button 1)
+			    activep t))
+		     ((and (or (= length 3) (= length 4))
+			   (not (keywordp (aref button 2))))
+		      ;; [ "name" callback active-p ] or
+		      ;; [ "name" callback active-p suffix ]
+		      ;; We ignore the 'suffix' entry, because that is
+		      ;; what the X code does.
+		      (setq callback (aref button 1)
+			    activep (aref button 2)))
+		     (t			; 100% keyword specification
+		      (let ((plist (cdr (mapcar 'identity button))))
+			(setq activep (plist-get plist :active)
+			      callback (plist-get plist :callback)))))
 
 		    (push (gtk-button-new-with-label (aref button 0)) buttons)
-
-		    ;; Need to detect what flavor of descriptor it is.
-		    (if (not (keywordp (aref button 2)))
-			;; Simple style... just [ name callback activep ]
-			;; We ignore the 'suffix' entry, because that is what
-			;; the X code does.
-			(setq activep (aref button 2))
-		      (let ((ctr 2)
-			    (len (length button)))
-			(if (logand len 1)
-			    (error
-			     "Button descriptor has an odd number of keywords and values: %S"
-			     button))
-			(while (< ctr len)
-			  (if (eq (aref button ctr) :active)
-			      (setq activep (aref button (1+ ctr))
-				    ctr len))
-			  (setq ctr (+ ctr 2)))))
 		    (gtk-widget-set-sensitive (car buttons) (eval activep))
 		    
 		    ;; Apply the callback
@@ -257,7 +260,7 @@
 			     unread-command-events)
 		       (gtk-main-quit)
 		       t)
-		     (cons (aref button 1) dialog))
+		     (cons callback dialog))
 
 		    (gtk-widget-show (car buttons))
 		    (funcall (if flushrightp 'gtk-box-pack-end 'gtk-box-pack-start)
--- a/lisp/faces.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/faces.el	Thu Dec 20 05:49:48 2001 +0000
@@ -847,10 +847,21 @@
 
 
       (setq temp-sp (copy-specifier sp))
-      (if (and (or (eq locale 'global) (eq locale 'all) (not locale))
-	       (not (face-property face property 'global)))
-	  (copy-specifier (face-property 'default property)
-			  temp-sp 'global))
+      (if (or (eq locale 'global) (eq locale 'all) (not locale))
+	  (when (not (specifier-specs temp-sp 'global))
+	    ;; Try fallback via the official ways and then do it "by hand"
+	    (let* ((fallback (specifier-fallback sp))
+		   (fallback-sp 
+		    (cond ((specifierp fallback) fallback)
+			  ;; just an inst list
+			  (fallback
+			   (make-specifier-and-init (specifier-type sp)
+						    fallback))
+			  ((eq (get-face face) (get-face 'default))
+			   (error "Unable to find global specification"))
+			  ;; If no fallback we snoop from default
+			  (t (face-property 'default property)))))
+	      (copy-specifier fallback-sp temp-sp 'global))))
       (if (and (valid-specifier-locale-p locale)
 	       (not (specifier-specs temp-sp locale)))
 	  (error "Property must have a specification in locale %S" locale))
@@ -986,6 +997,27 @@
 		  (face-property-instance unfrobbed-face 'font domain))
 	   (set-face-property face 'font (vector frobbed-face) the-locale tags)))))))
 
+;; WE DEMAND FOUNDRY FROBBING!
+
+;; Family frobbing
+;; Thx Jan Vroonhof, Ref xemacs-beta <87oflypbum.fsf@petteflet.ntlworld.com>
+;; Brainlessly derived from make-face-size by Stephen; don't blame Jan.
+;; I'm long since flown to Rio, it does you little good to blame me, either.
+(defun make-face-family (face family &optional locale tags)
+  "Set FACE's family to FAMILY in LOCALE, if possible.
+
+Add/replace settings specified by TAGS only."
+  (frob-face-property face 'font
+		      ;; uses dynamic scope of family
+		      #'(lambda (f d)
+			  ;; keep the dependency on font.el for now
+			  (let ((fo (font-create-object (font-instance-name f)
+							d)))
+			    (set-font-family fo family)
+			    (font-create-name fo d)))
+		      nil locale tags))
+
+;; Style (ie, typographical face) frobbing
 (defun make-face-bold (face &optional locale tags)
   "Make FACE bold in LOCALE, if possible.
 This will attempt to make the font bold for X/MSW locales and will set the
@@ -1169,6 +1201,23 @@
      ([bold-italic] . [bold]))))
 
 
+;; Size frobbing
+;; Thx Jan Vroonhof, Ref xemacs-beta <87oflypbum.fsf@petteflet.ntlworld.com>
+;; Jan had a separate helper function 
+(defun make-face-size (face size &optional locale tags)
+  "Adjust FACE to SIZE in LOCALE, if possible.
+
+Add/replace settings specified by TAGS only."
+  (frob-face-property face 'font
+		      ;; uses dynamic scope of size
+		      #'(lambda (f d)
+			  ;; keep the dependency on font.el for now
+			  (let ((fo (font-create-object (font-instance-name f)
+							d)))
+			    (set-font-size fo size)
+			    (font-create-name fo d)))
+		      nil locale tags))
+
 ;; Why do the following two functions lose so badly in so many
 ;; circumstances?
 
@@ -1579,10 +1628,12 @@
 (defun face-complain-about-font (face device)
   (if (symbolp face) (setq face (symbol-name face)))
 ;;  (if (not inhibit-font-complaints)
-  (display-warning
-   'font
-   (let ((default-name (face-font-name 'default device)))
-     (format "%s: couldn't deduce %s %s version of the font
+  ;; complaining for printers is generally annoying.
+  (unless (device-printer-p device)
+    (display-warning
+	'font
+      (let ((default-name (face-font-name 'default device)))
+	(format "%s: couldn't deduce %s %s version of the font
 %S.
 
 Please specify X resources to make the %s face
@@ -1592,14 +1643,14 @@
 Emacs.%s.attributeFont: -dt-*-medium-i-*
 or
 Emacs.%s.attributeForeground: hotpink\n"
-             invocation-name
-             (if (string-match "\\`[aeiouAEIOU]" face) "an" "a")
-             face
-             default-name
-             face
-             face
-             face
-             ))))
+		invocation-name
+		(if (string-match "\\`[aeiouAEIOU]" face) "an" "a")
+		face
+		default-name
+		face
+		face
+		face
+		)))))
 
 
 ;; #### This is quite a mess.  We should use the custom mechanism for
--- a/lisp/font.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/font.el	Thu Dec 20 05:49:48 2001 +0000
@@ -110,8 +110,10 @@
     (mswindows . (mswindows-font-create-name mswindows-font-create-object))
     (pm        . (x-font-create-name x-font-create-object)) ; Change? FIXME
     (tty       . (tty-font-create-plist tty-font-create-object)))
-  "An assoc list mapping device types to the function used to create
-a font name from a font structure.")
+  "An assoc list mapping device types to a list of translations.
+
+The first function creates a font name from a font descriptor object.
+The second performs the reverse translation.")
 
 (defconst ns-font-weight-mappings
   '((:extra-light . "extralight")
@@ -148,6 +150,8 @@
 (defvar font-maximum-slippage "1pt"
   "How much a font is allowed to vary from the desired size.")
 
+;; Canonical (internal) sizes are in points.
+;; Registry
 (define-font-keywords :family :style :size :registry :encoding)
 
 (define-font-keywords
@@ -304,8 +308,16 @@
       w2))))
 
 (defun font-spatial-to-canonical (spec &optional device)
-  "Convert SPEC (in inches, millimeters, points, or picas) into points."
-  ;; 1 in = 6 pa = 25.4 mm = 72 pt
+  "Convert SPEC (in inches, millimeters, points, picas, or pixels) into points.
+
+Canonical sizes are in points.  If SPEC is null, nil is returned.  If SPEC is
+a number, it is interpreted as the desired point size and returned unchanged.
+Otherwise SPEC must be a string consisting of a number and an optional type.
+The type may be the strings \"px\", \"pix\", or \"pixel\" (pixels), \"pt\" or
+\"point\" (points), \"pa\" or \"pica\" (picas), \"in\" or \"inch\" (inches), \"cm\"
+(centimeters), or \"mm\" (millimeters).
+
+1 in = 2.54 cm = 6 pa = 25.4 mm = 72 pt.  Pixel size is device-dependent."
   (cond
    ((numberp spec)
     spec)
@@ -320,6 +332,8 @@
 	  (mm-width (float (or (device-mm-width device) 293)))
 	  (retval nil))
       (cond
+       ;; the following string-match is broken, there will never be a
+       ;; left operand detected
        ((string-match "^ *\\([-+*/]\\) *" spec) ; math!  whee!
 	(let ((math-func (intern (match-string 1 spec)))
 	      (other (font-spatial-to-canonical
@@ -379,12 +393,14 @@
 	  (plist-get args :encoding)))
 
 (defun font-create-name (fontobj &optional device)
+  "Return a font name constructed from FONTOBJ, appropriate for DEVICE."
   (let* ((type (device-type device))
 	 (func (car (cdr-safe (assq type font-window-system-mappings)))))
     (and func (fboundp func) (funcall func fontobj device))))
 
 ;;;###autoload
 (defun font-create-object (fontname &optional device)
+  "Return a font descriptor object for FONTNAME, appropriate for DEVICE."
   (let* ((type (device-type device))
 	 (func (car (cdr (cdr-safe (assq type font-window-system-mappings))))))
     (and func (fboundp func) (funcall func fontname device))))
@@ -437,9 +453,11 @@
 ;;; The window-system dependent code (TTY-style)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defun tty-font-create-object (fontname &optional device)
+  "Return a font descriptor object for FONTNAME, appropriate for TTY devices."
   (make-font :size "12pt"))
 
 (defun tty-font-create-plist (fontobj &optional device)
+  "Return a font name constructed from FONTOBJ, appropriate for TTY devices."
   (list
    (cons 'underline (font-underline-p fontobj))
    (cons 'highlight (if (or (font-bold-p fontobj)
@@ -524,6 +542,7 @@
   "A list of font family mappings on X devices.")
 
 (defun x-font-create-object (fontname &optional device)
+  "Return a font descriptor object for FONTNAME, appropriate for X devices."
   (let ((case-fold-search t))
     (if (or (not (stringp fontname))
 	    (not (string-match font-x-font-regexp fontname)))
@@ -626,6 +645,7 @@
   (font-size (font-default-object-for-device (or device (selected-device)))))
 
 (defun x-font-create-name (fontobj &optional device)
+  "Return a font name constructed from FONTOBJ, appropriate for X devices."
   (if (and (not (or (font-family fontobj)
 		    (font-weight fontobj)
 		    (font-size fontobj)
@@ -717,6 +737,7 @@
 	    (sort (font-unique (nconc scaled normal)) 'string-lessp))))))
 
 (defun ns-font-create-name (fontobj &optional device)
+  "Return a font name constructed from FONTOBJ, appropriate for NextSTEP devices."
   (let ((family (or (font-family fontobj)
 		    (ns-font-families-for-device device)))
 	(weight (or (font-weight fontobj) :medium))
@@ -815,6 +836,7 @@
   "A list of font family mappings on mswindows devices.")
 
 (defun mswindows-font-create-object (fontname &optional device)
+  "Return a font descriptor object for FONTNAME, appropriate for MS Windows devices."
   (let ((case-fold-search t)
 	(font (mswindows-font-canonicalize-name fontname)))
     (if (or (not (stringp font))
@@ -853,6 +875,7 @@
 	retval))))
 
 (defun mswindows-font-create-name (fontobj &optional device)
+  "Return a font name constructed from FONTOBJ, appropriate for MS Windows devices."
   (if (and (not (or (font-family fontobj)
 		    (font-weight fontobj)
 		    (font-size fontobj)
--- a/lisp/gtk-faces.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/gtk-faces.el	Thu Dec 20 05:49:48 2001 +0000
@@ -61,7 +61,7 @@
   (if (not (eq (device-type device) 'gtk))
       nil
     (gtk-init-pointers)
-    '(let* ((style (gtk-style-info device))
+    (let* ((style (gtk-style-info device))
 	   ;;(normal 0)			; GTK_STATE_NORMAL
 	   ;;(active 1)			; GTK_STATE_ACTIVE
 	   (prelight 2)			; GTK_STATE_PRELIGHT
--- a/lisp/menubar.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/menubar.el	Thu Dec 20 05:49:48 2001 +0000
@@ -671,6 +671,10 @@
 
 MENU-DESC and EVENT are as in the call to `popup-menu'."
   ;; partially stolen from w3
+
+  ;; This function is way gross and assumes to much about menu
+  ;; processing that is X specific. Under mswindows popup menus behave
+  ;; in reasonable ways that you can't obstruct.
   (let ((echo-keystrokes 0)
 	new-event)
     (popup-menu menu-desc event)
@@ -679,14 +683,22 @@
 	(setq new-event (next-command-event new-event))
 	(cond ((misc-user-event-p new-event)
 	       (throw 'popup-done new-event))
-	      ((not (popup-up-p))
+	      ((button-release-event-p new-event);; don't beep twice
+	       nil)
+	      ;; It shows how bogus this function is that the event
+	      ;; arg could be missing and no-one noticed ...
+	      ((event-matches-key-specifier-p new-event (quit-char))
+	       (signal 'quit nil))
+	      ;; mswindows has no pop-down processing (selection is
+	      ;; atomic) so doing anything more makes no sense. Since
+	      ;; popup-up-p is always false under mswindows, this
+	      ;; function has been ordered to do essentially X-specifc
+	      ;; processing after this check.
+	      ((not (popup-up-p))	
 	       (setq unread-command-events (cons new-event
 						 unread-command-events))
 	       (throw 'popup-done nil))
-	      ((button-release-event-p new-event);; don't beep twice
-	       nil)
-	      ((event-matches-key-specifier-p (quit-char))
-	       (signal 'quit nil))
+	      ;; mswindows never gets here
 	      (t
 	       (beep)
 	       (message "please make a choice from the menu.")))))))
--- a/lisp/package-get.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/package-get.el	Thu Dec 20 05:49:48 2001 +0000
@@ -571,7 +571,8 @@
 	      (if (not (package-get (car pkg) nil 'never))
 		  (throw 'exit nil)		;; Bail out if error detected
 		  ))
-	    packages-package-list)))
+	    packages-package-list))
+  (package-net-update-installed-db))
 
 ;;;###autoload
 (defun package-get-all (package version &optional fetched-packages install-dir)
--- a/lisp/package-net.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/package-net.el	Thu Dec 20 05:49:48 2001 +0000
@@ -82,6 +82,9 @@
 (defvar package-net-win32-binary-size 0
   "The size in bytes of the win32 binary distribution.")
 
+(defvar package-net-kit-version ""
+  "XEmacs kitting revision, usually empty.")
+
 (defvar package-net-setup-version "1.0"
   "The version string of setup.")
 
@@ -90,68 +93,6 @@
   (file-truename (concat data-directory "../../" (if (eq system-type 'cygwin32)
 						     "xemacs/setup/" "setup/"))))
 
-(defun package-net-convert-index-to-ini (&optional destdir remote version)
-  "Convert the package index to ini file format in DESTDIR.
-DESTDIR defaults to the value of `data-directory'."
-  (package-get-require-base remote)
-
-  (setq destdir (file-name-as-directory (or destdir data-directory)))
-  (let ((buf (get-buffer-create "*setup.ini*")))
-    (unwind-protect
-        (save-excursion
-          (set-buffer buf)
-          (erase-buffer buf)
-          (goto-char (point-min))
-          (let ((entries package-get-base) entry plist)
-	    (insert "# This file is automatically generated.  If you edit it, your\n")
-	    (insert "# edits will be discarded next time the file is generated.\n")
-	    (insert "#\n\n")
-	    (insert (format "setup-timestamp: %d\n" 
-			    (+ (* (car (current-time)) 65536) (car (cdr (current-time))))))
-	    (insert (format "setup-version: %s\n\n" (or version "1.0")))
-	    ;; Native version
-	    (insert (format "@ %s\n" "xemacs-i386-pc-win32"))
-	    (insert (format "version: %s\n" emacs-program-version))
-	    (insert "type: native\n")
-	    (insert (format "install: binaries/win32/%s %d\n\n"
-			    (concat emacs-program-name
-				    "-i386-pc-win32-"
-				    emacs-program-version ".tar.gz")
-			    package-net-win32-binary-size))
-	    ;; Cygwin version
-	    (insert (format "@ %s\n" "xemacs-i686-pc-cygwin32"))
-	    (insert (format "version: %s\n" emacs-program-version))
-	    (insert "type: cygwin\n")
-	    (insert (format "install: binaries/cygwin32/%s %d\n\n"
-			    (concat emacs-program-name
-				    "-i686-pc-cygwin32-"
-				    emacs-program-version ".tar.gz") 
-			    package-net-cygwin32-binary-size))
-	    ;; Standard packages
-	    (while entries
-	      (setq entry (car entries))
-	      (setq plist (car (cdr entry)))
-	      ;; ignore mule packages
-	      (unless (or (memq 'mule-base (plist-get plist 'requires))
-			  (eq 'mule-base (car entry)))
-		(insert (format "@ %s\n" (symbol-name (car entry))))
-		(insert (format "version: %s\n" (plist-get plist 'version)))
-		(insert (format "install: packages/%s %s\n" (plist-get plist 'filename)
-				(plist-get plist 'size)))
-	      ;; These are not supported as yet
-	      ;;
-	      ;; (insert (format "source: %s\n" (plist-get plist 'source)))
-	      ;; (insert "[prev]\n")
-	      ;; (insert (format "version: %s\n" (plist-get plist 'version)))
-	      ;; (insert (format "install: %s\n" (plist-get plist 'filename)))
-	      ;; (insert (format "source: %s\n" (plist-get plist 'source)))
-		(insert "\n"))
-	      (setq entries (cdr entries))))
-	  (insert "# setup.ini file ends here\n")
-	  (write-region (point-min) (point-max) (concat destdir "setup.ini")))
-      (kill-buffer buf))))
-
-
 (defun package-net-generate-bin-ini (&optional version)
   "Convert the package index to ini file format in the current directory."
   (let ((buf (get-buffer-create "*setup-bin.ini*")))
@@ -168,21 +109,25 @@
 	  (insert (format "setup-version: %s\n\n" (or version "1.0")))
 	  ;; Native version
 	  (insert (format "@ %s\n" "xemacs-i586-pc-win32"))
-	  (insert (format "version: %s\n" emacs-program-version))
+	  (insert (format "version: %s%s\n" emacs-program-version 
+			  package-net-kit-version))
 	  (insert "type: native\n")
 	  (insert (format "install: win32/%s %d\n\n"
 			  (concat emacs-program-name
 				  "-i586-pc-win32-"
-				    emacs-program-version ".tar.gz")
+				    emacs-program-version package-net-kit-version 
+				    ".tar.gz")
 			  package-net-win32-binary-size))
 	  ;; Cygwin version
 	  (insert (format "@ %s\n" "xemacs-i686-pc-cygwin"))
-	  (insert (format "version: %s\n" emacs-program-version))
+	  (insert (format "version: %s%s\n" emacs-program-version 
+			  package-net-kit-version))
 	  (insert "type: cygwin\n")
 	  (insert (format "install: cygwin32/%s %d\n\n"
 			  (concat emacs-program-name
 				  "-i686-pc-cygwin-"
-				  emacs-program-version ".tar.gz") 
+				  emacs-program-version package-net-kit-version
+				  ".tar.gz") 
 			  package-net-cygwin32-binary-size))
 	  (insert "# setup.ini file ends here\n")
 	  (write-region (point-min) (point-max) "setup-bin.ini")))
--- a/lisp/printer.el	Wed Dec 19 00:40:26 2001 +0000
+++ b/lisp/printer.el	Thu Dec 20 05:49:48 2001 +0000
@@ -310,7 +310,10 @@
 	 ;; re-create the frame each time so that we eject the piece
 	 ;; of paper at the end even if we're printing more than one
 	 ;; page per sheet of paper.
-	 (let ((copies (plist-get props 'copies 1)))
+	 (let ((copies (plist-get props 'copies 1))
+	       ;; This is not relevant to printing and can mess up
+	       ;; msprinter frame sizing
+	       default-frame-plist)
 	   (while (> copies 0)
 	     (let (d f header-buffer footer-buffer)
 	       (setq buffer (decode-buffer buffer))
@@ -443,5 +446,5 @@
 	     (setq copies (1- copies)))))
 	((and (not (eq system-type 'windows-nt))
 	      (fboundp 'lpr-region))
-	 (lpr-region buffer))
+	 (lpr-region (point-min) (point-max)))
 	(t (error "No print support available"))))
--- a/man/lispref/glyphs.texi	Wed Dec 19 00:40:26 2001 +0000
+++ b/man/lispref/glyphs.texi	Thu Dec 20 05:49:48 2001 +0000
@@ -36,6 +36,7 @@
 * Redisplay Glyphs::    Glyphs controlling various redisplay functions.
 * Subwindows::          Inserting an externally-controlled subwindow
                           into a buffer.
+* Glyph Examples::      Examples of how to work with glyphs.
 @end menu
 
 @node Glyph Functions
@@ -1380,3 +1381,199 @@
 @defun subwindowp object
 This function returns non-@code{nil} if @var{object} is a subwindow.
 @end defun
+
+@node Glyph Examples
+@section Glyph Examples
+
+For many applications, displaying graphics is a simple process: you
+create a glyph, and then you insert it into a buffer.
+
+The easiest way to create a glyph is to use a file that contains a
+graphical image, such as a JPEG, TIFF, or PNG file:
+
+@lisp
+;; Create a glyph from a JPEG file:
+(setq foo (make-glyph [jpeg :file "/tmp/file1.jpg"]))
+@end lisp
+
+@lisp
+;; Create a glyph from a XPM file:
+(setq foo (make-glyph [xpm :file "/tmp/file2.xpm"]))
+@end lisp
+
+@lisp
+;; Create a glyph from a PNG file:
+(setq foo (make-glyph [png :file "/tmp/file3.png"]))
+@end lisp
+
+@lisp
+;; Create a glyph from a TIFF file:
+(setq foo (make-glyph [tiff :file "/tmp/file4.tiff"]))
+@end lisp
+
+The parameters passed to @code{make-glyph} are called "Image
+Specifiers", and can handle more image types than those shown above.
+You can also put the raw image data into a string (e.g., if you put the
+contents of a JPEG file into a string), and use that to create a glyph.
+@xref{Image Specifiers}, for more information.
+
+@quotation
+@strong{Caution}: In order for XEmacs to read a particular graphics file
+format, support for that format must have been compiled into XEmacs.
+It's possible, although somewhat unlikely, for XEmacs to have been
+compiled without support for any of the various graphics file formats.
+To see what graphics formats your particular version of XEmacs supports,
+use @kbd{M-x describe-installation}.
+
+To programmatically query whether or not a particular file format is
+supported, you can use the @code{featurep} function, with one of:
+@code{gif}, @code{tiff}, @code{jpeg}, @code{xpm}, @code{xbm},
+@code{png}, or @code{xface}.  For an up-to-date list, @ref{Image
+Specifiers}.  Example:
+
+@example
+;; Returns `t' if TIFF is supported:
+(featurep 'tiff)
+@end example
+
+Another example is:
+
+@example
+;; Returns a list of `t' or `nil', depending on whether or not the
+;; corresponding feature is supported:
+(mapcar #'(lambda (format-symbol) (featurep format-symbol))
+        '(gif tiff jpeg xpm png))
+@end example
+
+@end quotation
+
+Once you have a glyph, you can then insert it into a buffer.  Example:
+
+@lisp
+;; Use this function to insert a glyph at the left edge of point in the
+;; current buffer.  Any existing glyph at this location is replaced.
+(defun insert-glyph (gl)
+  "Insert a glyph at the left edge of point."
+  (let ( (prop 'myimage)        ;; myimage is an arbitrary name, chosen 
+                                ;; to (hopefully) not conflict with any
+                                ;; other properties.  Change it if
+                                ;; necessary.
+         extent )
+    ;; First, check to see if one of our extents already exists at
+    ;; point.  For ease-of-programming, we are creating and using our
+    ;; own extents (multiple extents are allowed to exist/overlap at the
+    ;; same point, and it's quite possible for other applications to
+    ;; embed extents in the current buffer without your knowledge).
+    ;; Basically, if an extent, with the property stored in "prop",
+    ;; exists at point, we assume that it is one of ours, and we re-use
+    ;; it (this is why it is important for the property stored in "prop"
+    ;; to be unique, and only used by us).
+    (if (not (setq extent (extent-at (point) (current-buffer) prop)))
+      (progn
+        ;; If an extent does not already exist, create a zero-length
+        ;; extent, and give it our special property.
+        (setq extent (make-extent (point) (point) (current-buffer)))
+        (set-extent-property extent prop t)
+        ))
+    ;; Display the glyph by storing it as the extent's "begin-glyph".
+    (set-extent-property extent 'begin-glyph gl)
+    ))
+
+;; You can then use this function like:
+(insert-glyph (make-glyph [jpeg :file "/tmp/file1.jpg"]))
+;; This will insert the glyph at point.
+
+;; Here's an example of how to insert two glyphs side-by-side, at point
+;; (using the above code):
+(progn
+  (insert-glyph (make-glyph [jpeg :file "/tmp/file1.jpg"]))
+  ;; Create a new extent at point.  We can't simply call "insert-glyph",
+  ;; as "insert-glyph" will simply replace the first glyph with the
+  ;; second.
+  (setq extent (make-extent (point) (point) (current-buffer)))
+  ;; Here, we're only setting the 'myimage property in case we need
+  ;; to later identify/locate/reuse this particular extent.
+  (set-extent-property extent 'myimage t)
+  (set-extent-property extent 'begin-glyph
+                       (make-glyph [jpeg :file "/tmp/file2.jpg"]))
+  )
+
+@end lisp
+
+Here are the gory details:
+
+@itemize @bullet
+
+@item
+Glyphs are displayed by attaching them to extents (see @ref{Extents}),
+either to the beginning or the end of extents.
+
+Note that extents can be used for many things, and not just for
+displaying images (although, in the above example, we are creating our
+own extent for the sole purpose of displaying an image).  Also, note
+that multiple extents are allowed to exist at the same position, and
+they can overlap.
+
+@item
+Glyphs are often displayed inside the text area (alongside text).  This
+is the default.
+
+Although glyphs can also be displayed in the margins, how to do this
+will not be described here.  For more information on this, see
+@ref{Annotation Basics} (look for information on "layout types") and
+@ref{Extent Properties} (look for @code{begin-glyph-layout} and
+@code{end-glyph-layout}).
+
+@item
+The easiest way to insert a glyph into text is to create a zero-length
+extent at the point where you want the glyph to appear.
+
+Note that zero-length extents are attached to the character to the
+right of the extent; deleting this character will also delete the extent.
+
+@item
+It's often a good idea to assign a unique property to the newly-created
+extent, in case you later want to locate it, and replace any existing
+glyph with a different one (or just delete the existing one).  In the
+above example, we are using "myimage" as our (hopefully) unique property
+name.
+
+If you need to locate all of the extents, you'll have to use functions
+like @code{extent-list} or @code{next-extent}, or provide additional
+parameters to the @code{extent-at} function.  Assigning a unique
+property to the extent makes it easy to locate your extents; for
+example, @code{extent-list} can return only those extents with a
+particular property.  @xref{Finding Extents}, and @ref{Mapping Over
+Extents}, for more information.
+
+@item
+Glyphs are displayed by assigning then to the @code{begin-glyph} or
+@code{end-glyph} property of the extent.  For zero-length extents, it
+doesn't really matter if you assign the glyph to the @code{begin-glyph}
+or @code{end-glyph} property, as they are both at the same location;
+however, for non-zero-length extents (extents that cover one or more
+characters of text), it does matter which one you use.
+
+Assigning @code{nil} to the @code{begin-glyph} or @code{end-glyph}
+property will delete any existing glyph.  In this case, you may also
+want to delete the extent, assuming that the extent is used for no other
+purpose.
+
+@item
+If you happen to insert two glyphs, side-by-side, note that the example
+@code{insert-glyph} function will have trouble, if it's again used at
+the same point (it can only locate one of the two extents).
+@xref{Finding Extents}, and @ref{Mapping Over Extents}, for more
+information on locating extents in a buffer.
+
+@item
+Among other things, glyphs provide a way of displaying graphics
+alongside text.  Note, however, that glyphs only provide a way of
+displaying graphics; glyphs are not actually part of the text, and are
+only displayed alongside the text.  If you save the text in the buffer,
+the graphics are not saved.  The low-level glyph code does not provide a
+way of saving graphics with the text.  If you need to save graphics and
+text, you have to write your own code to do this, and this topic is
+outside the scope of this discussion.
+
+@end itemize
--- a/man/lispref/lispref.texi	Wed Dec 19 00:40:26 2001 +0000
+++ b/man/lispref/lispref.texi	Thu Dec 20 05:49:48 2001 +0000
@@ -1000,6 +1000,7 @@
 * Redisplay Glyphs::    Glyphs controlling various redisplay functions.
 * Subwindows::          Inserting an externally-controlled subwindow
                           into a buffer.
+* Glyph Examples::      Examples of how to work with glyphs.
 
 Glyph Functions
 
--- a/netinstall/ChangeLog	Wed Dec 19 00:40:26 2001 +0000
+++ b/netinstall/ChangeLog	Thu Dec 20 05:49:48 2001 +0000
@@ -1,3 +1,43 @@
+2001-12-12  Andy Piper  <andy@xemacs.org>
+
+	* win32.h (CDECL): reorder to remove warnings.
+
+	* Makefile.in.in: add new dependencies.
+
+	* desktop.h: new file.
+
+	* uninstall.cc: use it.
+
+	* install.cc (uninstall_one): when uninstalling xemacs remove
+	shortcuts also.
+
+	* desktop.cc (remove_xemacs_setup): split out from
+	remove_desktop_setup.
+	(remove_desktop_setup): call it.
+
+2001-12-05  Andy Piper  <andy@xemacs.org>
+
+	* win32.h: re-order declarations for native windows from Fabrice
+	Popineau.
+
+2001-11-22  Andy Piper  <andy@xemacs.org>
+
+	* Makefile.in.in (setup-bin.ini): cope with kit revisions.
+
+	* source.cc (save_dialog): warning removal.
+	(load_dialog): ditto.
+
+	* msg.cc: remove cvs id.
+
+	* desktop.cc (find_xemacs_version): new function. Cope with kit
+	revisions.
+	(find_xemacs_exe_path): use it.
+	(find_xemacs_exe_name): ditto.
+
+2001-11-21  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* XEmacs 21.4.6 "Common Lisp" is released.
+
 2001-10-27  Andy Piper  <andy@xemacs.org>
 
 	* localdir.cc (dialog_cmd): allow download directory to be
@@ -349,7 +389,7 @@
 
 	* all: port from cygwin setup.
 
-%%% $Id: ChangeLog,v 1.10 2001/10/30 05:13:28 andyp Exp $
-$Revision: 1.10 $
+%%% $Id: ChangeLog,v 1.11 2001/12/20 05:49:40 andyp Exp $
+$Revision: 1.11 $
 
 
--- a/netinstall/Makefile.in.in	Wed Dec 19 00:40:26 2001 +0000
+++ b/netinstall/Makefile.in.in	Thu Dec 20 05:49:48 2001 +0000
@@ -96,6 +96,7 @@
 
 CYGWIN_SIZE=0
 WIN32_SIZE=0
+KIT_VERSION=""
 
 CONFIG_H = ../src/config.h
 
@@ -162,6 +163,7 @@
 	$(XEMACS) -batch -vanilla \
 		-eval '(setq package-net-cygwin32-binary-size $(CYGWIN_SIZE) \
 			package-net-win32-binary-size $(WIN32_SIZE) \
+			package-net-kit-version "$(KIT_VERSION)" \
 			package-net-setup-version "'$$V'")' \
 		-l ${srcdir}/../lisp/package-net.el \
 		-f package-net-batch-generate-bin-ini
@@ -215,7 +217,7 @@
  msg.h log.h find.h reginfo.h
 concat.o: concat.cc
 desktop.o: desktop.cc win32.h resource.h ini.h msg.h state.h concat.h \
- mkdir.h dialog.h version.h port.h reginfo.h
+ mkdir.h dialog.h version.h port.h reginfo.h desktop.h
 dialog.o: dialog.cc win32.h dialog.h msg.h log.h
 diskfull.o: diskfull.cc win32.h diskfull.h
 download.o: download.cc win32.h resource.h msg.h ini.h dialog.h \
@@ -236,11 +238,11 @@
  port.h
 install.o: install.cc win32.h \
  resource.h ini.h dialog.h concat.h geturl.h mkdir.h state.h tar.h \
- diskfull.h msg.h regedit.h reginfo.h log.h hash.h port.h
+ diskfull.h msg.h regedit.h reginfo.h log.h hash.h port.h desktop.h
 init.o: init.cc win32.h resource.h dialog.h state.h msg.h log.h 
 uninstall.o: uninstall.cc win32.h \
  resource.h ini.h dialog.h concat.h geturl.h mkdir.h state.h tar.h \
- diskfull.h msg.h regedit.h reginfo.h log.h hash.h port.h
+ diskfull.h msg.h regedit.h reginfo.h log.h hash.h port.h desktop.h
 localdir.o: localdir.cc win32.h dialog.h resource.h state.h msg.h \
  concat.h log.h
 log.o: log.cc win32.h resource.h msg.h log.h dialog.h state.h concat.h \
--- a/netinstall/desktop.cc	Wed Dec 19 00:40:26 2001 +0000
+++ b/netinstall/desktop.cc	Thu Dec 20 05:49:48 2001 +0000
@@ -41,6 +41,7 @@
 #include "regedit.h"
 #include "port.h"
 #include "log.h"
+#include "desktop.h"
 
 extern "C" {
   void make_link_2 (char *exepath, char *args, char *icon, char *lname);
@@ -102,13 +103,23 @@
 }
 
 static char* 
+find_xemacs_version ()
+{
+  char* v = strdup (xemacs_package->info[xemacs_package->trust].version);
+  char* dash = strrchr (v, '-');
+  if (dash)
+    *dash = 0;
+  return v;
+}
+
+static char* 
 find_xemacs_exe_path ()
 {
   if (xemacs_package->type == TY_CYGWIN)
     return backslash (concat (root_dir, "/bin/", XEMACS_CYGWIN_ARCH_NAME, 0));
   else
     return backslash (concat (root_dir, "\\XEmacs-",
-			      xemacs_package->info[xemacs_package->trust].version, 
+			      find_xemacs_version (), 
 			      "\\", XEMACS_NATIVE_ARCH_NAME, 0));
 }
 
@@ -121,7 +132,7 @@
     return strdup ("runemacs.exe");
   else if (xemacs_package->type == TY_CYGWIN)
     return backslash (concat ("xemacs-",
-			      xemacs_package->info[xemacs_package->trust].version, 
+			      find_xemacs_version (), 
 			      ".exe", 0));
   else
     return strdup ("xemacs.exe");
@@ -220,21 +231,27 @@
 }
 
 void
-remove_desktop_setup()
+remove_xemacs_setup()
 {
+  if (xemacs_package == 0)
+    return;
+
   start_menu ("XEmacs", 0, 1, 0);
-  start_menu ("Uninstall XEmacs", 0, 1, 0);
-  start_menu (0, 0, 1, 0);
   desktop_icon ("XEmacs", 0, 1);
 
-  if (xemacs_package != 0)
-    {
 #define FROB(exe)	  remove_app_path (exe)
-      FROB (find_xemacs_exe_name ());
-      FROB ("runemacs.exe");
-      FROB ("xemacs.exe");
+  FROB (find_xemacs_exe_name ());
+  FROB ("runemacs.exe");
+  FROB ("xemacs.exe");
 #undef FROB
-    }
+}
+
+void
+remove_desktop_setup()
+{
+  remove_xemacs_setup();
+  start_menu ("Uninstall XEmacs", 0, 1, 0);
+  start_menu (0, 0, 1, 0);
 }
 
 static void
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/netinstall/desktop.h	Thu Dec 20 05:49:48 2001 +0000
@@ -0,0 +1,23 @@
+/* 
+   Copyright (C) 2001 Andy Piper.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+extern void remove_desktop_setup ();
+extern void remove_xemacs_setup ();
+extern char* find_xemacs_exe_name();
--- a/netinstall/install.cc	Wed Dec 19 00:40:26 2001 +0000
+++ b/netinstall/install.cc	Thu Dec 20 05:49:48 2001 +0000
@@ -47,7 +47,7 @@
 #include "reginfo.h"
 #include "log.h"
 #include "hash.h"
-
+#include "desktop.h"
 #include "port.h"
 
 static HWND ins_dialog = 0;
@@ -231,6 +231,10 @@
     {
       SetWindowText (ins_pkgname, name);
       SetWindowText (ins_action, "Uninstalling...");
+      // remove shortcuts and registry entries
+      if (type != TY_GENERIC)
+	remove_xemacs_setup();
+
       if (action == ACTION_UPGRADE)
 	log (0, "Uninstalling old %s", name);
       else
--- a/netinstall/source.cc	Wed Dec 19 00:40:26 2001 +0000
+++ b/netinstall/source.cc	Thu Dec 20 05:49:48 2001 +0000
@@ -29,22 +29,14 @@
 static int rb[] = { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, IDC_SOURCE_CWD, 0 };
 
 static void
-check_if_enable_next (HWND h)
-{
-  EnableWindow (GetDlgItem (h, IDOK), source ? 1 : 0);
-}
-
-static void
 load_dialog (HWND h)
 {
-  int i;
   rbset (h, rb, source);
 }
 
 static void
 save_dialog (HWND h)
 {
-  int i;
   source = rbget (h, rb);
 }
 
--- a/netinstall/uninstall.cc	Wed Dec 19 00:40:26 2001 +0000
+++ b/netinstall/uninstall.cc	Thu Dec 20 05:49:48 2001 +0000
@@ -48,6 +48,7 @@
 #include "reginfo.h"
 #include "log.h"
 #include "hash.h"
+#include "desktop.h"
 
 #include "port.h"
 
@@ -66,9 +67,7 @@
 static int uninstall_started = 0;
 
 extern char * map_filename (char *fn, int type);
-void remove_desktop_setup ();
 static void start_uninstall ();
-extern char* find_xemacs_exe_name();
 
 char *
 base (char *s);
--- a/netinstall/win32.h	Wed Dec 19 00:40:26 2001 +0000
+++ b/netinstall/win32.h	Thu Dec 20 05:49:48 2001 +0000
@@ -23,14 +23,6 @@
 
 #define NOCOMATTRIBUTE
 
-#include <stdarg.h>
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include <wininet.h>
-#include <windowsx.h>
-
 /* Cope with native win32 & mingw differences.  Written by F. Popineau
    <Fabrice.Popineau@supelec.fr> */
 #ifdef WIN32_NATIVE
@@ -40,6 +32,14 @@
 #  define strnicmp _strnicmp
 #endif
 
+#include <stdarg.h>
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include <wininet.h>
+#include <windowsx.h>
+
 #ifndef CDECL
 #define CDECL __cdecl
 #endif
--- a/src/ChangeLog	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/ChangeLog	Thu Dec 20 05:49:48 2001 +0000
@@ -1,3 +1,93 @@
+2001-12-11  Andy Piper  <andy@xemacs.org>
+
+	* dialog-msw.c (dialog_popped_down): new function. unset popup_up_p.
+	* dialog-msw.c (mswindows_make_dialog_box_internal): set
+	popup_up_p.
+	* menubar-msw.c (unsafe_handle_wm_initmenupopup_1): ditto.
+	* menubar-msw.c (mswindows_handle_wm_command): ditto.
+	* menubar-msw.c (mswindows_popup_menu): ditto.
+
+2001-11-24  Andy Piper  <andy@xemacs.org>
+
+	* window.c (Fsplit_window): Doc return type.
+
+2001-07-30  Adrian Aichner  <adrian@xemacs.org>
+
+	* event-msw.c: Typo fix.
+	* event-msw.c (mswindows_wnd_proc): Set FRAME_VISIBLE_P after
+	magic XM_MAPFRAME event has been sent.
+
+2001-11-23  Andy Piper  <andy@xemacs.org>
+
+	* event-msw.c (mswindows_wnd_proc): Don't pump mousewheel events.
+
+2001-11-21  Andy Piper  <andy@xemacs.org>
+
+	* scrollbar-msw.c (mswindows_handle_mousewheel_event): cope with
+	mouse events outside the frame.
+
+2001-11-15  Andy Piper  <andy@xemacs.org>
+
+	(Fmswindows_shell_execute): fix handling of URL's under cygwin (again).
+
+2001-11-14  Andy Piper  <andy@xemacs.org>
+
+	* nt.c (REG_ROOT): change registry key to XEmacs.
+
+2001-10-29  Andy Piper  <andy@xemacs.org>
+
+	* dialog-msw.c (handle_directory_dialog_box): quit if the user
+	cancels.
+
+2001-12-16  Torsten Duwe  <duwe@caldera.de>
+
+	* search.c (Freplace_match): Add missing sub-expression functionality.
+
+	* buffer.c (decode_buffer): Add a check for pointer type to
+	decode_buffer, before gcc's CSE optimization reorders a
+	dereference in front of the allow_string test.
+
+2001-11-16  Darryl Okahata  <darrylo@xemacs.org>
+
+	* window.c (window_loop): Fix bug that sometimes prevented
+	window_loop() from iterating across multiple devices.  Also, at
+	Ben's request, changed infloop-detecting code to abort() instead
+	of silently terminating window_loop().
+
+2001-11-21  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	Based on analysis and patch by Simon Josefson <jas@extundo.com>.
+	* editfns.c (make_time): New function.
+	(Fencode_time): Use it instead of wasteful_word_to_lisp.
+	* lisp.h (make_time): Prototype and comment it.
+	* dired.c (wasteful_word_to_lisp): Deprecate.
+	(Ffile_attributes): Use make_time() instead of wasteful_word_to_lisp().
+
+2001-10-31  Kyle Jones  <kyle_jones@wonderworks.com>
+
+	* fileio.c (auto_save_1): Use current coding system, not
+	escape-quoted.
+
+2001-11-13  Ben Wing  <ben@xemacs.org>
+
+	* window.c:
+	* window.c (window_truncation_on):
+	* window.c (syms_of_window):
+	truncate-partial-width-windows should respect the buffer being
+	displayed, like other redisplay vars.
+
+2001-11-13  Hirokazu FUKUI  <hfukui@sannet.ne.jp>
+
+	* event-stream.c (Fread_key_sequence): save current buffer.
+
+2001-10-29  Andrew Begel  <abegel@eecs.berkeley.edu>
+
+	* ntheap.c (_heap_init): Don't redefine in VS.NET (MSC >= 1300).
+
+2001-10-29  Andrew Begel  <abegel@eecs.berkeley.edu>
+
+	* alloc.c (lcrecord_stats): Add space for types defined in modules.
+
 2001-12-18  Adrian Aichner  <adrian@xemacs.org>
 
 	* .cvsignore: Sort lines, add dump-id.c.
--- a/src/alloc.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/alloc.c	Thu Dec 20 05:49:48 2001 +0000
@@ -2472,7 +2472,8 @@
   int instances_freed;
   int bytes_freed;
   int instances_on_free_list;
-} lcrecord_stats [countof (lrecord_implementations_table)];
+} lcrecord_stats [countof (lrecord_implementations_table)
+		  + MODULE_DEFINABLE_TYPE_COUNT];
 
 static void
 tick_lcrecord_stats (const struct lrecord_header *h, int free_p)
--- a/src/buffer.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/buffer.c	Thu Dec 20 05:49:48 2001 +0000
@@ -354,7 +354,7 @@
 struct buffer *
 decode_buffer (Lisp_Object buffer, int allow_string)
 {
-  if (NILP (buffer))
+  if (NILP (buffer) || (!POINTER_TYPE_P( XTYPE(buffer))))
     return current_buffer;
 
   if (allow_string && STRINGP (buffer))
--- a/src/dialog-msw.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/dialog-msw.c	Thu Dec 20 05:49:48 2001 +0000
@@ -285,6 +285,13 @@
   return arg;
 }
 
+/* Unwind protection decrements dialog count */
+static Lisp_Object
+dialog_popped_down (Lisp_Object arg)
+{
+  popup_up_p--;
+}
+
 
 #define ALIGN_TEMPLATE					\
 {							\
@@ -434,12 +441,13 @@
 	pMalloc->lpVtbl->Free(pMalloc, pidl);
 	pMalloc->lpVtbl->Release(pMalloc);
 	return ret;
-      } 
+      }
       else if (pd.unknown_fname != 0) {
 	ret = tstr_to_local_file_format (pd.unknown_fname);
 	xfree(pd.unknown_fname);
       }
-      
+      else while (1)
+	signal_quit ();
     }
   else
     signal_error (Qdialog_box_error,
@@ -792,16 +800,21 @@
 mswindows_make_dialog_box_internal (struct frame* f, Lisp_Object type,
 				    Lisp_Object keys)
 {
+  int unbind_count = specpdl_depth ();
+  record_unwind_protect (dialog_popped_down, Qnil);
+  popup_up_p++;
+
   if (EQ (type, Qfile))
-    return handle_file_dialog_box (f, keys);
+    return unbind_to (unbind_count, handle_file_dialog_box (f, keys));
   else if (EQ (type, Qdirectory))
-    return handle_directory_dialog_box (f, keys);
+    return unbind_to (unbind_count, handle_directory_dialog_box (f, keys));
   else if (EQ (type, Qquestion))
-    return handle_question_dialog_box (f, keys);
+    return unbind_to (unbind_count, handle_question_dialog_box (f, keys));
   else if (EQ (type, Qprint))
-    return mswindows_handle_print_dialog_box (f, keys);
+    return unbind_to (unbind_count, mswindows_handle_print_dialog_box (f, keys));
   else if (EQ (type, Qpage_setup))
-    return mswindows_handle_page_setup_dialog_box (f, keys);
+    return unbind_to (unbind_count, 
+		      mswindows_handle_page_setup_dialog_box (f, keys));
   else
     signal_error (Qunimplemented, "Dialog box type", type);
   return Qnil;
--- a/src/dired.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/dired.c	Thu Dec 20 05:49:48 2001 +0000
@@ -811,6 +811,9 @@
     return Qnil;
 }
 
+#if 0
+/* ... never used ... should use list2 directly anyway ... */
+/* NOTE: This function can never return a negative value. */
 Lisp_Object
 wasteful_word_to_lisp (unsigned int item)
 {
@@ -820,6 +823,7 @@
   XCDR (cons) = Fcons (XCDR (cons), Qnil);
   return cons;
 }
+#endif
 
 DEFUN ("file-attributes", Ffile_attributes, 1, 1, 0, /*
 Return a list of attributes of file FILENAME.
@@ -906,9 +910,9 @@
   values[1] = make_int (s.st_nlink);
   values[2] = make_int (s.st_uid);
   values[3] = make_int (s.st_gid);
-  values[4] = wasteful_word_to_lisp (s.st_atime);
-  values[5] = wasteful_word_to_lisp (s.st_mtime);
-  values[6] = wasteful_word_to_lisp (s.st_ctime);
+  values[4] = make_time (s.st_atime);
+  values[5] = make_time (s.st_mtime);
+  values[6] = make_time (s.st_ctime);
   values[7] = make_int ((EMACS_INT) s.st_size);
   /* If the size is out of range, give back -1.  */
   /* #### Fix when Emacs gets bignums! */
--- a/src/editfns.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/editfns.c	Thu Dec 20 05:49:48 2001 +0000
@@ -1176,6 +1176,15 @@
 
 static void set_time_zone_rule (char *tzstring);
 
+/* from GNU Emacs 21, per Simon Josefsson, modified by stephen
+   The slight inefficiency is justified since negative times are weird. */
+Lisp_Object
+make_time (time_t time)
+{
+  return list2 (make_int (time < 0 ? time / 0x10000 : time >> 16),
+		make_int (time & 0xFFFF));
+}
+
 DEFUN ("encode-time", Fencode_time, 6, MANY, 0, /*
   Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time.
 This is the reverse operation of `decode-time', which see.
@@ -1249,7 +1258,7 @@
   if (the_time == (time_t) -1)
     invalid_argument ("Specified time is not representable", Qunbound);
 
-  return wasteful_word_to_lisp (the_time);
+  return make_time (the_time);
 }
 
 DEFUN ("current-time-string", Fcurrent_time_string, 0, 1, 0, /*
--- a/src/event-msw.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/event-msw.c	Thu Dec 20 05:49:48 2001 +0000
@@ -2630,13 +2630,11 @@
 	  }
 	else if (IsWindowVisible (hwnd))
 	  {
-            /*
-               APA: It's too early here to set the frame visible.
-               Let's do this later, in WM_SIZE processing, after the
-               magic XM_MAPFRAME event has been sent (just like 21.1
-               did).
-            */
-            /* FRAME_VISIBLE_P (frame) = 1; */
+	    /* APA: It's too early here to set the frame visible.
+	     * Let's do this later, in WM_SIZE processing, after the
+	     * magic XM_MAPFRAME event has been sent (just like 21.1
+	     * did). */
+	    /* FRAME_VISIBLE_P (frame) = 1; */
 	    FRAME_ICONIFIED_P (frame) = 0;
 	  }
 	else
@@ -2701,12 +2699,10 @@
 		{
 		  if (!msframe->sizing && !FRAME_VISIBLE_P (frame))
 		    mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
-                  /*
-                     APA: Now that the magic XM_MAPFRAME event has
-                     been sent we can mark the frame as visible (just
-                     like 21.1 did).
-                  */
-                  FRAME_VISIBLE_P (frame) = 1;
+		  /* APA: Now that the magic XM_MAPFRAME event has
+		   * been sent we can mark the frame as visible (just
+		   * like 21.1 did). */
+		  FRAME_VISIBLE_P (frame) = 1;
 
 		  if (!msframe->sizing || mswindows_dynamic_frame_resize)
 		    redisplay ();
@@ -2829,20 +2825,14 @@
       {
 	int keys = LOWORD (wParam); /* Modifier key flags */
 	int delta = (short) HIWORD (wParam); /* Wheel rotation amount */
-	struct gcpro gcpro1, gcpro2;
 
 	if (mswindows_handle_mousewheel_event (mswindows_find_frame (hwnd),
 					       keys, delta,
 					       MAKEPOINTS (lParam)))
-	  {
-	    GCPRO2 (emacs_event, fobj);
-	    if (UNBOUNDP(mswindows_pump_outstanding_events ()))	/* Can GC */
-	      SendMessage (hwnd, WM_CANCELMODE, 0, 0);
-	    UNGCPRO;
-	  }
+	  /* We are not in a modal loop so no pumping is necessary. */
+	  break;
 	else
 	  goto defproc;
-	break;
       }
 #endif
 
--- a/src/event-stream.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/event-stream.c	Thu Dec 20 05:49:48 2001 +0000
@@ -4290,6 +4290,7 @@
   struct gcpro gcpro1;
   GCPRO1 (event);
 
+  record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
   if (!NILP (prompt))
     CHECK_STRING (prompt);
   /* else prompt = Fkeymap_prompt (current_buffer->keymap); may GC */
--- a/src/fileio.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/fileio.c	Thu Dec 20 05:49:48 2001 +0000
@@ -3789,8 +3789,8 @@
   return
     /* !!#### need to deal with this 'escape-quoted everywhere */
     Fwrite_region_internal (Qnil, Qnil, a, Qnil, Qlambda, Qnil,
-#ifdef MULE
-			    Qescape_quoted
+#ifdef FILE_CODING
+			    current_buffer->buffer_file_coding_system
 #else
 			    Qnil
 #endif
--- a/src/lisp.h	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/lisp.h	Thu Dec 20 05:49:48 2001 +0000
@@ -2416,6 +2416,9 @@
   arith_grtr_or_equal };
 Lisp_Object arithcompare (Lisp_Object, Lisp_Object, enum arith_comparison);
 
+/* Do NOT use word_to_lisp or wasteful_word_to_lisp to decode time_t's
+   unless you KNOW arg is non-negative.  They cannot return negative
+   values!  Use make_time.  */
 Lisp_Object word_to_lisp (unsigned int);
 unsigned int lisp_to_word (Lisp_Object);
 
@@ -2454,6 +2457,7 @@
 void buffer_insert1 (struct buffer *, Lisp_Object);
 Lisp_Object make_string_from_buffer (struct buffer *, Charbpos, Charcount);
 Lisp_Object make_string_from_buffer_no_extents (struct buffer *, Charbpos, Charcount);
+Lisp_Object make_time (time_t);
 Lisp_Object save_excursion_save (void);
 Lisp_Object save_restriction_save (void);
 Lisp_Object save_excursion_restore (Lisp_Object);
--- a/src/menubar-msw.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/menubar-msw.c	Thu Dec 20 05:49:48 2001 +0000
@@ -738,7 +738,7 @@
 
   Lisp_Object path, desc;
   struct gcpro gcpro1;
-
+  
   /* Find which guy is going to explode */
   path = Fgethash (hmenu_to_lisp_object (menu), current_hash_table, Qunbound);
   assert (!UNBOUNDP (path));
@@ -822,8 +822,7 @@
      breaks customize because the misc_event gets eval'ed in some
      circumstances. Don't change it back unless you can fix the
      customize problem also.*/
-  enqueue_misc_user_event (frame, fn, arg);
-  mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
+  mswindows_enqueue_misc_user_event (frame, fn, arg);
 
   UNGCPRO; /* data */
   return Qt;
@@ -917,6 +916,8 @@
 	eev = NULL;
     }
 
+  popup_up_p++;
+
   /* Default is to put the menu at the point (10, 10) in frame */
   if (eev)
     {
@@ -932,6 +933,8 @@
   CHECK_CONS (menu_desc);
   CHECK_STRING (XCAR (menu_desc));
 
+  menu_cleanup (f);
+
   current_menudesc = menu_desc;
   current_hash_table =
     make_lisp_hash_table (10, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
@@ -950,7 +953,15 @@
 
   DestroyMenu (menu);
 
-  /* Signal a signal if caught by Track...() modal loop */
+  /* A WM_COMMAND is not issued until TrackPopupMenu returns. This
+     makes setting popup_up_p fairly pointless since we cannot keep
+     the menu up and dispatch events. Furthermore, we seem to have
+     little control over what happens to the menu when we click. */
+  popup_up_p--;
+
+  /* Signal a signal if caught by Track...() modal loop. */
+  /* I think this is pointless, the code hasn't actually put us in a
+     modal loop at this time -- andyp. */
   mswindows_unmodalize_signal_maybe ();
 
   /* This is probably the only real reason for failure */
@@ -961,6 +972,8 @@
 			 menu_desc);
     }
   UNGCPRO;
+
+  return Qnil;
 }
 
 
--- a/src/nt.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/nt.c	Thu Dec 20 05:49:48 2001 +0000
@@ -507,7 +507,7 @@
 }
 #endif /* 0 */
 
-#define REG_ROOT "SOFTWARE\\GNU\\XEmacs"
+#define REG_ROOT "SOFTWARE\\XEmacs\\XEmacs"
 
 LPBYTE 
 nt_get_resource (char *key, LPDWORD lpdwtype)
--- a/src/ntheap.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/ntheap.c	Thu Dec 20 05:49:48 2001 +0000
@@ -291,13 +291,15 @@
     sbrk (need_to_alloc);
 }
 
-#if (_MSC_VER >= 1000)
+#if ((_MSC_VER >= 1000) && (_MSC_VER < 1300))
 
 /* MSVC 4.2 invokes these functions from mainCRTStartup to initialize
    a heap via HeapCreate.  They are normally defined by the runtime,
    but we override them here so that the unnecessary HeapCreate call
    is not performed.  */
 
+/* MSVC 7.0 does not allow you to redefine _heap_init or _heap_term. */
+
 int __cdecl
 _heap_init (void)
 {
--- a/src/scrollbar-msw.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/scrollbar-msw.c	Thu Dec 20 05:49:48 2001 +0000
@@ -330,40 +330,45 @@
 {
   int hasVertBar, hasHorzBar;	/* Indicates presence of scroll bars */
   unsigned wheelScrollLines = 0; /* Number of lines per wheel notch */
-  Lisp_Object win;
+  Lisp_Object win, corpore, sano;
   struct window_mirror *mirror;
+  int mene, _mene, tekel, upharsin;
+  Charbpos mens, sana;
+  Charcount in;
+  struct window *needle_in_haystack = 0;
   POINT donde_esta;
 
   donde_esta.x = where.x;
   donde_esta.y = where.y;
 
-  ScreenToClient (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), &donde_esta);
-
   /* Find the window to scroll */
-  {
-    int mene, _mene, tekel, upharsin;
-    Charbpos mens, sana;
-    Charcount in;
-    Lisp_Object corpore, sano;
-    struct window *needle_in_haystack;
 
-    pixel_to_glyph_translation (XFRAME (frame), donde_esta.x, donde_esta.y,
-				&mene, &_mene, &tekel, &upharsin,
-				&needle_in_haystack,
-				&mens, &sana, &in, &corpore, &sano);
+  /* The mouse event could actually occur outside of the emacs
+     frame. */
+  if (ScreenToClient (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 
+		      &donde_esta) != 0)
+    {
+      /* stderr_out ("donde_esta: %d %d\n", donde_esta.x, donde_esta.y); */
+      pixel_to_glyph_translation (XFRAME (frame), donde_esta.x, donde_esta.y,
+				  &mene, &_mene, &tekel, &upharsin,
+				  &needle_in_haystack,
+				  &mens, &sana, &in, &corpore, &sano);
+      
+      if (needle_in_haystack)
+	{
+	  XSETWINDOW (win, needle_in_haystack);
+	  /* stderr_out ("found needle\n");
+	     debug_print (win); */
+	}
+    }
+  
+  if (!needle_in_haystack)
+    {
+      win = FRAME_SELECTED_WINDOW (XFRAME (frame));
+      needle_in_haystack = XWINDOW (win);
+    }
 
-    if (needle_in_haystack)
-      {
-	XSETWINDOW (win, needle_in_haystack);
-      }
-    else
-      {
-	win = FRAME_SELECTED_WINDOW (XFRAME (frame));
-	needle_in_haystack = XWINDOW (win);
-      }
-
-    mirror = find_window_mirror (needle_in_haystack);
-  }
+  mirror = find_window_mirror (needle_in_haystack);
 
   /* Check that there is something to scroll */
   hasVertBar = can_scroll (mirror->scrollbar_vertical_instance);
--- a/src/search.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/search.c	Thu Dec 20 05:49:48 2001 +0000
@@ -2293,9 +2293,7 @@
     }
   else
     {
-      if (NILP (strbuffer))
-	sub = 0;
-      else
+      if (!NILP (strbuffer))
 	{
 	  CHECK_INT (strbuffer);
 	  sub = XINT (strbuffer);
@@ -2337,7 +2335,7 @@
     {
       /* Decide how to casify by examining the matched text. */
 
-      last = search_regs.end[0];
+      last = search_regs.end[sub];
       prevc = '\n';
       case_action = all_caps;
 
@@ -2348,7 +2346,7 @@
       some_nonuppercase_initial = 0;
       some_uppercase = 0;
 
-      for (pos = search_regs.start[0]; pos < last; pos++)
+      for (pos = search_regs.start[sub]; pos < last; pos++)
 	{
 	  if (NILP (string))
 	    c = BUF_FETCH_CHAR (buf, pos);
@@ -2564,8 +2562,8 @@
       return concat3 (before, replacement, after);
     }
 
-  mc_count = begin_multiple_change (buf, search_regs.start[0],
-				    search_regs.end[0]);
+  mc_count = begin_multiple_change (buf, search_regs.start[sub],
+				    search_regs.end[sub]);
 
   /* begin_multiple_change() records an unwind-protect, so we need to
      record this value now. */
@@ -2575,7 +2573,7 @@
      delete the original text.  This means that markers at the
      beginning or end of the original will float to the corresponding
      position in the replacement.  */
-  BUF_SET_PT (buf, search_regs.start[0]);
+  BUF_SET_PT (buf, search_regs.start[sub]);
   if (!NILP (literal))
     Finsert (1, &replacement);
   else
@@ -2586,11 +2584,21 @@
       GCPRO1 (replacement);
       for (strpos = 0; strpos < stlen; strpos++)
 	{
-	  Charcount offset = BUF_PT (buf) - search_regs.start[0];
+	  /* on the first iteration assert(offset==0),
+	     exactly complementing BUF_SET_PT() above.
+	     During the loop, it keeps track of the amount inserted.
+	   */
+	  Charcount offset = BUF_PT (buf) - search_regs.start[sub];
 
 	  c = string_char (XSTRING (replacement), strpos);
 	  if (c == '\\' && strpos < stlen - 1)
 	    {
+	      /* XXX FIXME: replacing just a substring non-literally
+		 using backslash refs to the match looks dangerous.  But
+		 <15366.18513.698042.156573@ns.caldera.de> from Torsten Duwe
+		 <duwe@caldera.de> claims Finsert_buffer_substring already
+		 handles this correctly.
+	      */
 	      c = string_char (XSTRING (replacement), ++strpos);
 	      if (c == '&')
 		Finsert_buffer_substring
@@ -2633,9 +2641,9 @@
       UNGCPRO;
     }
 
-  inslen = BUF_PT (buf) - (search_regs.start[0]);
-  buffer_delete_range (buf, search_regs.start[0] + inslen, search_regs.end[0] +
-		       inslen, 0);
+  inslen = BUF_PT (buf) - (search_regs.start[sub]);
+  buffer_delete_range (buf, search_regs.start[sub] + inslen,
+		       search_regs.end[sub] +  inslen, 0);
 
   if (case_action == all_caps)
     Fupcase_region (make_int (BUF_PT (buf) - inslen),
--- a/src/win32.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/win32.c	Thu Dec 20 05:49:48 2001 +0000
@@ -211,19 +211,25 @@
       if ((fname1 = strchr (doc, ':')) != NULL 
 	  && *++fname1 == '/' && *++fname1 == '/')
 	{
-	  fname1++;
-	  pos = fname1 - doc;
-	  if (!(isalpha (fname1[0]) && (IS_DEVICE_SEP (fname1[1]))))
+	  // URL-style if we get here, but we must only convert file
+	  // arguments, since win32 paths are illegal in http etc.
+	  if (strncmp (doc, "file://", 7) == 0)
 	    {
-	      sz = cygwin_posix_to_win32_path_list_buf_size (fname1);
-	      fname2 = alloca (sz + pos);
-	      strncpy (fname2, doc, pos);
-	      doc = fname2;
-	      fname2 += pos;
-	      cygwin_posix_to_win32_path_list (fname1, fname2);
+	      fname1++;
+	      pos = fname1 - doc;
+	      if (!(isalpha (fname1[0]) && (IS_DEVICE_SEP (fname1[1]))))
+		{
+		  sz = cygwin_posix_to_win32_path_list_buf_size (fname1);
+		  fname2 = alloca (sz + pos);
+		  strncpy (fname2, doc, pos);
+		  doc = fname2;
+		  fname2 += pos;
+		  cygwin_posix_to_win32_path_list (fname1, fname2);
+		}
 	    }
 	}
       else {
+	// Not URL-style, must be a straight filename.
 	LOCAL_TO_WIN32_FILE_FORMAT (document, doc);
       }
 #endif
--- a/src/window.c	Wed Dec 19 00:40:26 2001 +0000
+++ b/src/window.c	Thu Dec 20 05:49:48 2001 +0000
@@ -123,6 +123,8 @@
 /* List of freed window configurations with 1 - 10 windows. */
 static Lisp_Object Vwindow_configuration_free_list[10];
 
+Lisp_Object Qtruncate_partial_width_windows;
+
 #define SET_LAST_MODIFIED(w, cache_too)		\
 do {						\
   (w)->last_modified[CURRENT_DISP] = Qzero;	\
@@ -756,7 +758,8 @@
 
   /* If truncate_partial_width_windows is true and the window is not
      the full width of the frame it is truncated. */
-  if (truncate_partial_width_windows
+  if (!NILP (symbol_value_in_buffer (Qtruncate_partial_width_windows,
+				     w->buffer))
       && !(window_is_leftmost (w) && window_is_rightmost (w)))
     return 1;
 
@@ -2670,7 +2673,7 @@
 	 We can't just wait until we hit the first window again,
 	 because it might be deleted.  */
 
-      last_window = Fprevious_window (w, mini ? Qt : Qnil, frame_arg, Qt);
+      last_window = Fprevious_window (w, mini ? Qt : Qnil, frame_arg, device);
 
       best_window = Qnil;
       for (;;)
@@ -2685,7 +2688,17 @@
 	  /* Given the outstanding quality of the rest of this code,
 	     I feel no shame about putting this piece of shit in. */
 	  if (++lose_lose >= 500)
-	    return Qnil;
+	    {
+	      /* Call to abort() added by Darryl Okahata (16 Nov. 2001),
+	         at Ben's request, to catch any remaining bugs.
+
+		 If you find that XEmacs is aborting here, and you
+		 need to be up and running ASAP, it should be safe to
+		 comment out the following abort(), as long as you
+		 leave the "break;" alone.  */
+	      abort();
+	      break;	/* <--- KEEP THIS HERE!  Do not delete!  */
+	    }
 
 	  /* Note that we do not pay attention here to whether
 	     the frame is visible, since Fnext_window skips non-visible frames
@@ -3683,8 +3696,9 @@
 DEFUN ("split-window", Fsplit_window, 0, 3, "", /*
 Split WINDOW, putting SIZE lines in the first of the pair.
 WINDOW defaults to the selected one and SIZE to half its size.
-If optional third arg HORFLAG is non-nil, split side by side
-and put SIZE columns in the first of the pair.
+If optional third arg HORFLAG is non-nil, split side by side and put
+SIZE columns in the first of the pair. The newly created window is
+returned.
 */
        (window, size, horflag))
 {
@@ -6146,6 +6160,8 @@
   /* Qother in general.c */
 #endif
 
+  DEFSYMBOL (Qtruncate_partial_width_windows);
+  
   DEFSUBR (Fselected_window);
   DEFSUBR (Flast_nonminibuf_window);
   DEFSUBR (Fminibuffer_window);