annotate lisp/url/url-sysdp.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; sysdep.el --- consolidate Emacs-version dependencies in one file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Ben Wing <wing@666.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: lisp, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Version: 0.001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; The purpose of this file is to eliminate the cruftiness that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; would otherwise be required of packages that want to run on multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; versions of Emacs. The idea is that we make it look like we're running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the latest version of XEmacs (currently 19.12) by emulating all the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; missing functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; #### This file does not currently do any advising but should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; Unfortunately, advice.el is a hugely big package. Is any such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; thing as `advice-lite' possible?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; #### - This package is great, but its role needs to be thought out a bit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; more. Sysdep will not permit programs written for the old XEmacs API to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; run on new versions of XEmacs. Sysdep is a backward-compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; package for the latest and greatest XEmacs API. It permits programmers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; to use the latest XEmacs functionality and still have their programs run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; on older versions of XEmacs...perhaps even on FSF Emacs. It should NEVER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; ever need to be loaded in the newest XEmacs. It doesn't even make sense
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; to put it in the lisp/utils part of the XEmacs distribution because it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; real purpose is to be distributed with packages like w3 which take
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; advantage of the latest and greatest features of XEmacs but still need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; be run on older versions. --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; Any packages that wish to use this file should load it using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; `load-library'. It will not load itself if a version of sysdep.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; that is at least as recent has already been loaded, but will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; load over an older version of sysdep.el. It will attempt to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; not redefine functions that have already been custom-redefined,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; but will redefine a function if the supplied definition came from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; an older version of sysdep.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; Packages such as w3 that wish to include this file with the package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; should rename it to something unique, such as `w3-sysdep.el', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; load it with `load-library'. That will ensure that no conflicts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; arise if more than one package in the load path provides a version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; of sysdep.el. If multiple packages load sysdep.el, the most recent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; version will end up loaded; as long as I'm careful not to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; introduce bugs in previously working definitions, this should work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; fine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; You may well discover deficiencies in this file as you use it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; The preferable way of dealing with this is to send me a patch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; to sysdep.el; that way, the collective body of knowledge gets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; increased.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; DO NOT load this file with `require'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; DO NOT put a `provide' statement in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; IMPORTANT: leave the version string in the format X.XXX (e.g. 1.001)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; so that string comparisons to other versions work properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defconst sysdep-potential-version "0.002")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (if (and (boundp 'sysdep-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (not (string-lessp sysdep-version sysdep-potential-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; if a more recent version of sysdep was already loaded,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; or if the same package is loaded again, don't load.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defconst sysdep-version sysdep-potential-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; this macro means: define the function, but only if either it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; wasn't bound before, or the supplied binding comes from an older
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; version of sysdep.el. That way, user-supplied bindings don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; get overridden.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; note: sysdep-defalias is often more useful than this function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; esp. since you can do load-time conditionalizing and can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; optionally leave the function undefined. (e.g. frame functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; in v18.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defmacro sysdep-defun (function &rest everything-else)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (` (cond ((or (not (fboundp (quote (, function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (get (quote (, function)) 'sysdep-defined-this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (put (quote (, function)) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defun (, function) (,@ everything-else))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defmacro sysdep-defvar (function &rest everything-else)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (` (cond ((or (not (boundp (quote (, function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (get (quote (, function)) 'sysdep-defined-this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (put (quote (, function)) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defvar (, function) (,@ everything-else))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defmacro sysdep-defconst (function &rest everything-else)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (` (cond ((or (not (boundp (quote (, function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (get (quote (, function)) 'sysdep-defined-this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (put (quote (, function)) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defconst (, function) (,@ everything-else))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; similar for fset and defalias. No need to quote as the argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; is already quoted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defmacro sysdep-fset (function def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (` (cond ((and (or (not (fboundp (, function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (get (, function) 'sysdep-defined-this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (, def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (put (, function) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (fset (, function) (, def))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defmacro sysdep-defalias (function def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (` (cond ((and (or (not (fboundp (, function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (get (, function) 'sysdep-defined-this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (, def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (or (listp (, def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (and (symbolp (, def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (fboundp (, def)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (put (, function) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (defalias (, function) (, def))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; bootstrapping: defalias and define-function don't exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; in older versions of lemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (sysdep-fset 'defalias 'fset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (sysdep-defalias 'define-function 'defalias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; useful ways of determining what version is running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; emacs-major-version and emacs-minor-version are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; already defined in recent versions of FSF Emacs and XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (sysdep-defconst emacs-major-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; will string-match ever fail? If so, assume 19.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; (should we assume 18.something?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if (string-match "^[0-9]+" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (substring emacs-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (sysdep-defconst emacs-minor-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (if (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (substring emacs-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (sysdep-defconst sysdep-running-xemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (or (string-match "Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (string-match "XEmacs" emacs-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (sysdep-defconst window-system nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (sysdep-defconst window-system-version 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (sysdep-defvar list-buffers-directory nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (sysdep-defvar x-library-search-path '("/usr/X11R6/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 "/usr/X11R5/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "/usr/lib/X11R6/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 "/usr/lib/X11R5/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "/usr/local/X11R6/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "/usr/local/X11R5/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 "/usr/local/lib/X11R6/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "/usr/local/lib/X11R5/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 "/usr/X11/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 "/usr/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 "/usr/local/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 "/usr/X386/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "/usr/x386/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "/usr/XFree86/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "/usr/unsupported/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 "/usr/athena/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 "/usr/local/x11r5/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 "/usr/lpp/Xamples/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "/usr/openwin/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "/usr/openwin/share/lib/X11/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "Search path used for X11 libraries.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; frame-related stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (sysdep-defalias 'buffer-dedicated-frame 'buffer-dedicated-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (sysdep-defalias 'deiconify-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (cond ((fboundp 'deiconify-screen) 'deiconify-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; make-frame-visible will be defined as necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (t 'make-frame-visible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (sysdep-defalias 'delete-frame 'delete-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (sysdep-defalias 'event-frame 'event-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (sysdep-defalias 'event-glyph-extent 'event-glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (sysdep-defalias 'find-file-other-frame 'find-file-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (sysdep-defalias 'find-file-read-only-other-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 'find-file-read-only-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (sysdep-defalias 'frame-height 'screen-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (sysdep-defalias 'frame-iconified-p 'screen-iconified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (sysdep-defalias 'frame-left-margin-width 'screen-left-margin-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (sysdep-defalias 'frame-list 'screen-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (sysdep-defalias 'frame-live-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (cond ((fboundp 'screen-live-p) 'screen-live-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ((fboundp 'live-screen-p) 'live-screen-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; #### not sure if this is correct (this is for Epoch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; but gnuserv.el uses it this way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ((fboundp 'screenp) 'screenp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (sysdep-defalias 'frame-name 'screen-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (sysdep-defalias 'frame-parameters 'screen-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (sysdep-defalias 'frame-pixel-height 'screen-pixel-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (sysdep-defalias 'frame-pixel-width 'screen-pixel-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (sysdep-defalias 'frame-right-margin-width 'screen-right-margin-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (sysdep-defalias 'frame-root-window 'screen-root-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (sysdep-defalias 'frame-selected-window 'screen-selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (sysdep-defalias 'frame-totally-visible-p 'screen-totally-visible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (sysdep-defalias 'frame-visible-p 'screen-visible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (sysdep-defalias 'frame-width 'screen-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (sysdep-defalias 'framep 'screenp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (sysdep-defalias 'get-frame-for-buffer 'get-screen-for-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (sysdep-defalias 'get-frame-for-buffer-noselect 'get-screen-for-buffer-noselect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (sysdep-defalias 'get-other-frame 'get-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (sysdep-defalias 'iconify-frame 'iconify-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (sysdep-defalias 'lower-frame 'lower-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (sysdep-defalias 'mail-other-frame 'mail-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (sysdep-defalias 'make-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (cond ((fboundp 'make-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (function (lambda (&optional parameters device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (make-screen parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ((fboundp 'x-create-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (function (lambda (&optional parameters device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (x-create-screen parameters))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (sysdep-defalias 'make-frame-invisible 'make-screen-invisible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (sysdep-defalias 'make-frame-visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (cond ((fboundp 'make-screen-visible) 'make-screen-visible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ((fboundp 'mapraised-screen) 'mapraised-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ((fboundp 'x-remap-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (lambda (&optional x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (x-remap-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (accept-process-output)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (sysdep-defalias 'modify-frame-parameters 'modify-screen-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (sysdep-defalias 'new-frame 'new-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (sysdep-defalias 'next-frame 'next-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (sysdep-defalias 'next-multiframe-window 'next-multiscreen-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (sysdep-defalias 'other-frame 'other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (sysdep-defalias 'previous-frame 'previous-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (sysdep-defalias 'previous-multiframe-window 'previous-multiscreen-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (sysdep-defalias 'raise-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (cond ((fboundp 'raise-screen) 'raise-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ((fboundp 'mapraise-screen) 'mapraise-screen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (sysdep-defalias 'redraw-frame 'redraw-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (sysdep-defalias 'select-frame 'select-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (sysdep-defalias 'selected-frame 'selected-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (sysdep-defalias 'set-buffer-dedicated-frame 'set-buffer-dedicated-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (sysdep-defalias 'set-frame-height 'set-screen-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (sysdep-defalias 'set-frame-left-margin-width 'set-screen-left-margin-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (sysdep-defalias 'set-frame-position 'set-screen-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (sysdep-defalias 'set-frame-right-margin-width 'set-screen-right-margin-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (sysdep-defalias 'set-frame-size 'set-screen-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (sysdep-defalias 'set-frame-width 'set-screen-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (sysdep-defalias 'show-temp-buffer-in-current-frame 'show-temp-buffer-in-current-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (sysdep-defalias 'switch-to-buffer-other-frame 'switch-to-buffer-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (sysdep-defalias 'visible-frame-list 'visible-screen-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (sysdep-defalias 'window-frame 'window-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (sysdep-defalias 'x-create-frame 'x-create-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (sysdep-defalias 'x-set-frame-icon-pixmap 'x-set-screen-icon-pixmap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (sysdep-defalias 'x-set-frame-pointer 'x-set-screen-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (sysdep-defalias 'x-display-color-p 'x-color-display-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (sysdep-defalias 'x-display-grayscale-p 'x-grayscale-display-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (sysdep-defalias 'menu-event-p 'misc-user-event-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (sysdep-defun add-submenu (menu-path submenu &optional before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "Add a menu to the menubar or one of its submenus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 If the named menu exists already, it is changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 MENU-PATH identifies the menu under which the new menu should be inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 It is a list of strings; for example, (\"File\") names the top-level \"File\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 If MENU-PATH is nil, then the menu will be added to the menubar itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 SUBMENU is the new menu to add.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 See the documentation of `current-menubar' for the syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 BEFORE, if provided, is the name of a menu before which this menu should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 be added, if this menu is not on its parent already. If the menu is already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 present, it will not be moved."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (add-menu menu-path (car submenu) (cdr submenu) before))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (sysdep-defun add-menu-button (menu-path menu-leaf &optional before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "Add a menu item to some menu, creating the menu first if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 If the named item exists already, it is changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 MENU-PATH identifies the menu under which the new menu item should be inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 It is a list of strings; for example, (\"File\") names the top-level \"File\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 MENU-LEAF is a menubar leaf node. See the documentation of `current-menubar'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 BEFORE, if provided, is the name of a menu item before which this item should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 be added, if this item is not on the menu already. If the item is already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 present, it will not be moved."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (add-menu-item menu-path (aref menu-leaf 0) (aref menu-leaf 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (aref menu-leaf 2) before))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (sysdep-defun make-glyph (&optional spec-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (if (and spec-list (cdr-safe (assq 'x spec-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (make-pixmap (cdr-safe (assq 'x spec-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (sysdep-defalias 'face-list 'list-faces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (sysdep-defun set-face-property (face property value &optional locale
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 tag-set how-to-add)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "Change a property of FACE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (and (symbolp face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (put face property value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (sysdep-defun face-property (face property &optional locale tag-set exact-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "Return FACE's value of the given PROPERTY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (and (symbolp face) (get face property)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; Device functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;; By wmperry@spry.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; This is a complete implementation of all the device-* functions found in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; XEmacs 19.14. A 'device' for Emacs 19 is just a frame, from which we can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;; determine the connection to an X display, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (sysdep-defalias 'selected-device 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (sysdep-defalias 'device-or-frame-p 'framep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (sysdep-defalias 'device-console 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (sysdep-defalias 'device-sound-enabled-p 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (sysdep-defalias 'device-live-p 'frame-live-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (sysdep-defalias 'devicep 'framep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (sysdep-defalias 'frame-device 'identity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (sysdep-defalias 'redisplay-device 'redraw-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (sysdep-defalias 'redraw-device 'redraw-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (sysdep-defalias 'select-device 'select-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (sysdep-defalias 'set-device-class 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (sysdep-defun make-device (type connection &optional props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "Create a new device of type TYPE, attached to connection CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 The valid values for CONNECTION are device-specific; however,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 CONNECTION is generally a string. (Specifically, for X devices,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 CONNECTION should be a display specification such as \"foo:0\", and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 for TTY devices, CONNECTION should be the filename of a TTY device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 file, such as \"/dev/ttyp4\", or nil to refer to XEmacs' standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 input/output.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 PROPS, if specified, should be a plist of properties controlling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 device creation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 If CONNECTION specifies an already-existing device connection, that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 device is simply returned; no new device is created, and PROPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 have no effect."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ((and (eq type 'x) connection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (make-frame-on-display display props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ((eq type 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (make-frame props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ((eq type 'tty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (error "Unsupported device-type: %s" type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (sysdep-defun make-frame-on-device (type connection &optional props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 "Create a frame of type TYPE on CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 TYPE should be a symbol naming the device type, i.e. one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 x An X display. CONNECTION should be a standard display string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 such as \"unix:0\", or nil for the display specified on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 command line or in the DISPLAY environment variable. Only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 support for X was compiled into XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 tty A standard TTY connection or terminal. CONNECTION should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 a TTY device name such as \"/dev/ttyp2\" (as determined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 the Unix command `tty') or nil for XEmacs' standard input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 and output (usually the TTY in which XEmacs started). Only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 if support for TTY's was compiled into XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ns A connection to a machine running the NeXTstep windowing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 system. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 win32 A connection to a machine running Microsoft Windows NT or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 Windows 95. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 pc A direct-write MS-DOS frame. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 PROPS should be an plist of properties, as in the call to `make-frame'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 If a connection to CONNECTION already exists, it is reused; otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 a new connection is opened."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (make-device type connection props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (sysdep-defun make-tty-device (&optional tty terminal-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 "Create a new device on TTY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 TTY should be the name of a tty device file (e.g. \"/dev/ttyp3\" under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 SunOS et al.), as returned by the `tty' command. A value of nil means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 use the stdin and stdout as passed to XEmacs from the shell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 If TERMINAL-TYPE is non-nil, it should be a string specifying the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 type of the terminal attached to the specified tty. If it is nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 the terminal type will be inferred from the TERM environment variable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (make-device 'tty tty (list 'terminal-type terminal-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (sysdep-defun make-x-device (&optional display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (make-device 'x display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (sysdep-defun set-device-selected-frame (device frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 "Set the selected frame of device object DEVICE to FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 If DEVICE is nil, the selected device is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 If DEVICE is the selected device, this makes FRAME the selected frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (select-frame frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (sysdep-defun set-device-baud-rate (device rate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 "Set the output baud rate of DEVICE to RATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 On most systems, changing this value will affect the amount of padding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 and other strategic decisions made during redisplay."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (setq baud-rate rate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (sysdep-defun dfw-device (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 "Given a device, frame, or window, return the associated device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 Return nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ((windowp obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (window-frame obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ((framep obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (sysdep-defun event-device (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "Return the device that EVENT occurred on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 This will be nil for some types of events (e.g. keyboard and eval events)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (dfw-device (posn-window (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (sysdep-defun find-device (connection &optional type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 "Look for an existing device attached to connection CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 Return the device if found; otherwise, return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 If TYPE is specified, only return devices of that type; otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 return devices of any type. (It is possible, although unlikely,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 that two devices of different types could have the same connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 name; in such a case, the first device found is returned.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (let ((devices (device-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (retval nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (while (and devices (not nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if (equal connection (device-connection (car devices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (setq retval (car devices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (setq devices (cdr devices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (sysdep-defalias 'get-device 'find-device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (sysdep-defun device-baud-rate (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 "Return the output baud rate of DEVICE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 baud-rate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (sysdep-defun device-on-window-system-p (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 "Return non-nil if DEVICE is on a window system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 This generally means that there is support for the mouse, the menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 the toolbar, glyphs, etc."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (and (cdr-safe (assq 'display (frame-parameters device))) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (sysdep-defun device-name (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 "Return the name of the specified device."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; doesn't handle the 19.29 multiple X display stuff yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;; doesn't handle NeXTStep either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ((null window-system) "stdio")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ((getenv "DISPLAY")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (let ((str (getenv "DISPLAY"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (x (1- (length (getenv "DISPLAY"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (y 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (while (/= y x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if (or (= (aref str y) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (= (aref str y) ?.))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (aset str y ?-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (setq y (1+ y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (t "stdio")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (sysdep-defun device-connection (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "Return the connection of the specified device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 DEVICE defaults to the selected device if omitted"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (or (cdr-safe (assq 'display (frame-parameters device))) "stdio"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (sysdep-defun device-frame-list (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 "Return a list of all frames on DEVICE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 If DEVICE is nil, the selected device will be used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (let ((desired (device-connection device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (filtered-frame-list (function (lambda (x) (equal (device-connection x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 desired))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (sysdep-defun device-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 "Return a list of all devices"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (let ((seen nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (cur nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (conn nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (retval nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (not-heard (frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (while not-heard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (setq cur (car not-heard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 conn (device-connection cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 not-heard (cdr not-heard))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (if (member conn seen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 nil ; Already got it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (setq seen (cons conn seen) ; Whoo hoo, a new one!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 retval (cons cur retval))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (sysdep-defvar delete-device-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 "Function or functions to call when a device is deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 One argument, the to-be-deleted device.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (sysdep-defun delete-device (device &optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 "Delete DEVICE, permanently eliminating it from use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 Normally, you cannot delete the last non-minibuffer-only frame (you must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 second argument FORCE is non-nil, you can delete the last frame. (This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 will automatically call `save-buffers-kill-emacs'.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (let ((frames (device-frame-list device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (run-hook-with-args 'delete-device-hook device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (while frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (delete-frame (car frames) force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (setq frames (cdr frames)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (sysdep-defalias 'device-color-cells
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ((null window-system) 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ((fboundp 'display-color-cells) 'display-color-cells)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ((fboundp 'x-display-color-cells) 'x-display-color-cells)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ((fboundp 'ns-display-color-cells) 'ns-display-color-celles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (sysdep-defun try-font-name (fontname &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (car-safe (x-list-fonts fontname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (sysdep-defalias 'device-pixel-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ((and (eq window-system 'x) (fboundp 'x-display-pixel-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 'x-display-pixel-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ((and (eq window-system 'ns) (fboundp 'ns-display-pixel-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 'ns-display-pixel-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (sysdep-defalias 'device-pixel-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ((and (eq window-system 'x) (fboundp 'x-display-pixel-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 'x-display-pixel-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ((and (eq window-system 'ns) (fboundp 'ns-display-pixel-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 'ns-display-pixel-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (sysdep-defalias 'device-mm-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ((and (eq window-system 'x) (fboundp 'x-display-mm-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 'x-display-mm-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ((and (eq window-system 'ns) (fboundp 'ns-display-mm-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 'ns-display-mm-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (sysdep-defalias 'device-mm-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ((and (eq window-system 'x) (fboundp 'x-display-mm-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 'x-display-mm-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ((and (eq window-system 'ns) (fboundp 'ns-display-mm-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 'ns-display-mm-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (sysdep-defalias 'device-bitplanes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 ((and (eq window-system 'x) (fboundp 'x-display-planes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 'x-display-planes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ((and (eq window-system 'ns) (fboundp 'ns-display-planes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 'ns-display-planes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (sysdep-defalias 'device-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ((and (eq window-system 'x) (fboundp 'x-display-visual-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (lambda (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (let ((val (symbol-name (x-display-visual-class device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ((string-match "color" val) 'color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ((string-match "gray-scale" val) 'grayscale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (t 'mono))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ((fboundp 'number-of-colors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (lambda (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (if (= 2 (number-of-colors))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 'mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 'color))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ((and (eq window-system 'x) (fboundp 'x-color-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (lambda (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (if (x-color-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 'color
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 'mono))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ((and (eq window-system 'ns) (fboundp 'ns-display-visual-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (lambda (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (let ((val (symbol-name (ns-display-visual-class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ((string-match "color" val) 'color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ((string-match "gray-scale" val) 'grayscale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (t 'mono))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (t (function (lambda (&optional device) 'mono)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (sysdep-defun device-class-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 "Returns a list of valid device classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (list 'color 'grayscale 'mono))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (sysdep-defun valid-device-class-p (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 "Given a CLASS, return t if it is valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 Valid classes are 'color, 'grayscale, and 'mono."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (memq class (device-class-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (sysdep-defun device-or-frame-type (device-or-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 "Return the type (e.g. `x' or `tty') of DEVICE-OR-FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 DEVICE-OR-FRAME should be a device or a frame object. See `device-type'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 for a description of the possible types."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (if (cdr-safe (assq 'display (frame-parameters device-or-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 'tty))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (sysdep-defun device-type (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 "Return the type of the specified device (e.g. `x' or `tty').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 Value is `tty' for a tty device (a character-only terminal),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 `x' for a device which is a connection to an X server,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 'ns' for a device which is a connection to a NeXTStep dps server,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 'win32' for a Windows-NT window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 'pm' for an OS/2 Presentation Manager window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 'intuition' for an Amiga screen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (device-or-frame-type device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (sysdep-defun device-type-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 "Return a list of valid console types."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (if window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (list window-system 'tty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (list 'tty)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (sysdep-defun valid-device-type-p (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 "Given a TYPE, return t if it is valid."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (memq type (device-type-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; Extent stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (sysdep-fset 'delete-extent 'delete-overlay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (sysdep-fset 'extent-end-position 'overlay-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (sysdep-fset 'extent-start-position 'overlay-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (sysdep-fset 'set-extent-endpoints 'move-overlay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (sysdep-defun extent-property (extent property &optional default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (or (overlay-get extent property) default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (sysdep-defun extent-at (pos &optional object property before at-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (let ((tmp (overlays-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ovls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (if property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (while tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (if (extent-property (car tmp) property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (setq ovls (cons (car tmp) ovls)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (setq tmp (cdr tmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (setq ovls tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 tmp nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (car-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (sort ovls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (lambda (a b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (< (- (extent-end-position a) (extent-start-position a))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (- (extent-end-position b) (extent-start-position b)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (sysdep-defun overlays-in (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 "Return a list of the overlays that overlap the region BEG ... END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 Overlap means that at least one character is contained within the overlay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 and also contained within the specified region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 Empty overlays are included in the result if they are located at BEG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 or between BEG and END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (let ((ovls (overlay-lists))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 tmp retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (if (< end beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (setq tmp end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 end beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 beg tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (setq ovls (nconc (car ovls) (cdr ovls)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (while ovls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (setq tmp (car ovls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ovls (cdr ovls))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (if (or (and (<= (overlay-start tmp) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (>= (overlay-start tmp) beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (and (<= (overlay-end tmp) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (>= (overlay-end tmp) beg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (setq retval (cons tmp retval))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (sysdep-defun map-extents (function &optional object from to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 maparg flags property value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (let ((tmp (overlays-in (or from (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (or to (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ovls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (if property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (while tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (if (extent-property (car tmp) property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (setq ovls (cons (car tmp) ovls)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (setq tmp (cdr tmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (setq ovls tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 tmp nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (while ovls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (setq tmp (funcall function (car ovls) maparg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ovls (cdr ovls))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (if tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (throw 'done tmp))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; misc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (sysdep-defun symbol-value-in-buffer (symbol buffer &optional unbound-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 "Return the value of SYMBOL in BUFFER, or UNBOUND-VALUE if it is unbound."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (if (not (boundp symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 unbound-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (symbol-value symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (sysdep-defun insert-file-contents-literally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (file &optional visit beg end replace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 "Like `insert-file-contents', q.v., but only reads in the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 A buffer may be modified in several ways after reading into the buffer due
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 to advanced Emacs features, such as file-name-handlers, format decoding,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 find-file-hooks, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 This function ensures that none of these modifications will take place."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (let ((file-name-handler-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (find-file-hooks nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (insert-file-contents file visit beg end replace)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (sysdep-defun alist-to-plist (alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 "Convert association list ALIST into the equivalent property-list form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 The plist is returned. This converts from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 \((a . 1) (b . 2) (c . 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 \(a 1 b 2 c 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 The original alist is not modified. See also `destructive-alist-to-plist'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (let (plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (let ((el (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (setq plist (cons (cdr el) (cons (car el) plist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (setq alist (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (nreverse plist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (sysdep-defun add-minor-mode (toggle name &optional keymap after toggle-fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 TOGGLE is a symbol which is used as the variable which toggle the minor mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 NAME is the name that should appear in the modeline (it should be a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 beginning with a space), KEYMAP is a keymap to make active when the minor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 mode is active, and AFTER is the toggling symbol used for another minor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 mode. If AFTER is non-nil, then it is used to position the new mode in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 minor-mode alists. TOGGLE-FUN specifies an interactive function that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 is called to toggle the mode on and off; this affects what appens when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 button2 is pressed on the mode, and when button3 is pressed somewhere
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 in the list of modes. If TOGGLE-FUN is nil and TOGGLE names an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 interactive function, TOGGLE is used as the toggle function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (if (not (assq toggle minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (setq minor-mode-alist (cons (list toggle name) minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (if (and keymap (not (assq toggle minor-mode-map-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (setq minor-mode-map-alist (cons (cons toggle keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 minor-mode-map-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (sysdep-defvar x-font-regexp-foundry-and-family
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (let ((- "[-?]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (foundry "[^-]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (family "[^-]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (concat "\\`[-?*]" foundry - "\\(" family "\\)" -)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (sysdep-defun match-string (num &optional string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 "Return string of text matched by last search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 NUM specifies which parenthesized expression in the last regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 Zero means the entire text matched by the whole regexp or whole string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 STRING should be given if the last search was by `string-match' on STRING."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (if (match-beginning num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (if string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (substring string (match-beginning num) (match-end num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (buffer-substring (match-beginning num) (match-end num)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (sysdep-defun add-hook (hook-var function &optional at-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 "Add a function to a hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 First argument HOOK-VAR (a symbol) is the name of a hook, second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 argument FUNCTION is the function to add.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 Third (optional) argument AT-END means to add the function at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 of the hook list instead of the beginning. If the function is already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 present, this has no effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 Returns nil if FUNCTION was already present in HOOK-VAR, else new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 value of HOOK-VAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (if (not (boundp hook-var)) (set hook-var nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (let ((old (symbol-value hook-var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if (or (not (listp old)) (eq (car old) 'lambda))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (setq old (list old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (if (member function old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (set hook-var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (if at-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (append old (list function)) ; don't nconc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (cons function old))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (sysdep-defalias 'valid-color-name-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ((fboundp 'x-valid-color-name-p) ; XEmacs/Lucid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 'x-valid-color-name-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ((and window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (fboundp 'color-defined-p)) ; NS/Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 'color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 ((and window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (fboundp 'x-color-defined-p)) ; Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 'x-color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 ((fboundp 'get-color) ; Epoch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (function (lambda (color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (let ((x (get-color color)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (if x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (setq x (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (free-color x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (t 'identity))) ; All others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ;; Misc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (sysdep-defun split-string (string pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 "Return a list of substrings of STRING which are separated by PATTERN."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (let (parts (start 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (while (string-match pattern string start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (setq parts (cons (substring string start (match-beginning 0)) parts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 start (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (nreverse (cons (substring string start) parts))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (sysdep-defun member (elt list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (while (and list (not (equal elt (car list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (sysdep-defun rassoc (key list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (let ((found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (while (and list (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (if (equal (cdr (car list)) key) (setq found (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (sysdep-defun display-error (error-object stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 "Display `error-object' on `stream' in a user-friendly way."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (funcall (or (let ((type (car-safe error-object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (catch 'error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (and (consp error-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (symbolp type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ;;(stringp (get type 'error-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (consp (get type 'error-conditions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (let ((tail (cdr error-object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (while (not (null tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (if (consp tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (setq tail (cdr tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (throw 'error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ;; (check-type condition condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (get type 'error-conditions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;; Search class hierarchy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (let ((tail (get type 'error-conditions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (while (not (null tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (cond ((not (and (consp tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (symbolp (car tail))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (throw 'error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ((get (car tail) 'display-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (throw 'error (get (car tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 'display-error)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (setq tail (cdr tail)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; Default method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (lambda (error-object stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (let ((type (car error-object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (tail (cdr error-object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (first t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (if (eq type 'error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (progn (princ (car tail) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (setq tail (cdr tail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (princ (or (get type 'error-message) type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (while tail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (princ (if first ": " ", ") stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (prin1 (car tail) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (setq tail (cdr tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 first nil)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (lambda (error-object stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (princ "Peculiar error " stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (prin1 error-object stream))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 error-object stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (sysdep-defun find-face (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (car-safe (memq face (face-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 ;; window functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 ;; not defined in v18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (sysdep-defun eval-buffer (bufname &optional printflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (set-buffer bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (eval-current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (sysdep-defun window-minibuffer-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 "Returns non-nil if WINDOW is a minibuffer window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (eq window (minibuffer-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 ;; not defined in v18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (sysdep-defun window-live-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 "Returns t if OBJ is a window which is currently visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (and (windowp window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (window-point window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; this parenthesis closes the if statement at the top of the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 ;; DO NOT put a provide statement here. This file should never be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;; loaded with `require'. Use `load-library' instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 ;;; sysdep.el ends here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 ;;;(sysdep.el) Local Variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;;;(sysdep.el) eval: (put 'sysdep-defun 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 ;;;(sysdep.el) eval: (put 'sysdep-defalias 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ;;;(sysdep.el) eval: (put 'sysdep-defconst 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ;;;(sysdep.el) eval: (put 'sysdep-defvar 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;;;(sysdep.el) End: