diff lisp/win32-native.el @ 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 5aa1854ad537
children 79940b592197
line wrap: on
line diff
--- 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))