Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
610:45ba69404a1f | 611:38db05db9cb5 |
---|---|
1 ;;; win32-native.el --- Lisp routines for MS Windows. | 1 ;;; win32-native.el --- Lisp routines when running on native MS Windows. |
2 | 2 |
3 ;; Copyright (C) 1994 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1994 Free Software Foundation, Inc. |
4 ;; Copyright (C) 2000 Ben Wing. | 4 ;; Copyright (C) 2000 Ben Wing. |
5 | 5 |
6 ;; Maintainer: XEmacs Development Team | 6 ;; Maintainer: XEmacs Development Team |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with XEmacs; see the file COPYING. If not, write to the | 22 ;; along with XEmacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, 59 Temple Place - Suite 330, | 23 ;; Free Software Foundation, 59 Temple Place - Suite 330, |
24 ;; Boston, MA 02111-1307, USA. | 24 ;; Boston, MA 02111-1307, USA. |
25 | 25 |
26 ;;; Synched up with: Not synched with FSF. Almost completely divergent. | 26 ;;; Synched up with: Not in FSF. |
27 ;;; (FSF has stuff in w32-fns.el and term/w32-win.el.) | 27 ;;; (FSF has stuff in w32-fns.el and term/w32-win.el.) |
28 | 28 |
29 ;;; Commentary: | 29 ;;; Commentary: |
30 | 30 |
31 ;; This file is dumped with XEmacs for MS Windows (without cygwin). | 31 ;; This file is dumped with XEmacs for MS Windows (without cygwin). |
32 | 32 ;; It is for stuff that is used specifically when `system-type' eq |
33 ;; Based on NT Emacs version by Geoff Voelker (voelker@cs.washington.edu) | 33 ;; `windows-nt' (i.e. also applies to MinGW), and has nothing to do |
34 ;; with the `mswindows' device type. Thus, it probably applies in | |
35 ;; non-interactive mode as well, and it DOES NOT APPLY to Cygwin. | |
36 | |
37 ;; Based (originally) on NT Emacs version by Geoff Voelker | |
38 ;; (voelker@cs.washington.edu) | |
34 ;; Ported to XEmacs by Marc Paquette <marcpa@cam.org> | 39 ;; Ported to XEmacs by Marc Paquette <marcpa@cam.org> |
35 ;; Largely modified by Kirill M. Katsnelson <kkm@kis.ru> | 40 ;; Largely modified by Kirill M. Katsnelson <kkm@kis.ru> |
41 ;; Rewritten from scratch by Ben Wing <ben@xemacs.org>. No code in common | |
42 ;; with FSF. | |
36 | 43 |
37 ;;; Code: | 44 ;;; Code: |
38 | |
39 ;; The cmd.exe shell uses the "/c" switch instead of the "-c" switch | |
40 ;; for executing its command line argument (from simple.el). | |
41 ;; #### Oh if we had an alist of shells and their command switches. | |
42 (setq shell-command-switch "/c") | |
43 | 45 |
44 ;; For appending suffixes to directories and files in shell | 46 ;; For appending suffixes to directories and files in shell |
45 ;; completions. This screws up cygwin users so we leave it out for | 47 ;; completions. This screws up cygwin users so we leave it out for |
46 ;; now. Uncomment this if you only ever want to use cmd. | 48 ;; now. Uncomment this if you only ever want to use cmd. |
47 | 49 |
58 (setq grep-null-device "NUL") | 60 (setq grep-null-device "NUL") |
59 | 61 |
60 ;; Set the grep regexp to match entries with drive letters. | 62 ;; Set the grep regexp to match entries with drive letters. |
61 (setq grep-regexp-alist | 63 (setq grep-regexp-alist |
62 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3))) | 64 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3))) |
65 | |
66 (defvar mswindows-system-shells '("cmd" "cmd.exe" "command" "command.com" | |
67 "4nt" "4nt.exe" "4dos" "4dos.exe" | |
68 "ndos" "ndos.exe") | |
69 "List of strings recognized as Windows NT/9X system shells. | |
70 These are shells with native semantics, e.g. they use `/c', not '-c', | |
71 to pass a command in.") | |
72 | |
73 (defun mswindows-system-shell-p (shell-name) | |
74 (member (downcase (file-name-nondirectory shell-name)) | |
75 mswindows-system-shells)) | |
76 | |
77 (defun init-mswindows-at-startup () | |
78 ;; shell-file-name is initialized in the C code (callproc.c) from | |
79 ;; SHELL or COMSPEC. | |
80 ;; #### If only shell-command-switch could be a function. But there | |
81 ;; is code littered around that uses it. | |
82 ;; #### Maybe we should set a symbol-value handler on `shell-file-name' | |
83 ;; that automatically sets shell-command-switch? | |
84 (if (mswindows-system-shell-p shell-file-name) | |
85 (setq shell-command-switch "/c"))) | |
63 | 86 |
64 ;;---------------------------------------------------------------------- | 87 ;;---------------------------------------------------------------------- |
65 ;; Quoting process args | 88 ;; Quoting process args |
66 ;;-------------------- | 89 ;;-------------------- |
67 | 90 |
74 (defun mswindows-quote-one-vc-runtime-arg (arg &optional quote-shell) | 97 (defun mswindows-quote-one-vc-runtime-arg (arg &optional quote-shell) |
75 ;; we mess with any arg with whitespace, quotes, or globbing chars in it. | 98 ;; we mess with any arg with whitespace, quotes, or globbing chars in it. |
76 ;; we also include shell metachars if asked. | 99 ;; we also include shell metachars if asked. |
77 ;; note that \ is NOT included! it's perfectly OK to include an | 100 ;; note that \ is NOT included! it's perfectly OK to include an |
78 ;; arg like c:\ or c:\foo. | 101 ;; arg like c:\ or c:\foo. |
79 (if (string-match (if quote-shell "[ \t\n\r\f*?\"<>|&^%]" "[ \t\n\r\f*?\"]") | 102 (cond ((equal arg "") "\"\"") |
80 arg) | 103 ((string-match |
81 (progn | 104 (if quote-shell "[ \t\n\r\f*?\"<>|&^%]" "[ \t\n\r\f*?\"]") |
82 ;; handle nested quotes, possibly preceded by backslashes | 105 arg) |
83 (setq arg (replace-in-string arg "\\([\\]*\\)\"" "\\1\\1\\\\\"")) | 106 ;; handle nested quotes, possibly preceded by backslashes |
84 ;; handle trailing backslashes | 107 (setq arg (replace-in-string arg "\\([\\]*\\)\"" "\\1\\1\\\\\"")) |
85 (setq arg (replace-in-string arg "\\([\\]+\\)$" "\\1\\1")) | 108 ;; handle trailing backslashes |
86 (concat "\"" arg "\"")) | 109 (setq arg (replace-in-string arg "\\([\\]+\\)$" "\\1\\1")) |
87 arg)) | 110 (concat "\"" arg "\"")) |
111 (t arg))) | |
88 | 112 |
89 (defun mswindows-quote-one-simple-arg (arg &optional quote-shell) | 113 (defun mswindows-quote-one-simple-arg (arg &optional quote-shell) |
90 ;; just put double quotes around args with spaces (and maybe shell | 114 ;; just put double quotes around args with spaces (and maybe shell |
91 ;; metachars). | 115 ;; metachars). |
92 (if (string-match (if quote-shell "[ \t\n\r\f*?\"<>|&^%]" "[ \t\n\r\f*?]") | 116 (cond ((equal arg "") "\"\"") |
93 arg) | 117 ((string-match |
94 (concat "\"" arg "\"") | 118 (if quote-shell "[ \t\n\r\f*?\"<>|&^%]" "[ \t\n\r\f*?]") |
95 arg)) | 119 arg) |
120 (concat "\"" arg "\"")) | |
121 (t arg))) | |
96 | 122 |
97 (defun mswindows-quote-one-command-arg (arg) | 123 (defun mswindows-quote-one-command-arg (arg) |
98 ;; quote an arg to get it past COMMAND.COM/CMD.EXE: need to quote shell | 124 ;; quote an arg to get it past COMMAND.COM/CMD.EXE: need to quote shell |
99 ;; metachars with ^. | 125 ;; metachars with ^. |
100 (replace-in-string "[<>|&^%]" "^\\1" arg)) | 126 (cond ((equal arg "") "\"\"") |
127 (t (replace-in-string "[<>|&^%]" "^\\1" arg)))) | |
101 | 128 |
102 (defun mswindows-construct-verbatim-command-line (program args) | 129 (defun mswindows-construct-verbatim-command-line (program args) |
103 (mapconcat #'identity args " ")) | 130 (mapconcat #'identity args " ")) |
104 | 131 |
105 ;; for use with either standard VC++ compiled programs or Cygwin programs, | 132 ;; for use with either standard VC++ compiled programs or Cygwin programs, |
196 (nreverse parts)) | 223 (nreverse parts)) |
197 "")) | 224 "")) |
198 args " ")) | 225 args " ")) |
199 | 226 |
200 (defvar mswindows-construct-process-command-line-alist | 227 (defvar mswindows-construct-process-command-line-alist |
201 '(("[\\/].?.?sh\\." . mswindows-construct-verbatim-command-line) | 228 '( |
229 ;; at one point (pre-1.0), this was required for Cygwin bash. | |
230 ;; evidently, Cygwin changed its arg handling to work just like | |
231 ;; any standard VC program, so we no longer need it. | |
232 ;;("[\\/].?.?sh\\." . mswindows-construct-verbatim-command-line) | |
202 ("[\\/]command\\.com$" . mswindows-construct-command-command-line) | 233 ("[\\/]command\\.com$" . mswindows-construct-command-command-line) |
203 ("[\\/]cmd\\.exe$" . mswindows-construct-command-command-line) | 234 ("[\\/]cmd\\.exe$" . mswindows-construct-command-command-line) |
204 ("" . mswindows-construct-vc-runtime-command-line)) | 235 ("" . mswindows-construct-vc-runtime-command-line)) |
205 "An alist for determining proper argument quoting given executable | 236 "An alist for determining proper argument quoting given executable |
206 file name. Car of each cons should be a string, a regexp against | 237 file name. Car of each cons should be a string, a regexp against |