Mercurial > hg > xemacs-beta
comparison lisp/w3/w3-sysdp.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | c53a95d3c46d |
children | 1ce6082ce73f |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
1 ;;; sysdep.el --- consolidate Emacs-version dependencies in one file. | 1 ;;; sysdep.el --- consolidate Emacs-version dependencies in one file. |
2 | 2 |
3 ;; Copyright (c) 1995 - 1997 Ben Wing. | 3 ;; Copyright (C) 1995 Ben Wing. |
4 | 4 |
5 ;; Author: Ben Wing <wing@666.com>, William Perry <wmperry@cs.indiana.edu> | 5 ;; Author: Ben Wing <wing@666.com> |
6 ;; Keywords: lisp, tools | 6 ;; Keywords: lisp, tools |
7 ;; Version: 0.003 | 7 ;; Version: 0.001 |
8 | 8 |
9 ;; The purpose of this file is to eliminate the cruftiness that | 9 ;; The purpose of this file is to eliminate the cruftiness that |
10 ;; would otherwise be required of packages that want to run on multiple | 10 ;; would otherwise be required of packages that want to run on multiple |
11 ;; versions of Emacs. The idea is that we make it look like we're running | 11 ;; versions of Emacs. The idea is that we make it look like we're running |
12 ;; the latest version of XEmacs (currently 19.12) by emulating all the | 12 ;; the latest version of XEmacs (currently 19.12) by emulating all the |
48 ;; You may well discover deficiencies in this file as you use it. | 48 ;; You may well discover deficiencies in this file as you use it. |
49 ;; The preferable way of dealing with this is to send me a patch | 49 ;; The preferable way of dealing with this is to send me a patch |
50 ;; to sysdep.el; that way, the collective body of knowledge gets | 50 ;; to sysdep.el; that way, the collective body of knowledge gets |
51 ;; increased. | 51 ;; increased. |
52 | 52 |
53 ;; DO NOT load this file with `require'. | |
54 ;; DO NOT put a `provide' statement in this file. | |
55 | |
53 ;; IMPORTANT: leave the version string in the format X.XXX (e.g. 1.001) | 56 ;; IMPORTANT: leave the version string in the format X.XXX (e.g. 1.001) |
54 ;; so that string comparisons to other versions work properly. | 57 ;; so that string comparisons to other versions work properly. |
55 | 58 |
56 (defconst sysdep-potential-version "0.003") | 59 (defconst sysdep-potential-version "0.002") |
60 | |
61 (if (and (boundp 'sysdep-version) | |
62 (not (string-lessp sysdep-version sysdep-potential-version))) | |
63 ;; if a more recent version of sysdep was already loaded, | |
64 ;; or if the same package is loaded again, don't load. | |
65 nil | |
66 | |
67 (defconst sysdep-version sysdep-potential-version) | |
57 | 68 |
58 ;; this macro means: define the function, but only if either it | 69 ;; this macro means: define the function, but only if either it |
59 ;; wasn't bound before, or the supplied binding comes from an older | 70 ;; wasn't bound before, or the supplied binding comes from an older |
60 ;; version of sysdep.el. That way, user-supplied bindings don't | 71 ;; version of sysdep.el. That way, user-supplied bindings don't |
61 ;; get overridden. | 72 ;; get overridden. |
64 ;; esp. since you can do load-time conditionalizing and can | 75 ;; esp. since you can do load-time conditionalizing and can |
65 ;; optionally leave the function undefined. (e.g. frame functions | 76 ;; optionally leave the function undefined. (e.g. frame functions |
66 ;; in v18.) | 77 ;; in v18.) |
67 | 78 |
68 (defmacro sysdep-defun (function &rest everything-else) | 79 (defmacro sysdep-defun (function &rest everything-else) |
69 (` (cond ((and (not (fboundp (quote (, function)))) | 80 (` (cond ((or (not (fboundp (quote (, function)))) |
70 (or | 81 (get (quote (, function)) 'sysdep-defined-this)) |
71 (not | 82 (put (quote (, function)) 'sysdep-defined-this t) |
72 (stringp (get (quote (, function)) 'sysdep-defined-this))) | |
73 (and (get (quote (, function)) 'sysdep-defined-this) | |
74 (string-lessp | |
75 (get (quote (, function)) 'sysdep-defined-this) | |
76 sysdep-potential-version)))) | |
77 (put (quote (, function)) 'sysdep-defined-this | |
78 sysdep-potential-version) | |
79 (defun (, function) (,@ everything-else)))))) | 83 (defun (, function) (,@ everything-else)))))) |
80 | 84 |
81 (defmacro sysdep-defvar (function &rest everything-else) | 85 (defmacro sysdep-defvar (function &rest everything-else) |
82 (` (cond ((and (not (boundp (quote (, function)))) | 86 (` (cond ((or (not (boundp (quote (, function)))) |
83 (or | 87 (get (quote (, function)) 'sysdep-defined-this)) |
84 (not | |
85 (stringp (get (quote (, function)) 'sysdep-defined-this))) | |
86 (and (get (quote (, function)) 'sysdep-defined-this) | |
87 (string-lessp | |
88 (get (quote (, function)) 'sysdep-defined-this) | |
89 sysdep-potential-version)))) | |
90 (put (quote (, function)) 'sysdep-defined-this t) | 88 (put (quote (, function)) 'sysdep-defined-this t) |
91 (defvar (, function) (,@ everything-else)))))) | 89 (defvar (, function) (,@ everything-else)))))) |
92 | 90 |
93 (defmacro sysdep-defconst (function &rest everything-else) | 91 (defmacro sysdep-defconst (function &rest everything-else) |
94 (` (cond ((and (not (boundp (quote (, function)))) | 92 (` (cond ((or (not (boundp (quote (, function)))) |
95 (or | 93 (get (quote (, function)) 'sysdep-defined-this)) |
96 (not | |
97 (stringp (get (quote (, function)) 'sysdep-defined-this))) | |
98 (and (get (quote (, function)) 'sysdep-defined-this) | |
99 (string-lessp | |
100 (get (quote (, function)) 'sysdep-defined-this) | |
101 sysdep-potential-version)))) | |
102 (put (quote (, function)) 'sysdep-defined-this t) | 94 (put (quote (, function)) 'sysdep-defined-this t) |
103 (defconst (, function) (,@ everything-else)))))) | 95 (defconst (, function) (,@ everything-else)))))) |
104 | 96 |
105 ;; similar for fset and defalias. No need to quote as the argument | 97 ;; similar for fset and defalias. No need to quote as the argument |
106 ;; is already quoted. | 98 ;; is already quoted. |
107 | 99 |
108 (defmacro sysdep-fset (function def) | 100 (defmacro sysdep-fset (function def) |
109 (` (cond ((and (not (fboundp (, function))) | 101 (` (cond ((and (or (not (fboundp (, function))) |
110 (or (not (stringp | 102 (get (, function) 'sysdep-defined-this)) |
111 (get (, function) 'sysdep-defined-this))) | |
112 (and (get (, function) 'sysdep-defined-this) | |
113 (string-lessp | |
114 (get (, function) 'sysdep-defined-this) | |
115 sysdep-potential-version))) | |
116 (, def)) | 103 (, def)) |
117 (put (, function) 'sysdep-defined-this t) | 104 (put (, function) 'sysdep-defined-this t) |
118 (fset (, function) (, def)))))) | 105 (fset (, function) (, def)))))) |
119 | 106 |
120 (defmacro sysdep-defalias (function def) | 107 (defmacro sysdep-defalias (function def) |
121 (` (cond ((and (not (fboundp (, function))) | 108 (` (cond ((and (or (not (fboundp (, function))) |
122 (or (not (stringp | 109 (get (, function) 'sysdep-defined-this)) |
123 (get (, function) 'sysdep-defined-this))) | |
124 (and (get (, function) 'sysdep-defined-this) | |
125 (string-lessp | |
126 (get (, function) 'sysdep-defined-this) | |
127 sysdep-potential-version))) | |
128 (, def) | 110 (, def) |
129 (or (listp (, def)) | 111 (or (listp (, def)) |
130 (and (symbolp (, def)) | 112 (and (symbolp (, def)) |
131 (fboundp (, def))))) | 113 (fboundp (, def))))) |
132 (put (, function) 'sysdep-defined-this t) | 114 (put (, function) 'sysdep-defined-this t) |
229 (sysdep-defalias 'get-frame-for-buffer 'get-screen-for-buffer) | 211 (sysdep-defalias 'get-frame-for-buffer 'get-screen-for-buffer) |
230 (sysdep-defalias 'get-frame-for-buffer-noselect 'get-screen-for-buffer-noselect) | 212 (sysdep-defalias 'get-frame-for-buffer-noselect 'get-screen-for-buffer-noselect) |
231 (sysdep-defalias 'get-other-frame 'get-other-screen) | 213 (sysdep-defalias 'get-other-frame 'get-other-screen) |
232 (sysdep-defalias 'iconify-frame 'iconify-screen) | 214 (sysdep-defalias 'iconify-frame 'iconify-screen) |
233 (sysdep-defalias 'lower-frame 'lower-screen) | 215 (sysdep-defalias 'lower-frame 'lower-screen) |
234 ;(sysdep-defalias 'mail-other-frame 'mail-other-screen) | 216 (sysdep-defalias 'mail-other-frame 'mail-other-screen) |
235 | 217 |
236 (sysdep-defalias 'make-frame | 218 (sysdep-defalias 'make-frame |
237 (cond ((fboundp 'make-screen) | 219 (cond ((fboundp 'make-screen) |
238 (function (lambda (&optional parameters device) | 220 (function (lambda (&optional parameters device) |
239 (make-screen parameters)))) | 221 (make-screen parameters)))) |
278 (sysdep-defalias 'x-set-frame-pointer 'x-set-screen-pointer) | 260 (sysdep-defalias 'x-set-frame-pointer 'x-set-screen-pointer) |
279 (sysdep-defalias 'x-display-color-p 'x-color-display-p) | 261 (sysdep-defalias 'x-display-color-p 'x-color-display-p) |
280 (sysdep-defalias 'x-display-grayscale-p 'x-grayscale-display-p) | 262 (sysdep-defalias 'x-display-grayscale-p 'x-grayscale-display-p) |
281 (sysdep-defalias 'menu-event-p 'misc-user-event-p) | 263 (sysdep-defalias 'menu-event-p 'misc-user-event-p) |
282 | 264 |
283 ;; WMP - commention these out so that Emacs 19 doesn't get screwed by them. | 265 (sysdep-defun add-submenu (menu-path submenu &optional before) |
284 ;; In particular, this makes the 'custom' package blow up quite well. | 266 "Add a menu to the menubar or one of its submenus. |
285 ;;(sysdep-defun add-submenu (menu-path submenu &optional before) | 267 If the named menu exists already, it is changed. |
286 ;; "Add a menu to the menubar or one of its submenus. | 268 MENU-PATH identifies the menu under which the new menu should be inserted. |
287 ;;If the named menu exists already, it is changed. | 269 It is a list of strings; for example, (\"File\") names the top-level \"File\" |
288 ;;MENU-PATH identifies the menu under which the new menu should be inserted. | 270 menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\". |
289 ;; It is a list of strings; for example, (\"File\") names the top-level \"File\" | 271 If MENU-PATH is nil, then the menu will be added to the menubar itself. |
290 ;; menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\". | 272 SUBMENU is the new menu to add. |
291 ;; If MENU-PATH is nil, then the menu will be added to the menubar itself. | 273 See the documentation of `current-menubar' for the syntax. |
292 ;;SUBMENU is the new menu to add. | 274 BEFORE, if provided, is the name of a menu before which this menu should |
293 ;; See the documentation of `current-menubar' for the syntax. | 275 be added, if this menu is not on its parent already. If the menu is already |
294 ;;BEFORE, if provided, is the name of a menu before which this menu should | 276 present, it will not be moved." |
295 ;; be added, if this menu is not on its parent already. If the menu is already | 277 (add-menu menu-path (car submenu) (cdr submenu) before)) |
296 ;; present, it will not be moved." | 278 |
297 ;; (add-menu menu-path (car submenu) (cdr submenu) before)) | 279 (sysdep-defun add-menu-button (menu-path menu-leaf &optional before) |
298 | 280 "Add a menu item to some menu, creating the menu first if necessary. |
299 ;;(sysdep-defun add-menu-button (menu-path menu-leaf &optional before) | 281 If the named item exists already, it is changed. |
300 ;; "Add a menu item to some menu, creating the menu first if necessary. | 282 MENU-PATH identifies the menu under which the new menu item should be inserted. |
301 ;;If the named item exists already, it is changed. | 283 It is a list of strings; for example, (\"File\") names the top-level \"File\" |
302 ;;MENU-PATH identifies the menu under which the new menu item should be inserted. | 284 menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\". |
303 ;; It is a list of strings; for example, (\"File\") names the top-level \"File\" | 285 MENU-LEAF is a menubar leaf node. See the documentation of `current-menubar'. |
304 ;; menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\". | 286 BEFORE, if provided, is the name of a menu item before which this item should |
305 ;;MENU-LEAF is a menubar leaf node. See the documentation of `current-menubar'. | 287 be added, if this item is not on the menu already. If the item is already |
306 ;;BEFORE, if provided, is the name of a menu item before which this item should | 288 present, it will not be moved." |
307 ;; be added, if this item is not on the menu already. If the item is already | 289 (add-menu-item menu-path (aref menu-leaf 0) (aref menu-leaf 1) |
308 ;; present, it will not be moved." | 290 (aref menu-leaf 2) before)) |
309 ;; (add-menu-item menu-path (aref menu-leaf 0) (aref menu-leaf 1) | |
310 ;; (aref menu-leaf 2) before)) | |
311 | 291 |
312 (sysdep-defun make-glyph (&optional spec-list) | 292 (sysdep-defun make-glyph (&optional spec-list) |
313 (if (and spec-list (cdr-safe (assq 'x spec-list))) | 293 (if (and spec-list (cdr-safe (assq 'x spec-list))) |
314 (make-pixmap (cdr-safe (assq 'x spec-list))))) | 294 (make-pixmap (cdr-safe (assq 'x spec-list))))) |
315 | 295 |
316 (sysdep-defalias 'face-list 'list-faces) | 296 (sysdep-defalias 'face-list 'list-faces) |
317 | |
318 (sysdep-defun set-keymap-parent (keymap new-parent) | |
319 (let ((tail keymap)) | |
320 (while (and tail (cdr tail) (not (eq (car (cdr tail)) 'keymap))) | |
321 (setq tail (cdr tail))) | |
322 (if tail | |
323 (setcdr tail new-parent)))) | |
324 | 297 |
325 (sysdep-defun facep (face) | 298 (sysdep-defun facep (face) |
326 "Return t if X is a face name or an internal face vector." | 299 "Return t if X is a face name or an internal face vector." |
327 ;; CAUTION!!! This is Emacs 19.x, for x <= 28, specific | 300 ;; CAUTION!!! This is Emacs 19.x, for x <= 28, specific |
328 ;; I know of no version of Lucid Emacs or XEmacs that did not have | 301 ;; I know of no version of Lucid Emacs or XEmacs that did not have |
329 ;; facep. Even if they did, they are unsupported, so big deal. | 302 ;; facep. Even if they did, they are unsupported, so big deal. |
330 (if (not window-system) | 303 (and (or (internal-facep face) |
331 nil ; FIXME if FSF ever does TTY faces | 304 (and (symbolp face) (assq face global-face-data))) |
332 (and (or (internal-facep face) | 305 t)) |
333 (and (symbolp face) (assq face global-face-data))) | |
334 t))) | |
335 | 306 |
336 (sysdep-defun set-face-property (face property value &optional locale | 307 (sysdep-defun set-face-property (face property value &optional locale |
337 tag-set how-to-add) | 308 tag-set how-to-add) |
338 "Change a property of FACE." | 309 "Change a property of FACE." |
339 (and (symbolp face) | 310 (and (symbolp face) |
340 (put face property value))) | 311 (put face property value))) |
341 | 312 |
342 (sysdep-defun face-property (face property &optional locale tag-set exact-p) | 313 (sysdep-defun face-property (face property &optional locale tag-set exact-p) |
343 "Return FACE's value of the given PROPERTY." | 314 "Return FACE's value of the given PROPERTY." |
344 (and (symbolp face) (get face property))) | 315 (and (symbolp face) (get face property))) |
345 | |
346 ;;; Additional text property functions. | |
347 | |
348 ;; The following three text property functions are not generally available (and | |
349 ;; it's not certain that they should be) so they are inlined for speed. | |
350 ;; The case for `fillin-text-property' is simple; it may or not be generally | |
351 ;; useful. (Since it is used here, it is useful in at least one place.;-) | |
352 ;; However, the case for `append-text-property' and `prepend-text-property' is | |
353 ;; more complicated. Should they remove duplicate property values or not? If | |
354 ;; so, should the first or last duplicate item remain? Or the one that was | |
355 ;; added? In our implementation, the first duplicate remains. | |
356 | |
357 (sysdep-defun fillin-text-property (start end setprop markprop value &optional object) | |
358 "Fill in one property of the text from START to END. | |
359 Arguments PROP and VALUE specify the property and value to put where none are | |
360 already in place. Therefore existing property values are not overwritten. | |
361 Optional argument OBJECT is the string or buffer containing the text." | |
362 (let ((start (text-property-any start end markprop nil object)) next) | |
363 (while start | |
364 (setq next (next-single-property-change start markprop object end)) | |
365 (put-text-property start next setprop value object) | |
366 (put-text-property start next markprop value object) | |
367 (setq start (text-property-any next end markprop nil object))))) | |
368 | |
369 ;; This function (from simon's unique.el) is rewritten and inlined for speed. | |
370 ;(defun unique (list function) | |
371 ; "Uniquify LIST, deleting elements using FUNCTION. | |
372 ;Return the list with subsequent duplicate items removed by side effects. | |
373 ;FUNCTION is called with an element of LIST and a list of elements from LIST, | |
374 ;and should return the list of elements with occurrences of the element removed, | |
375 ;i.e., a function such as `delete' or `delq'. | |
376 ;This function will work even if LIST is unsorted. See also `uniq'." | |
377 ; (let ((list list)) | |
378 ; (while list | |
379 ; (setq list (setcdr list (funcall function (car list) (cdr list)))))) | |
380 ; list) | |
381 | |
382 (sysdep-defun unique (list) | |
383 "Uniquify LIST, deleting elements using `delq'. | |
384 Return the list with subsequent duplicate items removed by side effects." | |
385 (let ((list list)) | |
386 (while list | |
387 (setq list (setcdr list (delq (car list) (cdr list)))))) | |
388 list) | |
389 | |
390 ;; A generalisation of `facemenu-add-face' for any property, but without the | |
391 ;; removal of inactive faces via `facemenu-discard-redundant-faces' and special | |
392 ;; treatment of `default'. Uses `unique' to remove duplicate property values. | |
393 (sysdep-defun prepend-text-property (start end prop value &optional object) | |
394 "Prepend to one property of the text from START to END. | |
395 Arguments PROP and VALUE specify the property and value to prepend to the value | |
396 already in place. The resulting property values are always lists, and unique. | |
397 Optional argument OBJECT is the string or buffer containing the text." | |
398 (let ((val (if (listp value) value (list value))) next prev) | |
399 (while (/= start end) | |
400 (setq next (next-single-property-change start prop object end) | |
401 prev (get-text-property start prop object)) | |
402 (put-text-property | |
403 start next prop | |
404 (unique (append val (if (listp prev) prev (list prev)))) | |
405 object) | |
406 (setq start next)))) | |
407 | |
408 (sysdep-defun append-text-property (start end prop value &optional object) | |
409 "Append to one property of the text from START to END. | |
410 Arguments PROP and VALUE specify the property and value to append to the value | |
411 already in place. The resulting property values are always lists, and unique. | |
412 Optional argument OBJECT is the string or buffer containing the text." | |
413 (let ((val (if (listp value) value (list value))) next prev) | |
414 (while (/= start end) | |
415 (setq next (next-single-property-change start prop object end) | |
416 prev (get-text-property start prop object)) | |
417 (put-text-property | |
418 start next prop | |
419 (unique (append (if (listp prev) prev (list prev)) val)) | |
420 object) | |
421 (setq start next)))) | |
422 | |
423 (sysdep-defun buffer-substring-no-properties (st nd) | |
424 "Return the characters of part of the buffer, without the text properties. | |
425 The two arguments START and END are character positions; | |
426 they can be in either order." | |
427 (buffer-substring st nd)) | |
428 | 316 |
429 ;; Property list functions | 317 ;; Property list functions |
430 ;; | 318 ;; |
431 (sysdep-defun plist-put (plist prop val) | 319 (sysdep-defun plist-put (plist prop val) |
432 "Change value in PLIST of PROP to VAL. | 320 "Change value in PLIST of PROP to VAL. |
446 "Extract a value from a property list. | 334 "Extract a value from a property list. |
447 PLIST is a property list, which is a list of the form | 335 PLIST is a property list, which is a list of the form |
448 (PROP1 VALUE1 PROP2 VALUE2...). This function returns the value | 336 (PROP1 VALUE1 PROP2 VALUE2...). This function returns the value |
449 corresponding to the given PROP, or nil if PROP is not | 337 corresponding to the given PROP, or nil if PROP is not |
450 one of the properties on the list." | 338 one of the properties on the list." |
451 (while (and plist (not (eq (car plist) prop))) | 339 (car-safe (cdr-safe (memq prop plist)))) |
452 (setq plist (cdr (cdr plist)))) | |
453 (and plist (car (cdr plist)))) | |
454 | 340 |
455 ;; Device functions | 341 ;; Device functions |
456 ;; By wmperry@cs.indiana.edu | 342 ;; By wmperry@cs.indiana.edu |
457 ;; This is a complete implementation of all the device-* functions found in | 343 ;; This is a complete implementation of all the device-* functions found in |
458 ;; XEmacs 19.14. A 'device' for Emacs 19 is just a frame, from which we can | 344 ;; XEmacs 19.14. A 'device' for Emacs 19 is just a frame, from which we can |
486 If CONNECTION specifies an already-existing device connection, that | 372 If CONNECTION specifies an already-existing device connection, that |
487 device is simply returned; no new device is created, and PROPS | 373 device is simply returned; no new device is created, and PROPS |
488 have no effect." | 374 have no effect." |
489 (cond | 375 (cond |
490 ((and (eq type 'x) connection) | 376 ((and (eq type 'x) connection) |
491 (make-frame-on-display connection props)) | 377 (make-frame-on-display display props)) |
492 ((eq type 'x) | 378 ((eq type 'x) |
493 (make-frame props)) | 379 (make-frame props)) |
494 ((eq type 'tty) | 380 ((eq type 'tty) |
495 nil) | 381 nil) |
496 (t | 382 (t |
513 system. Not currently implemented. | 399 system. Not currently implemented. |
514 win32 A connection to a machine running Microsoft Windows NT or | 400 win32 A connection to a machine running Microsoft Windows NT or |
515 Windows 95. Not currently implemented. | 401 Windows 95. Not currently implemented. |
516 pc A direct-write MS-DOS frame. Not currently implemented. | 402 pc A direct-write MS-DOS frame. Not currently implemented. |
517 | 403 |
518 PROPS should be an plist of properties, as in the call to `make-frame'. | 404 PROPS should be a plist of properties, as in the call to `make-frame'. |
519 | 405 |
520 If a connection to CONNECTION already exists, it is reused; otherwise, | 406 If a connection to CONNECTION already exists, it is reused; otherwise, |
521 a new connection is opened." | 407 a new connection is opened." |
522 (make-device type connection props)) | 408 (make-device type connection props)) |
523 | 409 |
659 ((fboundp 'x-display-color-cells) 'x-display-color-cells) | 545 ((fboundp 'x-display-color-cells) 'x-display-color-cells) |
660 ((fboundp 'ns-display-color-cells) 'ns-display-color-celles) | 546 ((fboundp 'ns-display-color-cells) 'ns-display-color-celles) |
661 (t 'ignore))) | 547 (t 'ignore))) |
662 | 548 |
663 (sysdep-defun try-font-name (fontname &rest args) | 549 (sysdep-defun try-font-name (fontname &rest args) |
664 (cond | 550 (car-safe (x-list-fonts fontname))) |
665 ((eq window-system 'x) (car-safe (x-list-fonts fontname))) | |
666 ((eq window-system 'ns) (car-safe (ns-list-fonts fontname))) | |
667 ((eq window-system 'win32) (car-safe (x-list-fonts fontname))) | |
668 ((eq window-system 'pm) (car-safe (x-list-fonts fontname))) | |
669 (t nil))) | |
670 | 551 |
671 (sysdep-defalias 'device-pixel-width | 552 (sysdep-defalias 'device-pixel-width |
672 (cond | 553 (cond |
673 ((and (memq window-system '(x win32 pm)) (fboundp 'x-display-pixel-width)) | 554 ((and (eq window-system 'x) (fboundp 'x-display-pixel-width)) |
674 'x-display-pixel-width) | 555 'x-display-pixel-width) |
675 ((and (eq window-system 'ns) (fboundp 'ns-display-pixel-width)) | 556 ((and (eq window-system 'ns) (fboundp 'ns-display-pixel-width)) |
676 'ns-display-pixel-width) | 557 'ns-display-pixel-width) |
677 (t 'ignore))) | 558 (t 'ignore))) |
678 | 559 |
679 (sysdep-defalias 'device-pixel-height | 560 (sysdep-defalias 'device-pixel-height |
680 (cond | 561 (cond |
681 ((and (memq window-system '(x win32 pm)) (fboundp 'x-display-pixel-height)) | 562 ((and (eq window-system 'x) (fboundp 'x-display-pixel-height)) |
682 'x-display-pixel-height) | 563 'x-display-pixel-height) |
683 ((and (eq window-system 'ns) (fboundp 'ns-display-pixel-height)) | 564 ((and (eq window-system 'ns) (fboundp 'ns-display-pixel-height)) |
684 'ns-display-pixel-height) | 565 'ns-display-pixel-height) |
685 (t 'ignore))) | 566 (t 'ignore))) |
686 | 567 |
687 (sysdep-defalias 'device-mm-width | 568 (sysdep-defalias 'device-mm-width |
688 (cond | 569 (cond |
689 ((and (memq window-system '(x win32 pm)) (fboundp 'x-display-mm-width)) | 570 ((and (eq window-system 'x) (fboundp 'x-display-mm-width)) |
690 'x-display-mm-width) | 571 'x-display-mm-width) |
691 ((and (eq window-system 'ns) (fboundp 'ns-display-mm-width)) | 572 ((and (eq window-system 'ns) (fboundp 'ns-display-mm-width)) |
692 'ns-display-mm-width) | 573 'ns-display-mm-width) |
693 (t 'ignore))) | 574 (t 'ignore))) |
694 | 575 |
695 (sysdep-defalias 'device-mm-height | 576 (sysdep-defalias 'device-mm-height |
696 (cond | 577 (cond |
697 ((and (memq window-system '(x win32 pm)) (fboundp 'x-display-mm-height)) | 578 ((and (eq window-system 'x) (fboundp 'x-display-mm-height)) |
698 'x-display-mm-height) | 579 'x-display-mm-height) |
699 ((and (eq window-system 'ns) (fboundp 'ns-display-mm-height)) | 580 ((and (eq window-system 'ns) (fboundp 'ns-display-mm-height)) |
700 'ns-display-mm-height) | 581 'ns-display-mm-height) |
701 (t 'ignore))) | 582 (t 'ignore))) |
702 | 583 |
703 (sysdep-defalias 'device-bitplanes | 584 (sysdep-defalias 'device-bitplanes |
704 (cond | 585 (cond |
705 ((and (memq window-system '(x win32 pm)) (fboundp 'x-display-planes)) | 586 ((and (eq window-system 'x) (fboundp 'x-display-planes)) |
706 'x-display-planes) | 587 'x-display-planes) |
707 ((and (eq window-system 'ns) (fboundp 'ns-display-planes)) | 588 ((and (eq window-system 'ns) (fboundp 'ns-display-planes)) |
708 'ns-display-planes) | 589 'ns-display-planes) |
709 (t 'ignore))) | 590 (t 'ignore))) |
710 | 591 |
753 (let ((val (symbol-name (ns-display-visual-class)))) | 634 (let ((val (symbol-name (ns-display-visual-class)))) |
754 (cond | 635 (cond |
755 ((string-match "color" val) 'color) | 636 ((string-match "color" val) 'color) |
756 ((string-match "gray-scale" val) 'grayscale) | 637 ((string-match "gray-scale" val) 'grayscale) |
757 (t 'mono)))))) | 638 (t 'mono)))))) |
758 (t (function (lambda (&optional device) 'color))))) | 639 (t (function (lambda (&optional device) 'mono))))) |
759 | 640 |
760 (sysdep-defun device-class-list () | 641 (sysdep-defun device-class-list () |
761 "Returns a list of valid device classes." | 642 "Returns a list of valid device classes." |
762 (list 'color 'grayscale 'mono)) | 643 (list 'color 'grayscale 'mono)) |
763 | 644 |
792 (list 'tty))) | 673 (list 'tty))) |
793 | 674 |
794 (sysdep-defun valid-device-type-p (type) | 675 (sysdep-defun valid-device-type-p (type) |
795 "Given a TYPE, return t if it is valid." | 676 "Given a TYPE, return t if it is valid." |
796 (memq type (device-type-list))) | 677 (memq type (device-type-list))) |
678 | |
797 | 679 |
798 ;; Extent stuff | 680 ;; Extent stuff |
799 (sysdep-fset 'delete-extent 'delete-overlay) | 681 (sysdep-fset 'delete-extent 'delete-overlay) |
800 (sysdep-fset 'extent-end-position 'overlay-end) | 682 (sysdep-fset 'extent-end-position 'overlay-end) |
801 (sysdep-fset 'extent-start-position 'overlay-start) | 683 (sysdep-fset 'extent-start-position 'overlay-start) |
989 t))) | 871 t))) |
990 x)))) | 872 x)))) |
991 (t 'identity))) ; All others | 873 (t 'identity))) ; All others |
992 | 874 |
993 ;; Misc. | 875 ;; Misc. |
994 ;; NT doesn't have make-symbolic-link | |
995 (sysdep-defalias 'make-symbolic-link 'copy-file) | |
996 | |
997 (sysdep-defun split-string (string pattern) | 876 (sysdep-defun split-string (string pattern) |
998 "Return a list of substrings of STRING which are separated by PATTERN." | 877 "Return a list of substrings of STRING which are separated by PATTERN." |
999 (let (parts (start 0)) | 878 (let (parts (start 0)) |
1000 (while (string-match pattern string start) | 879 (while (string-match pattern string start) |
1001 (setq parts (cons (substring string start (match-beginning 0)) parts) | 880 (setq parts (cons (substring string start (match-beginning 0)) parts) |
1062 (lambda (error-object stream) | 941 (lambda (error-object stream) |
1063 (princ "Peculiar error " stream) | 942 (princ "Peculiar error " stream) |
1064 (prin1 error-object stream)))) | 943 (prin1 error-object stream)))) |
1065 error-object stream)) | 944 error-object stream)) |
1066 | 945 |
1067 (sysdep-defun decode-time (&optional specified-time) | |
1068 (let* ((date (current-time-string specified-time)) | |
1069 (dateinfo (and date (timezone-parse-date date))) | |
1070 (timeinfo (and dateinfo (timezone-parse-time (aref dateinfo 3))))) | |
1071 (list (aref timeinfo 2) (aref timeinfo 1) | |
1072 (aref timeinfo 0) (aref dateinfo 2) | |
1073 (aref dateinfo 1) (aref dateinfo 0) | |
1074 "unknown" nil 0))) | |
1075 | |
1076 (sysdep-defun find-face (face) | 946 (sysdep-defun find-face (face) |
1077 (car-safe (memq face (face-list)))) | 947 (car-safe (memq face (face-list)))) |
1078 | 948 |
1079 (sysdep-defun set-marker-insertion-type (marker type) | 949 (sysdep-defun set-marker-insertion-type (marker type) |
1080 "Set the insertion-type of MARKER to TYPE. | 950 "Set the insertion-type of MARKER to TYPE. |
1084 | 954 |
1085 ;; window functions | 955 ;; window functions |
1086 | 956 |
1087 ;; not defined in v18 | 957 ;; not defined in v18 |
1088 (sysdep-defun eval-buffer (bufname &optional printflag) | 958 (sysdep-defun eval-buffer (bufname &optional printflag) |
1089 (interactive) | |
1090 (save-excursion | 959 (save-excursion |
1091 (set-buffer bufname) | 960 (set-buffer bufname) |
1092 (eval-current-buffer))) | 961 (eval-current-buffer))) |
1093 | 962 |
1094 (sysdep-defun window-minibuffer-p (window) | 963 (sysdep-defun window-minibuffer-p (window) |
1098 (sysdep-defun window-live-p (window) | 967 (sysdep-defun window-live-p (window) |
1099 "Returns t if OBJ is a window which is currently visible." | 968 "Returns t if OBJ is a window which is currently visible." |
1100 (and (windowp window) | 969 (and (windowp window) |
1101 (window-point window))) | 970 (window-point window))) |
1102 | 971 |
1103 (provide 'w3-sysdp) | 972 ;; this parenthesis closes the if statement at the top of the file. |
973 | |
974 ) | |
975 | |
976 ;; DO NOT put a provide statement here. This file should never be | |
977 ;; loaded with `require'. Use `load-library' instead. | |
978 | |
1104 ;;; sysdep.el ends here | 979 ;;; sysdep.el ends here |
1105 | 980 |
1106 ;;;(sysdep.el) Local Variables: | 981 ;;;(sysdep.el) Local Variables: |
1107 ;;;(sysdep.el) eval: (put 'sysdep-defun 'lisp-indent-function 'defun) | 982 ;;;(sysdep.el) eval: (put 'sysdep-defun 'lisp-indent-function 'defun) |
1108 ;;;(sysdep.el) eval: (put 'sysdep-defalias 'lisp-indent-function 'defun) | 983 ;;;(sysdep.el) eval: (put 'sysdep-defalias 'lisp-indent-function 'defun) |