Commit | Line | Data |
---|---|---|
e8af40ee | 1 | ;;; w32-fns.el --- Lisp routines for Windows NT |
b578f267 | 2 | |
597e2240 GM |
3 | ;; Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
4 | ;; 2009 Free Software Foundation, Inc. | |
95ed0025 | 5 | |
68429d86 | 6 | ;; Author: Geoff Voelker <voelker@cs.washington.edu> |
284b3043 | 7 | ;; Keywords: internal |
95ed0025 RS |
8 | |
9 | ;; This file is part of GNU Emacs. | |
10 | ||
eb3fa2cf | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
95ed0025 | 12 | ;; it under the terms of the GNU General Public License as published by |
eb3fa2cf GM |
13 | ;; the Free Software Foundation, either version 3 of the License, or |
14 | ;; (at your option) any later version. | |
95ed0025 RS |
15 | |
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;; GNU General Public License for more details. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
eb3fa2cf | 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
95ed0025 RS |
23 | |
24 | ;;; Commentary: | |
25 | ||
95ed0025 RS |
26 | |
27 | ;;; Code: | |
2f42c75f | 28 | (require 'w32-vars) |
95ed0025 | 29 | |
b5de9ae0 JB |
30 | (defvar explicit-shell-file-name) |
31 | ||
716eb574 JR |
32 | ;;;; Function keys |
33 | ||
34 | (defvar x-alternatives-map | |
35 | (let ((map (make-sparse-keymap))) | |
36 | ;; Map certain keypad keys into ASCII characters that people usually expect. | |
716eb574 JR |
37 | (define-key map [M-backspace] [?\M-\d]) |
38 | (define-key map [M-delete] [?\M-\d]) | |
39 | (define-key map [M-tab] [?\M-\t]) | |
40 | (define-key map [M-linefeed] [?\M-\n]) | |
41 | (define-key map [M-clear] [?\M-\C-l]) | |
42 | (define-key map [M-return] [?\M-\C-m]) | |
43 | (define-key map [M-escape] [?\M-\e]) | |
44 | (define-key map [iso-lefttab] [backtab]) | |
45 | (define-key map [S-iso-lefttab] [backtab]) | |
c56e37dd | 46 | (define-key map [S-tab] [backtab]) |
716eb574 JR |
47 | map) |
48 | "Keymap of possible alternative meanings for some keys.") | |
49 | ||
50 | (defun x-setup-function-keys (frame) | |
3077d1f6 | 51 | "Set up `function-key-map' on the graphical frame FRAME." |
716eb574 JR |
52 | ;; Don't do this twice on the same display, or it would break |
53 | ;; normal-erase-is-backspace-mode. | |
54 | (unless (terminal-parameter frame 'x-setup-function-keys) | |
55 | ;; Map certain keypad keys into ASCII characters that people usually expect. | |
56 | (with-selected-frame frame | |
57 | (let ((map (copy-keymap x-alternatives-map))) | |
58 | (set-keymap-parent map (keymap-parent local-function-key-map)) | |
59 | (set-keymap-parent local-function-key-map map))) | |
60 | (set-terminal-parameter frame 'x-setup-function-keys t))) | |
61 | ||
73e6adaa DN |
62 | (declare-function set-message-beep "w32console.c") |
63 | (declare-function w32-get-clipboard-data "w32select.c") | |
64 | (declare-function w32-get-locale-info "w32proc.c") | |
65 | (declare-function w32-get-valid-locale-ids "w32proc.c") | |
66 | (declare-function w32-set-clipboard-data "w32select.c") | |
81b38822 | 67 | |
bcaf1c36 | 68 | ;; Map all versions of a filename (8.3, longname, mixed case) to the |
d234707d GV |
69 | ;; same buffer. |
70 | (setq find-file-visit-truename t) | |
71 | ||
aa360da1 GM |
72 | (declare-function x-server-version "w32fns.c" (&optional display)) |
73 | ||
161ab819 AI |
74 | (defun w32-version () |
75 | "Return the MS-Windows version numbers. | |
76 | The value is a list of three integers: the major and minor version | |
77 | numbers, and the build number." | |
78 | (x-server-version)) | |
79 | ||
ee82af56 | 80 | (defun w32-using-nt () |
4ff64219 | 81 | "Return non-nil if running on a Windows NT descendant. |
49bd2bfe | 82 | That includes all Windows systems except for 9X/Me." |
ee82af56 GV |
83 | (and (eq system-type 'windows-nt) (getenv "SystemRoot"))) |
84 | ||
85 | (defun w32-shell-name () | |
d234707d | 86 | "Return the name of the shell being used." |
551ea1bd | 87 | (or (bound-and-true-p explicit-shell-file-name) |
ee82af56 GV |
88 | (getenv "ESHELL") |
89 | (getenv "SHELL") | |
90 | (and (w32-using-nt) "cmd.exe") | |
91 | "command.com")) | |
92 | ||
d234707d GV |
93 | (defun w32-system-shell-p (shell-name) |
94 | (and shell-name | |
bcaf1c36 | 95 | (member (downcase (file-name-nondirectory shell-name)) |
d234707d | 96 | w32-system-shells))) |
ee82af56 | 97 | |
f3e62da2 | 98 | (defun w32-shell-dos-semantics () |
8fc29035 | 99 | "Return non-nil if the interactive shell being used expects MS-DOS shell semantics." |
f3e62da2 GV |
100 | (or (w32-system-shell-p (w32-shell-name)) |
101 | (and (member (downcase (file-name-nondirectory (w32-shell-name))) | |
102 | '("cmdproxy" "cmdproxy.exe")) | |
103 | (w32-system-shell-p (getenv "COMSPEC"))))) | |
104 | ||
200fe89b DN |
105 | (defvar w32-quote-process-args) ;; defined in w32proc.c |
106 | ||
d234707d | 107 | (defun w32-check-shell-configuration () |
72ab66eb | 108 | "Check the configuration of shell variables on Windows. |
ee82af56 | 109 | This function is invoked after loading the init files and processing |
d234707d GV |
110 | the command line arguments. It issues a warning if the user or site |
111 | has configured the shell with inappropriate settings." | |
85f568ec | 112 | (interactive) |
d234707d GV |
113 | (let ((prev-buffer (current-buffer)) |
114 | (buffer (get-buffer-create "*Shell Configuration*")) | |
115 | (system-shell)) | |
116 | (set-buffer buffer) | |
117 | (erase-buffer) | |
118 | (if (w32-system-shell-p (getenv "ESHELL")) | |
119 | (insert (format "Warning! The ESHELL environment variable uses %s. | |
bcaf1c36 | 120 | You probably want to change it so that it uses cmdproxy.exe instead.\n\n" |
d234707d GV |
121 | (getenv "ESHELL")))) |
122 | (if (w32-system-shell-p (getenv "SHELL")) | |
123 | (insert (format "Warning! The SHELL environment variable uses %s. | |
bcaf1c36 | 124 | You probably want to change it so that it uses cmdproxy.exe instead.\n\n" |
d234707d GV |
125 | (getenv "SHELL")))) |
126 | (if (w32-system-shell-p shell-file-name) | |
127 | (insert (format "Warning! shell-file-name uses %s. | |
bcaf1c36 | 128 | You probably want to change it so that it uses cmdproxy.exe instead.\n\n" |
d234707d GV |
129 | shell-file-name))) |
130 | (if (and (boundp 'explicit-shell-file-name) | |
131 | (w32-system-shell-p explicit-shell-file-name)) | |
132 | (insert (format "Warning! explicit-shell-file-name uses %s. | |
133 | You probably want to change it so that it uses cmdproxy.exe instead.\n\n" | |
134 | explicit-shell-file-name))) | |
135 | (setq system-shell (> (buffer-size) 0)) | |
85f568ec GV |
136 | |
137 | ;; Allow user to specify that they really do want to use one of the | |
138 | ;; "system" shells, despite the drawbacks, but still warn if | |
139 | ;; shell-command-switch doesn't match. | |
140 | (if w32-allow-system-shell | |
141 | (erase-buffer)) | |
142 | ||
d234707d GV |
143 | (cond (system-shell |
144 | ;; System shells. | |
145 | (if (string-equal "-c" shell-command-switch) | |
146 | (insert "Warning! shell-command-switch is \"-c\". | |
147 | You should set this to \"/c\" when using a system shell.\n\n")) | |
148 | (if w32-quote-process-args | |
149 | (insert "Warning! w32-quote-process-args is t. | |
150 | You should set this to nil when using a system shell.\n\n"))) | |
151 | ;; Non-system shells. | |
152 | (t | |
153 | (if (string-equal "/c" shell-command-switch) | |
154 | (insert "Warning! shell-command-switch is \"/c\". | |
155 | You should set this to \"-c\" when using a non-system shell.\n\n")) | |
156 | (if (not w32-quote-process-args) | |
157 | (insert "Warning! w32-quote-process-args is nil. | |
158 | You should set this to t when using a non-system shell.\n\n")))) | |
159 | (if (> (buffer-size) 0) | |
160 | (display-buffer buffer) | |
161 | (kill-buffer buffer)) | |
162 | (set-buffer prev-buffer))) | |
163 | ||
164 | (add-hook 'after-init-hook 'w32-check-shell-configuration) | |
165 | ||
f2b256fa | 166 | ;; Override setting chosen at startup. |
b1ed8648 AI |
167 | (defun set-default-process-coding-system () |
168 | ;; Most programs on Windows will accept Unix line endings on input | |
169 | ;; (and some programs ported from Unix require it) but most will | |
170 | ;; produce DOS line endings on output. | |
171 | (setq default-process-coding-system | |
597e2240 | 172 | (if (default-value 'enable-multibyte-characters) |
b1ed8648 AI |
173 | '(undecided-dos . undecided-unix) |
174 | '(raw-text-dos . raw-text-unix))) | |
a272a739 JR |
175 | ;; Make cmdproxy default to using DOS line endings for input, |
176 | ;; because some Windows programs (including command.com) require it. | |
177 | (add-to-list 'process-coding-system-alist | |
178 | `("[cC][mM][dD][pP][rR][oO][xX][yY]" | |
597e2240 | 179 | . ,(if (default-value 'enable-multibyte-characters) |
a272a739 JR |
180 | '(undecided-dos . undecided-dos) |
181 | '(raw-text-dos . raw-text-dos)))) | |
182 | ;; plink needs DOS input when entering the password. | |
183 | (add-to-list 'process-coding-system-alist | |
184 | `("[pP][lL][iI][nN][kK]" | |
597e2240 | 185 | . ,(if (default-value 'enable-multibyte-characters) |
a272a739 JR |
186 | '(undecided-dos . undecided-dos) |
187 | '(raw-text-dos . raw-text-dos))))) | |
b1ed8648 AI |
188 | |
189 | (add-hook 'before-init-hook 'set-default-process-coding-system) | |
190 | ||
85f568ec GV |
191 | |
192 | ;;; Basic support functions for managing Emacs' locale setting | |
193 | ||
194 | (defvar w32-valid-locales nil | |
195 | "List of locale ids known to be supported.") | |
196 | ||
f2b256fa SM |
197 | ;; This is the brute-force version; an efficient version is now |
198 | ;; built-in though. | |
85f568ec GV |
199 | (if (not (fboundp 'w32-get-valid-locale-ids)) |
200 | (defun w32-get-valid-locale-ids () | |
201 | "Return list of all valid Windows locale ids." | |
202 | (let ((i 65535) | |
203 | locales) | |
204 | (while (> i 0) | |
205 | (if (w32-get-locale-info i) | |
206 | (setq locales (cons i locales))) | |
207 | (setq i (1- i))) | |
208 | locales))) | |
209 | ||
210 | (defun w32-list-locales () | |
211 | "List the name and id of all locales supported by Windows." | |
212 | (interactive) | |
ac62ec16 JB |
213 | (when (null w32-valid-locales) |
214 | (setq w32-valid-locales (sort (w32-get-valid-locale-ids) #'<))) | |
555e23cf JB |
215 | (with-output-to-temp-buffer "*Supported Locales*" |
216 | (princ "LCID\tAbbrev\tFull name\n\n") | |
011a0143 JB |
217 | (dolist (locale w32-valid-locales) |
218 | (princ (format "%d\t%s\t%s\n" | |
219 | locale | |
220 | (w32-get-locale-info locale) | |
221 | (w32-get-locale-info locale t)))))) | |
85f568ec | 222 | |
f2b256fa SM |
223 | ;; Setup Info-default-directory-list to include the info directory |
224 | ;; near where Emacs executable was installed. We used to set INFOPATH, | |
225 | ;; but when this is set Info-default-directory-list is ignored. We | |
226 | ;; also cannot rely upon what is set in paths.el because they assume | |
227 | ;; that configuration during build time is correct for runtime. | |
d234707d GV |
228 | (defun w32-init-info () |
229 | (let* ((instdir (file-name-directory invocation-directory)) | |
85f568ec | 230 | (dir1 (expand-file-name "../info/" instdir)) |
d234707d GV |
231 | (dir2 (expand-file-name "../../../info/" instdir))) |
232 | (if (file-exists-p dir1) | |
bcaf1c36 | 233 | (setq Info-default-directory-list |
d234707d GV |
234 | (append Info-default-directory-list (list dir1))) |
235 | (if (file-exists-p dir2) | |
236 | (setq Info-default-directory-list | |
237 | (append Info-default-directory-list (list dir2))))))) | |
238 | ||
239 | (add-hook 'before-init-hook 'w32-init-info) | |
3eab6a03 | 240 | |
f2b256fa SM |
241 | ;; The variable source-directory is used to initialize Info-directory-list. |
242 | ;; However, the common case is that Emacs is being used from a binary | |
243 | ;; distribution, and the value of source-directory is meaningless in that | |
244 | ;; case. Even worse, source-directory can refer to a directory on a drive | |
245 | ;; on the build machine that happens to be a removable drive on the user's | |
246 | ;; machine. When this happens, Emacs tries to access the removable drive | |
247 | ;; and produces the abort/retry/ignore dialog. Since we do not use | |
248 | ;; source-directory, set it to something that is a reasonable approximation | |
249 | ;; on the user's machine. | |
250 | ||
251 | ;;(add-hook 'before-init-hook | |
252 | ;; (lambda () | |
253 | ;; (setq source-directory (file-name-as-directory | |
254 | ;; (expand-file-name ".." exec-directory))))) | |
8929f478 | 255 | |
d234707d GV |
256 | (defun convert-standard-filename (filename) |
257 | "Convert a standard file's name to something suitable for the current OS. | |
915b0bf0 JB |
258 | This means to guarantee valid names and perhaps to canonicalize |
259 | certain patterns. | |
260 | ||
261 | On Windows and DOS, replace invalid characters. On DOS, make | |
262 | sure to obey the 8.3 limitations. On Windows, turn Cygwin names | |
263 | into native names, and also turn slashes into backslashes if the | |
264 | shell requires it (see `w32-shell-dos-semantics')." | |
45b8a401 EZ |
265 | (save-match-data |
266 | (let ((name | |
267 | (if (string-match "\\`/cygdrive/\\([a-zA-Z]\\)/" filename) | |
bcaf1c36 | 268 | (replace-match "\\1:/" t nil filename) |
45b8a401 EZ |
269 | (copy-sequence filename))) |
270 | (start 0)) | |
271 | ;; leave ':' if part of drive specifier | |
272 | (if (and (> (length name) 1) | |
273 | (eq (aref name 1) ?:)) | |
274 | (setq start 2)) | |
275 | ;; destructively replace invalid filename characters with ! | |
276 | (while (string-match "[?*:<>|\"\000-\037]" name start) | |
277 | (aset name (match-beginning 0) ?!) | |
278 | (setq start (match-end 0))) | |
279 | ;; convert directory separators to Windows format | |
280 | ;; (but only if the shell in use requires it) | |
281 | (when (w32-shell-dos-semantics) | |
282 | (setq start 0) | |
283 | (while (string-match "/" name start) | |
284 | (aset name (match-beginning 0) ?\\) | |
285 | (setq start (match-end 0)))) | |
286 | name))) | |
4e0cd0df | 287 | |
95ed0025 | 288 | ;;; Fix interface to (X-specific) mouse.el |
bffcf874 | 289 | (defun x-set-selection (type data) |
d977a092 | 290 | "Make an X selection of type TYPE and value DATA. |
3077d1f6 EZ |
291 | The argument TYPE (nil means `PRIMARY') says which selection, and |
292 | DATA specifies the contents. TYPE must be a symbol. \(It can also | |
293 | be a string, which stands for the symbol with that name, but this | |
294 | is considered obsolete.) DATA may be a string, a symbol, an | |
295 | integer (or a cons of two integers or list of two integers). | |
296 | ||
297 | The selection may also be a cons of two markers pointing to the same buffer, | |
298 | or an overlay. In these cases, the selection is considered to be the text | |
299 | between the markers *at whatever time the selection is examined*. | |
300 | Thus, editing done in the buffer after you specify the selection | |
301 | can alter the effective value of the selection. | |
302 | ||
303 | The data may also be a vector of valid non-vector selection values. | |
304 | ||
305 | The return value is DATA. | |
306 | ||
307 | Interactively, this command sets the primary selection. Without | |
308 | prefix argument, it reads the selection in the minibuffer. With | |
309 | prefix argument, it uses the text of the region as the selection value. | |
310 | ||
311 | Note that on MS-Windows, primary and secondary selections set by Emacs | |
312 | are not available to other programs." | |
3f5c9cad | 313 | (put 'x-selections (or type 'PRIMARY) data)) |
bffcf874 RS |
314 | |
315 | (defun x-get-selection (&optional type data-type) | |
3077d1f6 EZ |
316 | "Return the value of an X Windows selection. |
317 | The argument TYPE (default `PRIMARY') says which selection, | |
318 | and the argument DATA-TYPE (default `STRING') says | |
319 | how to convert the data. | |
320 | ||
321 | TYPE may be any symbol \(but nil stands for `PRIMARY'). However, | |
322 | only a few symbols are commonly used. They conventionally have | |
323 | all upper-case names. The most often used ones, in addition to | |
324 | `PRIMARY', are `SECONDARY' and `CLIPBOARD'. | |
325 | ||
326 | DATA-TYPE is usually `STRING', but can also be one of the symbols | |
327 | in `selection-converter-alist', which see." | |
3f5c9cad CY |
328 | (get 'x-selections (or type 'PRIMARY))) |
329 | ||
330 | ;; x-selection-owner-p is used in simple.el | |
331 | (defun x-selection-owner-p (&optional type) | |
332 | (and (memq type '(nil PRIMARY SECONDARY)) | |
333 | (get 'x-selections (or type 'PRIMARY)))) | |
bffcf874 | 334 | |
1b42a753 | 335 | (defun set-w32-system-coding-system (coding-system) |
49bd2bfe | 336 | "Set the coding system used by the Windows system to CODING-SYSTEM. |
1b42a753 | 337 | This is used for things like passing font names with non-ASCII |
551ea1bd | 338 | characters in them to the system. For a list of possible values of |
086ceb30 JR |
339 | CODING-SYSTEM, use \\[list-coding-systems]. |
340 | ||
341 | This function is provided for backward compatibility, since | |
49bd2bfe | 342 | `w32-system-coding-system' is now an alias for `locale-coding-system'." |
1b42a753 | 343 | (interactive |
086ceb30 | 344 | (list (let ((default locale-coding-system)) |
1b42a753 | 345 | (read-coding-system |
5b76833f | 346 | (format "Coding system for system calls (default %s): " |
1b42a753 GV |
347 | default) |
348 | default)))) | |
349 | (check-coding-system coding-system) | |
086ceb30 JR |
350 | (setq locale-coding-system coding-system)) |
351 | ||
352 | ;; locale-coding-system was introduced to do the same thing as | |
353 | ;; w32-system-coding-system. Use that instead. | |
354 | (defvaralias 'w32-system-coding-system 'locale-coding-system) | |
1b42a753 | 355 | |
f2b256fa | 356 | ;; Set to a system sound if you want a fancy bell. |
81b38822 KH |
357 | (set-message-beep nil) |
358 | ||
f2b256fa SM |
359 | ;; The "Windows" keys on newer keyboards bring up the Start menu |
360 | ;; whether you want it or not - make Emacs ignore these keystrokes | |
361 | ;; rather than beep. | |
d234707d GV |
362 | (global-set-key [lwindow] 'ignore) |
363 | (global-set-key [rwindow] 'ignore) | |
364 | ||
15fa6efb JR |
365 | (defun w32-add-charset-info (xlfd-charset windows-charset codepage) |
366 | "Function to add character sets to display with Windows fonts. | |
367 | Creates entries in `w32-charset-info-alist'. | |
368 | XLFD-CHARSET is a string which will appear in the XLFD font name to | |
72ab66eb | 369 | identify the character set. WINDOWS-CHARSET is a symbol identifying |
551ea1bd JB |
370 | the Windows character set this maps to. For the list of possible |
371 | values, see the documentation for `w32-charset-info-alist'. CODEPAGE | |
15fa6efb JR |
372 | can be a numeric codepage that Windows uses to display the character |
373 | set, t for Unicode output with no codepage translation or nil for 8 | |
374 | bit output with no translation." | |
375 | (add-to-list 'w32-charset-info-alist | |
72ab66eb | 376 | (cons xlfd-charset (cons windows-charset codepage)))) |
15fa6efb | 377 | |
4c7ec703 JR |
378 | ;; The last charset we add becomes the "preferred" charset for the return |
379 | ;; value from w32-select-font etc, so list the most important charsets last. | |
15fa6efb JR |
380 | (w32-add-charset-info "iso8859-14" 'w32-charset-ansi 28604) |
381 | (w32-add-charset-info "iso8859-15" 'w32-charset-ansi 28605) | |
2005121f JR |
382 | ;; The following two are included for pattern matching. |
383 | (w32-add-charset-info "jisx0201" 'w32-charset-shiftjis 932) | |
384 | (w32-add-charset-info "jisx0208" 'w32-charset-shiftjis 932) | |
15fa6efb JR |
385 | (w32-add-charset-info "jisx0201-latin" 'w32-charset-shiftjis 932) |
386 | (w32-add-charset-info "jisx0201-katakana" 'w32-charset-shiftjis 932) | |
751be31e JR |
387 | (w32-add-charset-info "ksc5601.1989" 'w32-charset-hangeul 949) |
388 | (w32-add-charset-info "big5" 'w32-charset-chinesebig5 950) | |
389 | (w32-add-charset-info "gb2312.1980" 'w32-charset-gb2312 936) | |
15fa6efb JR |
390 | (w32-add-charset-info "ms-symbol" 'w32-charset-symbol nil) |
391 | (w32-add-charset-info "ms-oem" 'w32-charset-oem 437) | |
392 | (w32-add-charset-info "ms-oemlatin" 'w32-charset-oem 850) | |
57016d37 JR |
393 | (w32-add-charset-info "iso8859-2" 'w32-charset-easteurope 28592) |
394 | (w32-add-charset-info "iso8859-3" 'w32-charset-turkish 28593) | |
395 | (w32-add-charset-info "iso8859-4" 'w32-charset-baltic 28594) | |
396 | (w32-add-charset-info "iso8859-6" 'w32-charset-arabic 28596) | |
397 | (w32-add-charset-info "iso8859-7" 'w32-charset-greek 28597) | |
398 | (w32-add-charset-info "iso8859-8" 'w32-charset-hebrew 1255) | |
399 | (w32-add-charset-info "iso8859-9" 'w32-charset-turkish 1254) | |
400 | (w32-add-charset-info "iso8859-13" 'w32-charset-baltic 1257) | |
401 | (w32-add-charset-info "koi8-r" 'w32-charset-russian 20866) | |
402 | (w32-add-charset-info "iso8859-5" 'w32-charset-russian 28595) | |
18885c11 | 403 | (w32-add-charset-info "tis620-2533" 'w32-charset-thai 874) |
57016d37 JR |
404 | (w32-add-charset-info "windows-1258" 'w32-charset-vietnamese 1258) |
405 | (w32-add-charset-info "ksc5601.1992" 'w32-charset-johab 1361) | |
7992f52c JR |
406 | (w32-add-charset-info "mac-roman" 'w32-charset-mac 10000) |
407 | (w32-add-charset-info "iso10646-1" 'w32-charset-default t) | |
57016d37 | 408 | |
2005121f JR |
409 | ;; ;; If unicode windows charset is not defined, use ansi fonts. |
410 | ;; (w32-add-charset-info "iso10646-1" 'w32-charset-ansi t)) | |
411 | ||
412 | ;; Prefered names | |
413 | (w32-add-charset-info "big5-0" 'w32-charset-chinesebig5 950) | |
414 | (w32-add-charset-info "gb2312.1980-0" 'w32-charset-gb2312 936) | |
415 | (w32-add-charset-info "jisx0208-sjis" 'w32-charset-shiftjis 932) | |
416 | (w32-add-charset-info "ksc5601.1987-0" 'w32-charset-hangeul 949) | |
417 | (w32-add-charset-info "tis620-0" 'w32-charset-thai 874) | |
4c7ec703 | 418 | (w32-add-charset-info "iso8859-1" 'w32-charset-ansi 1252) |
52f32671 | 419 | |
47092217 JR |
420 | (make-obsolete-variable 'w32-enable-italics |
421 | 'w32-enable-synthesized-fonts "21.1") | |
d4b7d6b4 | 422 | (make-obsolete-variable 'w32-charset-to-codepage-alist |
47092217 | 423 | 'w32-charset-info-alist "21.1") |
d4b7d6b4 | 424 | |
3b4cf5db AI |
425 | \f |
426 | ;;;; Selections and cut buffers | |
427 | ||
f2b256fa SM |
428 | ;; We keep track of the last text selected here, so we can check the |
429 | ;; current selection against it, and avoid passing back our own text | |
430 | ;; from x-cut-buffer-or-selection-value. | |
3b4cf5db AI |
431 | (defvar x-last-selected-text nil) |
432 | ||
f2b256fa SM |
433 | ;; It is said that overlarge strings are slow to put into the cut buffer. |
434 | ;; Note this value is overridden below. | |
3b4cf5db AI |
435 | (defvar x-cut-buffer-max 20000 |
436 | "Max number of characters to put in the cut buffer.") | |
437 | ||
3b4cf5db | 438 | (defun x-select-text (text &optional push) |
3077d1f6 EZ |
439 | "Select TEXT, a string, according to the window system. |
440 | ||
441 | On X, put TEXT in the primary X selection. For backward | |
442 | compatibility with older X applications, set the value of X cut | |
443 | buffer 0 as well, and if the optional argument PUSH is non-nil, | |
444 | rotate the cut buffers. If `x-select-enable-clipboard' is | |
445 | non-nil, copy the text to the X clipboard as well. | |
446 | ||
447 | On Windows, make TEXT the current selection. If | |
448 | `x-select-enable-clipboard' is non-nil, copy the text to the | |
449 | clipboard as well. The argument PUSH is ignored. | |
450 | ||
451 | On Nextstep, put TEXT in the pasteboard; PUSH is ignored." | |
3b4cf5db AI |
452 | (if x-select-enable-clipboard |
453 | (w32-set-clipboard-data text)) | |
454 | (setq x-last-selected-text text)) | |
bcaf1c36 | 455 | |
3b4cf5db AI |
456 | (defun x-get-selection-value () |
457 | "Return the value of the current selection. | |
458 | Consult the selection, then the cut buffer. Treat empty strings as if | |
459 | they were unset." | |
460 | (if x-select-enable-clipboard | |
461 | (let (text) | |
462 | ;; Don't die if x-get-selection signals an error. | |
463 | (condition-case c | |
464 | (setq text (w32-get-clipboard-data)) | |
465 | (error (message "w32-get-clipboard-data:%s" c))) | |
466 | (if (string= text "") (setq text nil)) | |
467 | (cond | |
468 | ((not text) nil) | |
469 | ((eq text x-last-selected-text) nil) | |
470 | ((string= text x-last-selected-text) | |
471 | ;; Record the newer string, so subsequent calls can use the 'eq' test. | |
472 | (setq x-last-selected-text text) | |
473 | nil) | |
474 | (t | |
475 | (setq x-last-selected-text text)))))) | |
476 | \f | |
477 | (defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value) | |
478 | ||
f2b256fa | 479 | ;; Arrange for the kill and yank functions to set and check the clipboard. |
3b4cf5db AI |
480 | (setq interprogram-cut-function 'x-select-text) |
481 | (setq interprogram-paste-function 'x-get-selection-value) | |
482 | ||
3712a0b3 EZ |
483 | \f |
484 | ;;;; Support for build process | |
485 | (defun w32-batch-update-autoloads () | |
486 | "Like `batch-update-autoloads', but takes the name of the autoloads file | |
487 | from the command line. | |
488 | ||
489 | This is required because some Windows build environments, such as MSYS, | |
490 | munge command-line arguments that include file names to a horrible mess | |
491 | that Emacs is unable to cope with." | |
492 | (let ((generated-autoload-file | |
af9fb32f GM |
493 | (expand-file-name (pop command-line-args-left))) |
494 | ;; I can only assume the same considerations may apply here... | |
495 | (autoload-make-program (pop command-line-args-left))) | |
3712a0b3 | 496 | (batch-update-autoloads))) |
3b4cf5db | 497 | |
d1dcf3e7 EZ |
498 | (defun w32-append-code-lines (orig extra) |
499 | "Append non-empty non-comment lines in the file EXTRA to the file ORIG. | |
500 | ||
501 | This function saves all buffers and kills the Emacs session, without asking | |
502 | for any permissions. | |
503 | ||
504 | This is required because the Windows build environment is not required | |
505 | to include Sed, which is used by leim/Makefile.in to do the job." | |
506 | (find-file orig) | |
507 | (goto-char (point-max)) | |
508 | (insert-file-contents extra) | |
509 | (delete-matching-lines "^$\\|^;") | |
510 | (save-buffers-kill-emacs t)) | |
511 | ||
cbee283d | 512 | ;; arch-tag: c49b48cc-0f4f-454f-a274-c2dc34815e14 |
a0d14345 | 513 | ;;; w32-fns.el ends here |