aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorDaniel Colascione2012-09-17 03:55:02 -0800
committerDaniel Colascione2012-09-17 03:55:02 -0800
commit0fda9b750e337d876c9461db7d4426a3f0b81482 (patch)
tree1e1659bfa590cd8375c564c6fb5c3bafa65e06c0 /lisp
parent8b33967313f09a736a833816d32fd52e10640969 (diff)
downloademacs-0fda9b750e337d876c9461db7d4426a3f0b81482.tar.gz
emacs-0fda9b750e337d876c9461db7d4426a3f0b81482.zip
Implement cygw32
Here, we use the generic window-system configuration system we just implemented to support the w32 window-system in the mainline build under Cygwin. (Previously, the w32 window system could only be compiled as part of the NT-native Emacs build process.) The changes in this patch need to be applied atomically in order to avoid breaking Emacs. The changes include: - Changes throughout the Lisp and C code to not assume that NT Emacs and the w32 window system are synonymous. - Wiring up the regular select(2) event loop to Windows messages - Cleaning up the w32 drag-and-drop receiving code. - Exposing Cygwin path conversion functions to elisp. - Unicode file dialog support when compiling for Cygwin. - Splitting the w32 term lisp initialization code into code applicable to any w32 window-system and code specific to system-type windows-nt. - Integrating the old and new w32 code into the build system.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/battery.el2
-rw-r--r--lisp/faces.el2
-rw-r--r--lisp/frame.el4
-rw-r--r--lisp/international/mule-cmds.el3
-rw-r--r--lisp/loadup.el13
-rw-r--r--lisp/mouse.el2
-rw-r--r--lisp/simple.el2
-rw-r--r--lisp/term/common-win.el2
-rw-r--r--lisp/term/w32-win.el42
-rw-r--r--lisp/w32-fns.el105
-rw-r--r--lisp/w32-vars.el24
11 files changed, 57 insertions, 144 deletions
diff --git a/lisp/battery.el b/lisp/battery.el
index 8e98291b11c..69d25643bb9 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -60,7 +60,7 @@
60 (> (buffer-size) 0))) 60 (> (buffer-size) 0)))
61 (error nil))) 61 (error nil)))
62 'battery-pmset) 62 'battery-pmset)
63 ((eq system-type 'windows-nt) 63 ((fboundp 'w32-battery-status)
64 'w32-battery-status)) 64 'w32-battery-status))
65 "Function for getting battery status information. 65 "Function for getting battery status information.
66The function has to return an alist of conversion definitions. 66The function has to return an alist of conversion definitions.
diff --git a/lisp/faces.el b/lisp/faces.el
index 6a477e172e1..d004ae650cb 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -96,7 +96,7 @@ ALTERNATIVE2 etc."
96;; This is defined originally in xfaces.c. 96;; This is defined originally in xfaces.c.
97(defcustom face-font-registry-alternatives 97(defcustom face-font-registry-alternatives
98 (mapcar (lambda (arg) (mapcar 'purecopy arg)) 98 (mapcar (lambda (arg) (mapcar 'purecopy arg))
99 (if (eq system-type 'windows-nt) 99 (if (featurep 'w32)
100 '(("iso8859-1" "ms-oemlatin") 100 '(("iso8859-1" "ms-oemlatin")
101 ("gb2312.1980" "gb2312" "gbk" "gb18030") 101 ("gb2312.1980" "gb2312" "gbk" "gb18030")
102 ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978") 102 ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978")
diff --git a/lisp/frame.el b/lisp/frame.el
index 01225639ecf..9be64a6b7ff 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -524,7 +524,7 @@ The optional argument PARAMETERS specifies additional frame parameters."
524 (ns-initialize-window-system)) 524 (ns-initialize-window-system))
525 (make-frame `((window-system . ns) 525 (make-frame `((window-system . ns)
526 (display . ,display) . ,parameters))) 526 (display . ,display) . ,parameters)))
527 ((eq system-type 'windows-nt) 527 ((eq window-system 'w32)
528 ;; On Windows, ignore DISPLAY. 528 ;; On Windows, ignore DISPLAY.
529 (make-frame parameters)) 529 (make-frame parameters))
530 (t 530 (t
@@ -1260,7 +1260,7 @@ frame's display)."
1260 (cond 1260 (cond
1261 ((eq frame-type 'pc) 1261 ((eq frame-type 'pc)
1262 (msdos-mouse-p)) 1262 (msdos-mouse-p))
1263 ((eq system-type 'windows-nt) 1263 ((eq frame-type 'w32)
1264 (with-no-warnings 1264 (with-no-warnings
1265 (> w32-num-mouse-buttons 0))) 1265 (> w32-num-mouse-buttons 0)))
1266 ((memq frame-type '(x ns)) 1266 ((memq frame-type '(x ns))
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 2fc9759972e..177ac8eaa91 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -2670,7 +2670,8 @@ See also `locale-charset-language-names', `locale-language-names',
2670 ;; On Windows, override locale-coding-system, 2670 ;; On Windows, override locale-coding-system,
2671 ;; default-file-name-coding-system, keyboard-coding-system, 2671 ;; default-file-name-coding-system, keyboard-coding-system,
2672 ;; terminal-coding-system with system codepage. 2672 ;; terminal-coding-system with system codepage.
2673 (when (boundp 'w32-ansi-code-page) 2673 (when (and (eq system-type 'windows-nt)
2674 (boundp 'w32-ansi-code-page))
2674 (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page)))) 2675 (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page))))
2675 (when (coding-system-p code-page-coding) 2676 (when (coding-system-p code-page-coding)
2676 (unless frame (setq locale-coding-system code-page-coding)) 2677 (unless frame (setq locale-coding-system code-page-coding))
diff --git a/lisp/loadup.el b/lisp/loadup.el
index a460fcab339..c70b417822f 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -224,15 +224,18 @@
224 (load "term/common-win") 224 (load "term/common-win")
225 (load "term/x-win"))) 225 (load "term/x-win")))
226 226
227(if (eq system-type 'windows-nt) 227(if (or (eq system-type 'windows-nt)
228 (featurep 'w32))
228 (progn 229 (progn
229 (load "w32-vars")
230 (load "term/common-win") 230 (load "term/common-win")
231 (load "w32-vars")
231 (load "term/w32-win") 232 (load "term/w32-win")
232 (load "ls-lisp")
233 (load "disp-table") 233 (load "disp-table")
234 (load "dos-w32") 234 (load "w32-common-fns")
235 (load "w32-fns"))) 235 (when (eq system-type 'windows-nt)
236 (load "w32-fns")
237 (load "ls-lisp")
238 (load "dos-w32"))))
236(if (eq system-type 'ms-dos) 239(if (eq system-type 'ms-dos)
237 (progn 240 (progn
238 (load "dos-w32") 241 (load "dos-w32")
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 4ea84288f69..14e69c9f34d 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1151,7 +1151,7 @@ regardless of where you click."
1151 (or mouse-yank-at-point (mouse-set-point click)) 1151 (or mouse-yank-at-point (mouse-set-point click))
1152 (let ((primary 1152 (let ((primary
1153 (cond 1153 (cond
1154 ((eq system-type 'windows-nt) 1154 ((eq (framep (selected-frame)) 'w32)
1155 ;; MS-Windows emulates PRIMARY in x-get-selection, but not 1155 ;; MS-Windows emulates PRIMARY in x-get-selection, but not
1156 ;; in x-get-selection-value (the latter only accesses the 1156 ;; in x-get-selection-value (the latter only accesses the
1157 ;; clipboard). So try PRIMARY first, in case they selected 1157 ;; clipboard). So try PRIMARY first, in case they selected
diff --git a/lisp/simple.el b/lisp/simple.el
index b7a24f4f970..b81e0d7ee88 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6870,7 +6870,7 @@ call `normal-erase-is-backspace-mode' (which see) instead."
6870 (if (if (eq normal-erase-is-backspace 'maybe) 6870 (if (if (eq normal-erase-is-backspace 'maybe)
6871 (and (not noninteractive) 6871 (and (not noninteractive)
6872 (or (memq system-type '(ms-dos windows-nt)) 6872 (or (memq system-type '(ms-dos windows-nt))
6873 (memq window-system '(ns)) 6873 (memq window-system '(w32 ns))
6874 (and (memq window-system '(x)) 6874 (and (memq window-system '(x))
6875 (fboundp 'x-backspace-delete-keys-p) 6875 (fboundp 'x-backspace-delete-keys-p)
6876 (x-backspace-delete-keys-p)) 6876 (x-backspace-delete-keys-p))
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el
index 067b996d1ff..b44e092cc0a 100644
--- a/lisp/term/common-win.el
+++ b/lisp/term/common-win.el
@@ -57,7 +57,7 @@ clipboard as well.
57 57
58On Nextstep, put TEXT in the pasteboard (`x-select-enable-clipboard' 58On Nextstep, put TEXT in the pasteboard (`x-select-enable-clipboard'
59is not used)." 59is not used)."
60 (cond ((eq system-type 'windows-nt) 60 (cond ((eq (framep (selected-frame)) 'w32)
61 (if x-select-enable-clipboard 61 (if x-select-enable-clipboard
62 (w32-set-clipboard-data text)) 62 (w32-set-clipboard-data text))
63 (setq x-last-selected-text text)) 63 (setq x-last-selected-text text))
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index a4fac3441db..dd577af0ae1 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -1,4 +1,4 @@
1;;; w32-win.el --- parse switches controlling interface with W32 window system 1;;; w32-win.el --- parse switches controlling interface with W32 window system -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc.
4 4
@@ -102,7 +102,22 @@
102;; (interactive "e") 102;; (interactive "e")
103;; (princ event)) 103;; (princ event))
104 104
105(defun w32-drag-n-drop (event) 105(defun w32-handle-dropped-file (window file-name)
106 (let ((f (if (eq system-type 'cygwin)
107 (cygwin-convert-path-from-windows file-name t)
108 (subst-char-in-string ?\\ ?/ file-name)))
109 (coding (or file-name-coding-system
110 default-file-name-coding-system)))
111
112 (setq file-name
113 (mapconcat 'url-hexify-string
114 (split-string (encode-coding-string f coding)
115 "/")
116 "/")))
117 (dnd-handle-one-url window 'private
118 (concat "file:" file-name)))
119
120(defun w32-drag-n-drop (event &optional new-frame)
106 "Edit the files listed in the drag-n-drop EVENT. 121 "Edit the files listed in the drag-n-drop EVENT.
107Switch to a buffer editing the last file dropped." 122Switch to a buffer editing the last file dropped."
108 (interactive "e") 123 (interactive "e")
@@ -116,26 +131,21 @@ Switch to a buffer editing the last file dropped."
116 (y (cdr coords))) 131 (y (cdr coords)))
117 (if (and (> x 0) (> y 0)) 132 (if (and (> x 0) (> y 0))
118 (set-frame-selected-window nil window)) 133 (set-frame-selected-window nil window))
119 (mapc (lambda (file-name) 134
120 (let ((f (subst-char-in-string ?\\ ?/ file-name)) 135 (when new-frame
121 (coding (or file-name-coding-system 136 (select-frame (make-frame)))
122 default-file-name-coding-system))) 137 (raise-frame)
123 (setq file-name 138 (setq window (selected-window))
124 (mapconcat 'url-hexify-string 139
125 (split-string (encode-coding-string f coding) 140 (mapc (apply-partially #'w32-handle-dropped-file window)
126 "/") 141 (car (cdr (cdr event)))))))
127 "/")))
128 (dnd-handle-one-url window 'private
129 (concat "file:" file-name)))
130 (car (cdr (cdr event)))))
131 (raise-frame)))
132 142
133(defun w32-drag-n-drop-other-frame (event) 143(defun w32-drag-n-drop-other-frame (event)
134 "Edit the files listed in the drag-n-drop EVENT, in other frames. 144 "Edit the files listed in the drag-n-drop EVENT, in other frames.
135May create new frames, or reuse existing ones. The frame editing 145May create new frames, or reuse existing ones. The frame editing
136the last file dropped is selected." 146the last file dropped is selected."
137 (interactive "e") 147 (interactive "e")
138 (mapcar 'find-file-other-frame (car (cdr (cdr event))))) 148 (w32-drag-n-drop event t))
139 149
140;; Bind the drag-n-drop event. 150;; Bind the drag-n-drop event.
141(global-set-key [drag-n-drop] 'w32-drag-n-drop) 151(global-set-key [drag-n-drop] 'w32-drag-n-drop)
diff --git a/lisp/w32-fns.el b/lisp/w32-fns.el
index 1769ee73be5..813a8fd4d96 100644
--- a/lisp/w32-fns.el
+++ b/lisp/w32-fns.el
@@ -26,34 +26,20 @@
26 26
27;;; Code: 27;;; Code:
28(require 'w32-vars) 28(require 'w32-vars)
29(require 'w32-common-fns)
29 30
30(defvar explicit-shell-file-name) 31(defvar explicit-shell-file-name)
31 32
32;;;; Function keys 33;;;; Function keys
33 34
34(declare-function set-message-beep "w32console.c") 35(declare-function set-message-beep "w32console.c")
35(declare-function w32-get-clipboard-data "w32select.c")
36(declare-function w32-get-locale-info "w32proc.c") 36(declare-function w32-get-locale-info "w32proc.c")
37(declare-function w32-get-valid-locale-ids "w32proc.c") 37(declare-function w32-get-valid-locale-ids "w32proc.c")
38(declare-function w32-set-clipboard-data "w32select.c")
39 38
40;; Map all versions of a filename (8.3, longname, mixed case) to the 39;; Map all versions of a filename (8.3, longname, mixed case) to the
41;; same buffer. 40;; same buffer.
42(setq find-file-visit-truename t) 41(setq find-file-visit-truename t)
43 42
44(declare-function x-server-version "w32fns.c" (&optional display))
45
46(defun w32-version ()
47 "Return the MS-Windows version numbers.
48The value is a list of three integers: the major and minor version
49numbers, and the build number."
50 (x-server-version))
51
52(defun w32-using-nt ()
53 "Return non-nil if running on a Windows NT descendant.
54That includes all Windows systems except for 9X/Me."
55 (and (eq system-type 'windows-nt) (getenv "SystemRoot")))
56
57(defun w32-shell-name () 43(defun w32-shell-name ()
58 "Return the name of the shell being used." 44 "Return the name of the shell being used."
59 (or (bound-and-true-p shell-file-name) 45 (or (bound-and-true-p shell-file-name)
@@ -240,53 +226,6 @@ requires it (see `w32-shell-dos-semantics')."
240 (setq start (match-end 0)))) 226 (setq start (match-end 0))))
241 name))) 227 name)))
242 228
243;;; Fix interface to (X-specific) mouse.el
244(defun x-set-selection (type data)
245 "Make an X selection of type TYPE and value DATA.
246The argument TYPE (nil means `PRIMARY') says which selection, and
247DATA specifies the contents. TYPE must be a symbol. \(It can also
248be a string, which stands for the symbol with that name, but this
249is considered obsolete.) DATA may be a string, a symbol, an
250integer (or a cons of two integers or list of two integers).
251
252The selection may also be a cons of two markers pointing to the same buffer,
253or an overlay. In these cases, the selection is considered to be the text
254between the markers *at whatever time the selection is examined*.
255Thus, editing done in the buffer after you specify the selection
256can alter the effective value of the selection.
257
258The data may also be a vector of valid non-vector selection values.
259
260The return value is DATA.
261
262Interactively, this command sets the primary selection. Without
263prefix argument, it reads the selection in the minibuffer. With
264prefix argument, it uses the text of the region as the selection value.
265
266Note that on MS-Windows, primary and secondary selections set by Emacs
267are not available to other programs."
268 (put 'x-selections (or type 'PRIMARY) data))
269
270(defun x-get-selection (&optional type _data-type)
271 "Return the value of an X Windows selection.
272The argument TYPE (default `PRIMARY') says which selection,
273and the argument DATA-TYPE (default `STRING') says
274how to convert the data.
275
276TYPE may be any symbol \(but nil stands for `PRIMARY'). However,
277only a few symbols are commonly used. They conventionally have
278all upper-case names. The most often used ones, in addition to
279`PRIMARY', are `SECONDARY' and `CLIPBOARD'.
280
281DATA-TYPE is usually `STRING', but can also be one of the symbols
282in `selection-converter-alist', which see."
283 (get 'x-selections (or type 'PRIMARY)))
284
285;; x-selection-owner-p is used in simple.el
286(defun x-selection-owner-p (&optional type)
287 (and (memq type '(nil PRIMARY SECONDARY))
288 (get 'x-selections (or type 'PRIMARY))))
289
290(defun set-w32-system-coding-system (coding-system) 229(defun set-w32-system-coding-system (coding-system)
291 "Set the coding system used by the Windows system to CODING-SYSTEM. 230 "Set the coding system used by the Windows system to CODING-SYSTEM.
292This is used for things like passing font names with non-ASCII 231This is used for things like passing font names with non-ASCII
@@ -311,14 +250,6 @@ This function is provided for backward compatibility, since
311;; Set to a system sound if you want a fancy bell. 250;; Set to a system sound if you want a fancy bell.
312(set-message-beep nil) 251(set-message-beep nil)
313 252
314;; The "Windows" keys on newer keyboards bring up the Start menu
315;; whether you want it or not - make Emacs ignore these keystrokes
316;; rather than beep.
317(global-set-key [lwindow] 'ignore)
318(global-set-key [rwindow] 'ignore)
319
320(defvar w32-charset-info-alist) ; w32font.c
321
322(defun w32-add-charset-info (xlfd-charset windows-charset codepage) 253(defun w32-add-charset-info (xlfd-charset windows-charset codepage)
323 "Function to add character sets to display with Windows fonts. 254 "Function to add character sets to display with Windows fonts.
324Creates entries in `w32-charset-info-alist'. 255Creates entries in `w32-charset-info-alist'.
@@ -380,40 +311,6 @@ bit output with no translation."
380 'w32-charset-info-alist "21.1") 311 'w32-charset-info-alist "21.1")
381 312
382 313
383;;;; Selections
384
385;; We keep track of the last text selected here, so we can check the
386;; current selection against it, and avoid passing back our own text
387;; from x-selection-value.
388(defvar x-last-selected-text nil)
389
390(defun x-get-selection-value ()
391 "Return the value of the current selection.
392Consult the selection. Treat empty strings as if they were unset."
393 (if x-select-enable-clipboard
394 (let (text)
395 ;; Don't die if x-get-selection signals an error.
396 (condition-case c
397 (setq text (w32-get-clipboard-data))
398 (error (message "w32-get-clipboard-data:%s" c)))
399 (if (string= text "") (setq text nil))
400 (cond
401 ((not text) nil)
402 ((eq text x-last-selected-text) nil)
403 ((string= text x-last-selected-text)
404 ;; Record the newer string, so subsequent calls can use the 'eq' test.
405 (setq x-last-selected-text text)
406 nil)
407 (t
408 (setq x-last-selected-text text))))))
409
410(defalias 'x-selection-value 'x-get-selection-value)
411
412;; Arrange for the kill and yank functions to set and check the clipboard.
413(setq interprogram-cut-function 'x-select-text)
414(setq interprogram-paste-function 'x-get-selection-value)
415
416
417;;;; Support for build process 314;;;; Support for build process
418 315
419;; From autoload.el 316;; From autoload.el
diff --git a/lisp/w32-vars.el b/lisp/w32-vars.el
index c8716ef6c36..0e152b125bc 100644
--- a/lisp/w32-vars.el
+++ b/lisp/w32-vars.el
@@ -44,17 +44,19 @@ X does. See `w32-fixed-font-alist' for the font menu definition."
44 "Include proportional fonts in the default font dialog.") 44 "Include proportional fonts in the default font dialog.")
45(make-obsolete-variable 'w32-list-proportional-fonts "no longer used." "23.1") 45(make-obsolete-variable 'w32-list-proportional-fonts "no longer used." "23.1")
46 46
47(defcustom w32-allow-system-shell nil 47(unless (eq system-type 'cygwin)
48 "Disable startup warning when using \"system\" shells." 48 (defcustom w32-allow-system-shell nil
49 :type 'boolean 49 "Disable startup warning when using \"system\" shells."
50 :group 'w32) 50 :type 'boolean
51 51 :group 'w32))
52(defcustom w32-system-shells '("cmd" "cmd.exe" "command" "command.com" 52
53 "4nt" "4nt.exe" "4dos" "4dos.exe" 53(unless (eq system-type 'cygwin)
54 "tcc" "tcc.exe" "ndos" "ndos.exe") 54 (defcustom w32-system-shells '("cmd" "cmd.exe" "command" "command.com"
55 "List of strings recognized as Windows system shells." 55 "4nt" "4nt.exe" "4dos" "4dos.exe"
56 :type '(repeat string) 56 "tcc" "tcc.exe" "ndos" "ndos.exe")
57 :group 'w32) 57 "List of strings recognized as Windows system shells."
58 :type '(repeat string)
59 :group 'w32))
58 60
59;; Want "menu" custom type for this. 61;; Want "menu" custom type for this.
60(defcustom w32-fixed-font-alist 62(defcustom w32-fixed-font-alist