annotate lisp/w3/w3-sysdp.el @ 82:6a378aca36af r20-0b91

Import from CVS: tag r20-0b91
author cvs
date Mon, 13 Aug 2007 09:07:36 +0200
parents 1ce6082ce73f
children 360340f9fd5f
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
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
3 ;; Copyright (c) 1995 - 1997 Ben Wing.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
5 ;; Author: Ben Wing <wing@666.com>, William Perry <wmperry@cs.indiana.edu>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: lisp, tools
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
7 ;; Version: 0.003
0
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 ;; 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
54 ;; so that string comparisons to other versions work properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
56 (defconst sysdep-potential-version "0.003")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; this macro means: define the function, but only if either it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; wasn't bound before, or the supplied binding comes from an older
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; version of sysdep.el. That way, user-supplied bindings don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; get overridden.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; note: sysdep-defalias is often more useful than this function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; esp. since you can do load-time conditionalizing and can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; optionally leave the function undefined. (e.g. frame functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; in v18.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defmacro sysdep-defun (function &rest everything-else)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
69 (` (cond ((and (not (fboundp (quote (, function))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
70 (or
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
71 (not
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
72 (stringp (get (quote (, function)) 'sysdep-defined-this)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
73 (and (get (quote (, function)) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
74 (string-lessp
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
75 (get (quote (, function)) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
76 sysdep-potential-version))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
77 (put (quote (, function)) 'sysdep-defined-this
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
78 sysdep-potential-version)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun (, function) (,@ everything-else))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defmacro sysdep-defvar (function &rest everything-else)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
82 (` (cond ((and (not (boundp (quote (, function))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
83 (or
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
84 (not
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
85 (stringp (get (quote (, function)) 'sysdep-defined-this)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
86 (and (get (quote (, function)) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
87 (string-lessp
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
88 (get (quote (, function)) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
89 sysdep-potential-version))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (put (quote (, function)) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defvar (, function) (,@ everything-else))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defmacro sysdep-defconst (function &rest everything-else)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
94 (` (cond ((and (not (boundp (quote (, function))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
95 (or
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
96 (not
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
97 (stringp (get (quote (, function)) 'sysdep-defined-this)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
98 (and (get (quote (, function)) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
99 (string-lessp
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
100 (get (quote (, function)) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
101 sysdep-potential-version))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (put (quote (, function)) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defconst (, function) (,@ everything-else))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; similar for fset and defalias. No need to quote as the argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; is already quoted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defmacro sysdep-fset (function def)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
109 (` (cond ((and (not (fboundp (, function)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
110 (or (not (stringp
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
111 (get (, function) 'sysdep-defined-this)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
112 (and (get (, function) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
113 (string-lessp
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
114 (get (, function) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
115 sysdep-potential-version)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (, def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (put (, function) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (fset (, function) (, def))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defmacro sysdep-defalias (function def)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
121 (` (cond ((and (not (fboundp (, function)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
122 (or (not (stringp
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
123 (get (, function) 'sysdep-defined-this)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
124 (and (get (, function) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
125 (string-lessp
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
126 (get (, function) 'sysdep-defined-this)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
127 sysdep-potential-version)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (, def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (or (listp (, def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (and (symbolp (, def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (fboundp (, def)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (put (, function) 'sysdep-defined-this t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defalias (, function) (, def))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; bootstrapping: defalias and define-function don't exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; in older versions of lemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (sysdep-fset 'defalias 'fset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (sysdep-defalias 'define-function 'defalias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; useful ways of determining what version is running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; emacs-major-version and emacs-minor-version are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; already defined in recent versions of FSF Emacs and XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (sysdep-defconst emacs-major-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; will string-match ever fail? If so, assume 19.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; (should we assume 18.something?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if (string-match "^[0-9]+" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (substring emacs-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (sysdep-defconst emacs-minor-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (substring emacs-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (sysdep-defconst sysdep-running-xemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (or (string-match "Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (string-match "XEmacs" emacs-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (sysdep-defconst window-system nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (sysdep-defconst window-system-version 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (sysdep-defvar list-buffers-directory nil)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
169 (sysdep-defvar x-library-search-path (`
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
170 ("/usr/X11R6/lib/X11/"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "/usr/X11R5/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 "/usr/lib/X11R6/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "/usr/lib/X11R5/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "/usr/local/X11R6/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 "/usr/local/X11R5/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "/usr/local/lib/X11R6/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 "/usr/local/lib/X11R5/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "/usr/X11/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "/usr/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "/usr/local/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "/usr/X386/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 "/usr/x386/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 "/usr/XFree86/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 "/usr/unsupported/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 "/usr/athena/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 "/usr/local/x11r5/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 "/usr/lpp/Xamples/lib/X11/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "/usr/openwin/lib/X11/"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
189 "/usr/openwin/share/lib/X11/"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
190 (, data-directory)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
191 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
192 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 "Search path used for X11 libraries.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; frame-related stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (sysdep-defalias 'buffer-dedicated-frame 'buffer-dedicated-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (sysdep-defalias 'deiconify-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (cond ((fboundp 'deiconify-screen) 'deiconify-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; make-frame-visible will be defined as necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (t 'make-frame-visible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (sysdep-defalias 'delete-frame 'delete-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (sysdep-defalias 'event-frame 'event-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (sysdep-defalias 'event-glyph-extent 'event-glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (sysdep-defalias 'find-file-other-frame 'find-file-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (sysdep-defalias 'find-file-read-only-other-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 'find-file-read-only-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (sysdep-defalias 'frame-height 'screen-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (sysdep-defalias 'frame-iconified-p 'screen-iconified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (sysdep-defalias 'frame-left-margin-width 'screen-left-margin-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (sysdep-defalias 'frame-list 'screen-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (sysdep-defalias 'frame-live-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (cond ((fboundp 'screen-live-p) 'screen-live-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ((fboundp 'live-screen-p) 'live-screen-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;; #### not sure if this is correct (this is for Epoch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;; but gnuserv.el uses it this way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ((fboundp 'screenp) 'screenp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (sysdep-defalias 'frame-name 'screen-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (sysdep-defalias 'frame-parameters 'screen-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (sysdep-defalias 'frame-pixel-height 'screen-pixel-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (sysdep-defalias 'frame-pixel-width 'screen-pixel-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (sysdep-defalias 'frame-right-margin-width 'screen-right-margin-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (sysdep-defalias 'frame-root-window 'screen-root-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (sysdep-defalias 'frame-selected-window 'screen-selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (sysdep-defalias 'frame-totally-visible-p 'screen-totally-visible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (sysdep-defalias 'frame-visible-p 'screen-visible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (sysdep-defalias 'frame-width 'screen-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (sysdep-defalias 'framep 'screenp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (sysdep-defalias 'get-frame-for-buffer 'get-screen-for-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (sysdep-defalias 'get-frame-for-buffer-noselect 'get-screen-for-buffer-noselect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (sysdep-defalias 'get-other-frame 'get-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (sysdep-defalias 'iconify-frame 'iconify-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (sysdep-defalias 'lower-frame 'lower-screen)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
234 (sysdep-defalias 'mail-other-frame 'mail-other-screen)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (sysdep-defalias 'make-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (cond ((fboundp 'make-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (function (lambda (&optional parameters device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (make-screen parameters))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ((fboundp 'x-create-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (function (lambda (&optional parameters device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (x-create-screen parameters))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (sysdep-defalias 'make-frame-invisible 'make-screen-invisible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (sysdep-defalias 'make-frame-visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (cond ((fboundp 'make-screen-visible) 'make-screen-visible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ((fboundp 'mapraised-screen) 'mapraised-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ((fboundp 'x-remap-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (lambda (&optional x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (x-remap-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (accept-process-output)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (sysdep-defalias 'modify-frame-parameters 'modify-screen-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (sysdep-defalias 'new-frame 'new-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (sysdep-defalias 'next-frame 'next-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (sysdep-defalias 'next-multiframe-window 'next-multiscreen-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (sysdep-defalias 'other-frame 'other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (sysdep-defalias 'previous-frame 'previous-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (sysdep-defalias 'previous-multiframe-window 'previous-multiscreen-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (sysdep-defalias 'raise-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (cond ((fboundp 'raise-screen) 'raise-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ((fboundp 'mapraise-screen) 'mapraise-screen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (sysdep-defalias 'redraw-frame 'redraw-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (sysdep-defalias 'select-frame 'select-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (sysdep-defalias 'selected-frame 'selected-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (sysdep-defalias 'set-buffer-dedicated-frame 'set-buffer-dedicated-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (sysdep-defalias 'set-frame-height 'set-screen-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (sysdep-defalias 'set-frame-left-margin-width 'set-screen-left-margin-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (sysdep-defalias 'set-frame-position 'set-screen-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (sysdep-defalias 'set-frame-right-margin-width 'set-screen-right-margin-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (sysdep-defalias 'set-frame-size 'set-screen-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (sysdep-defalias 'set-frame-width 'set-screen-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (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
273 (sysdep-defalias 'switch-to-buffer-other-frame 'switch-to-buffer-other-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (sysdep-defalias 'visible-frame-list 'visible-screen-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (sysdep-defalias 'window-frame 'window-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (sysdep-defalias 'x-create-frame 'x-create-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (sysdep-defalias 'x-set-frame-icon-pixmap 'x-set-screen-icon-pixmap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (sysdep-defalias 'x-set-frame-pointer 'x-set-screen-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (sysdep-defalias 'x-display-color-p 'x-color-display-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (sysdep-defalias 'x-display-grayscale-p 'x-grayscale-display-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (sysdep-defalias 'menu-event-p 'misc-user-event-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
283 ;; WMP - commention these out so that Emacs 19 doesn't get screwed by them.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
284 ;; In particular, this makes the 'custom' package blow up quite well.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
285 ;;(sysdep-defun add-submenu (menu-path submenu &optional before)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
286 ;; "Add a menu to the menubar or one of its submenus.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
287 ;;If the named menu exists already, it is changed.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
288 ;;MENU-PATH identifies the menu under which the new menu should be inserted.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
289 ;; It is a list of strings; for example, (\"File\") names the top-level \"File\"
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
290 ;; menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\".
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
291 ;; If MENU-PATH is nil, then the menu will be added to the menubar itself.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
292 ;;SUBMENU is the new menu to add.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
293 ;; See the documentation of `current-menubar' for the syntax.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
294 ;;BEFORE, if provided, is the name of a menu before which this menu should
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
295 ;; be added, if this menu is not on its parent already. If the menu is already
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
296 ;; present, it will not be moved."
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
297 ;; (add-menu menu-path (car submenu) (cdr submenu) before))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
299 ;;(sysdep-defun add-menu-button (menu-path menu-leaf &optional before)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
300 ;; "Add a menu item to some menu, creating the menu first if necessary.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
301 ;;If the named item exists already, it is changed.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
302 ;;MENU-PATH identifies the menu under which the new menu item should be inserted.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
303 ;; It is a list of strings; for example, (\"File\") names the top-level \"File\"
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
304 ;; menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\".
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
305 ;;MENU-LEAF is a menubar leaf node. See the documentation of `current-menubar'.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
306 ;;BEFORE, if provided, is the name of a menu item before which this item should
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
307 ;; be added, if this item is not on the menu already. If the item is already
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
308 ;; present, it will not be moved."
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
309 ;; (add-menu-item menu-path (aref menu-leaf 0) (aref menu-leaf 1)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
310 ;; (aref menu-leaf 2) before))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (sysdep-defun make-glyph (&optional spec-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (if (and spec-list (cdr-safe (assq 'x spec-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (make-pixmap (cdr-safe (assq 'x spec-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (sysdep-defalias 'face-list 'list-faces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
318 (sysdep-defun set-keymap-parent (keymap new-parent)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
319 (let ((tail keymap))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
320 (while (and tail (cdr tail) (not (eq (car (cdr tail)) 'keymap)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
321 (setq tail (cdr tail)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
322 (if tail
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
323 (setcdr tail new-parent))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
324
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
325 (sysdep-defun facep (face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
326 "Return t if X is a face name or an internal face vector."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
327 ;; CAUTION!!! This is Emacs 19.x, for x <= 28, specific
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
328 ;; I know of no version of Lucid Emacs or XEmacs that did not have
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
329 ;; facep. Even if they did, they are unsupported, so big deal.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
330 (if (not window-system)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
331 nil ; FIXME if FSF ever does TTY faces
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
332 (and (or (internal-facep face)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
333 (and (symbolp face) (assq face global-face-data)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
334 t)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
335
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (sysdep-defun set-face-property (face property value &optional locale
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 tag-set how-to-add)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "Change a property of FACE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (and (symbolp face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (put face property value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (sysdep-defun face-property (face property &optional locale tag-set exact-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 "Return FACE's value of the given PROPERTY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (and (symbolp face) (get face property)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
346 ;;; Additional text property functions.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
347
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
348 ;; The following three text property functions are not generally available (and
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
349 ;; it's not certain that they should be) so they are inlined for speed.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
350 ;; The case for `fillin-text-property' is simple; it may or not be generally
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
351 ;; useful. (Since it is used here, it is useful in at least one place.;-)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
352 ;; However, the case for `append-text-property' and `prepend-text-property' is
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
353 ;; more complicated. Should they remove duplicate property values or not? If
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
354 ;; so, should the first or last duplicate item remain? Or the one that was
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
355 ;; added? In our implementation, the first duplicate remains.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
356
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
357 (sysdep-defun fillin-text-property (start end setprop markprop value &optional object)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
358 "Fill in one property of the text from START to END.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
359 Arguments PROP and VALUE specify the property and value to put where none are
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
360 already in place. Therefore existing property values are not overwritten.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
361 Optional argument OBJECT is the string or buffer containing the text."
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
362 (let ((start (text-property-any start end markprop nil object)) next)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
363 (while start
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
364 (setq next (next-single-property-change start markprop object end))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
365 (put-text-property start next setprop value object)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
366 (put-text-property start next markprop value object)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
367 (setq start (text-property-any next end markprop nil object)))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
368
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
369 ;; This function (from simon's unique.el) is rewritten and inlined for speed.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
370 ;(defun unique (list function)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
371 ; "Uniquify LIST, deleting elements using FUNCTION.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
372 ;Return the list with subsequent duplicate items removed by side effects.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
373 ;FUNCTION is called with an element of LIST and a list of elements from LIST,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
374 ;and should return the list of elements with occurrences of the element removed,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
375 ;i.e., a function such as `delete' or `delq'.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
376 ;This function will work even if LIST is unsorted. See also `uniq'."
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
377 ; (let ((list list))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
378 ; (while list
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
379 ; (setq list (setcdr list (funcall function (car list) (cdr list))))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
380 ; list)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
381
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
382 (sysdep-defun unique (list)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
383 "Uniquify LIST, deleting elements using `delq'.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
384 Return the list with subsequent duplicate items removed by side effects."
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
385 (let ((list list))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
386 (while list
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
387 (setq list (setcdr list (delq (car list) (cdr list))))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
388 list)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
389
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
390 ;; A generalisation of `facemenu-add-face' for any property, but without the
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
391 ;; removal of inactive faces via `facemenu-discard-redundant-faces' and special
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
392 ;; treatment of `default'. Uses `unique' to remove duplicate property values.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
393 (sysdep-defun prepend-text-property (start end prop value &optional object)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
394 "Prepend to one property of the text from START to END.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
395 Arguments PROP and VALUE specify the property and value to prepend to the value
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
396 already in place. The resulting property values are always lists, and unique.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
397 Optional argument OBJECT is the string or buffer containing the text."
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
398 (let ((val (if (listp value) value (list value))) next prev)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
399 (while (/= start end)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
400 (setq next (next-single-property-change start prop object end)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
401 prev (get-text-property start prop object))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
402 (put-text-property
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
403 start next prop
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
404 (unique (append val (if (listp prev) prev (list prev))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
405 object)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
406 (setq start next))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
407
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
408 (sysdep-defun append-text-property (start end prop value &optional object)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
409 "Append to one property of the text from START to END.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
410 Arguments PROP and VALUE specify the property and value to append to the value
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
411 already in place. The resulting property values are always lists, and unique.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
412 Optional argument OBJECT is the string or buffer containing the text."
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
413 (let ((val (if (listp value) value (list value))) next prev)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
414 (while (/= start end)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
415 (setq next (next-single-property-change start prop object end)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
416 prev (get-text-property start prop object))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
417 (put-text-property
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
418 start next prop
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
419 (unique (append (if (listp prev) prev (list prev)) val))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
420 object)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
421 (setq start next))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
422
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
423 ;; Property list functions
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
424 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
425 (sysdep-defun plist-put (plist prop val)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
426 "Change value in PLIST of PROP to VAL.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
427 PLIST is a property list, which is a list of the form
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
428 (PROP1 VALUE1 PROP2 VALUE2 ...). PROP is a symbol and VAL is any object.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
429 If PROP is already a property on the list, its value is set to VAL,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
430 otherwise the new PROP VAL pair is added. The new plist is returned;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
431 use `(setq x (plist-put x prop val))' to be sure to use the new value.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
432 The PLIST is modified by side effects."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
433 (let ((node (memq prop plist)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
434 (if node
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
435 (setcar (cdr node) val)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
436 (setq plist (cons prop (cons val plist))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
437 plist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
438
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
439 (sysdep-defun plist-get (plist prop)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
440 "Extract a value from a property list.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
441 PLIST is a property list, which is a list of the form
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
442 (PROP1 VALUE1 PROP2 VALUE2...). This function returns the value
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
443 corresponding to the given PROP, or nil if PROP is not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
444 one of the properties on the list."
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
445 (while (and plist (not (eq (car plist) prop)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
446 (setq plist (cdr (cdr plist))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
447 (and plist (car (cdr plist))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
448
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;; Device functions
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
450 ;; By wmperry@cs.indiana.edu
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; This is a complete implementation of all the device-* functions found in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;; 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
453 ;; determine the connection to an X display, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (sysdep-defalias 'selected-device 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (sysdep-defalias 'device-or-frame-p 'framep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (sysdep-defalias 'device-console 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (sysdep-defalias 'device-sound-enabled-p 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (sysdep-defalias 'device-live-p 'frame-live-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (sysdep-defalias 'devicep 'framep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (sysdep-defalias 'frame-device 'identity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (sysdep-defalias 'redisplay-device 'redraw-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (sysdep-defalias 'redraw-device 'redraw-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (sysdep-defalias 'select-device 'select-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (sysdep-defalias 'set-device-class 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (sysdep-defun make-device (type connection &optional props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 "Create a new device of type TYPE, attached to connection CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 The valid values for CONNECTION are device-specific; however,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 CONNECTION is generally a string. (Specifically, for X devices,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 CONNECTION should be a display specification such as \"foo:0\", and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 for TTY devices, CONNECTION should be the filename of a TTY device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 file, such as \"/dev/ttyp4\", or nil to refer to XEmacs' standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 input/output.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 PROPS, if specified, should be a plist of properties controlling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 device creation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 If CONNECTION specifies an already-existing device connection, that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 device is simply returned; no new device is created, and PROPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 have no effect."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ((and (eq type 'x) connection)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
485 (make-frame-on-display connection props))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ((eq type 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (make-frame props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ((eq type 'tty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (error "Unsupported device-type: %s" type))))
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 make-frame-on-device (type connection &optional props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 "Create a frame of type TYPE on CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 TYPE should be a symbol naming the device type, i.e. one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 x An X display. CONNECTION should be a standard display string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 such as \"unix:0\", or nil for the display specified on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 command line or in the DISPLAY environment variable. Only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 support for X was compiled into XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 tty A standard TTY connection or terminal. CONNECTION should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 a TTY device name such as \"/dev/ttyp2\" (as determined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 the Unix command `tty') or nil for XEmacs' standard input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 and output (usually the TTY in which XEmacs started). Only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 if support for TTY's was compiled into XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ns A connection to a machine running the NeXTstep windowing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 system. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 win32 A connection to a machine running Microsoft Windows NT or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 Windows 95. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 pc A direct-write MS-DOS frame. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
512 PROPS should be an plist of properties, as in the call to `make-frame'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 If a connection to CONNECTION already exists, it is reused; otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 a new connection is opened."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (make-device type connection props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (sysdep-defun make-tty-device (&optional tty terminal-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 "Create a new device on TTY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 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
521 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
522 use the stdin and stdout as passed to XEmacs from the shell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 If TERMINAL-TYPE is non-nil, it should be a string specifying the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 type of the terminal attached to the specified tty. If it is nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 the terminal type will be inferred from the TERM environment variable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (make-device 'tty tty (list 'terminal-type terminal-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (sysdep-defun make-x-device (&optional display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (make-device 'x display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (sysdep-defun set-device-selected-frame (device frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 "Set the selected frame of device object DEVICE to FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 If DEVICE is nil, the selected device is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 If DEVICE is the selected device, this makes FRAME the selected frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (select-frame frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (sysdep-defun set-device-baud-rate (device rate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 "Set the output baud rate of DEVICE to RATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 On most systems, changing this value will affect the amount of padding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 and other strategic decisions made during redisplay."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (setq baud-rate rate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (sysdep-defun dfw-device (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 "Given a device, frame, or window, return the associated device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 Return nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ((windowp obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (window-frame obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ((framep obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (sysdep-defun event-device (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 "Return the device that EVENT occurred on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 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
557 (dfw-device (posn-window (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (sysdep-defun find-device (connection &optional type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 "Look for an existing device attached to connection CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 Return the device if found; otherwise, return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 If TYPE is specified, only return devices of that type; otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 return devices of any type. (It is possible, although unlikely,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 that two devices of different types could have the same connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 name; in such a case, the first device found is returned.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (let ((devices (device-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (retval nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (while (and devices (not nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (if (equal connection (device-connection (car devices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (setq retval (car devices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (setq devices (cdr devices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (sysdep-defalias 'get-device 'find-device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (sysdep-defun device-baud-rate (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 "Return the output baud rate of DEVICE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 baud-rate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (sysdep-defun device-on-window-system-p (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 "Return non-nil if DEVICE is on a window system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 This generally means that there is support for the mouse, the menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 the toolbar, glyphs, etc."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (and (cdr-safe (assq 'display (frame-parameters device))) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (sysdep-defun device-name (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 "Return the name of the specified device."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;; doesn't handle the 19.29 multiple X display stuff yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; doesn't handle NeXTStep either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ((null window-system) "stdio")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ((getenv "DISPLAY")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (let ((str (getenv "DISPLAY"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (x (1- (length (getenv "DISPLAY"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (y 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (while (/= y x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (if (or (= (aref str y) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (= (aref str y) ?.))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (aset str y ?-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (setq y (1+ y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (t "stdio")))
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-connection (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 "Return the connection of the specified device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 DEVICE defaults to the selected device if omitted"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (or (cdr-safe (assq 'display (frame-parameters device))) "stdio"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (sysdep-defun device-frame-list (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 "Return a list of all frames on DEVICE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 If DEVICE is nil, the selected device will be used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (let ((desired (device-connection device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (filtered-frame-list (function (lambda (x) (equal (device-connection x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 desired))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (sysdep-defun device-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 "Return a list of all devices"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (let ((seen nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (cur nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (conn nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (retval nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (not-heard (frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (while not-heard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (setq cur (car not-heard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 conn (device-connection cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 not-heard (cdr not-heard))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (if (member conn seen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 nil ; Already got it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (setq seen (cons conn seen) ; Whoo hoo, a new one!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 retval (cons cur retval))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (sysdep-defvar delete-device-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "Function or functions to call when a device is deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 One argument, the to-be-deleted device.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (sysdep-defun delete-device (device &optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 "Delete DEVICE, permanently eliminating it from use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 Normally, you cannot delete the last non-minibuffer-only frame (you must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 second argument FORCE is non-nil, you can delete the last frame. (This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 will automatically call `save-buffers-kill-emacs'.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (let ((frames (device-frame-list device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (run-hook-with-args 'delete-device-hook device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (while frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (delete-frame (car frames) force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq frames (cdr frames)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (sysdep-defalias 'device-color-cells
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ((null window-system) 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ((fboundp 'display-color-cells) 'display-color-cells)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ((fboundp 'x-display-color-cells) 'x-display-color-cells)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ((fboundp 'ns-display-color-cells) 'ns-display-color-celles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (sysdep-defun try-font-name (fontname &rest args)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
658 (cond
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
659 ((eq window-system 'x) (car-safe (x-list-fonts fontname)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
660 ((eq window-system 'ns) (car-safe (ns-list-fonts fontname)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
661 (t nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (sysdep-defalias 'device-pixel-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
665 ((and (eq window-system 'x) (fboundp 'x-display-pixel-width))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 'x-display-pixel-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 ((and (eq window-system 'ns) (fboundp 'ns-display-pixel-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 'ns-display-pixel-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (sysdep-defalias 'device-pixel-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
673 ((and (eq window-system 'x) (fboundp 'x-display-pixel-height))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 'x-display-pixel-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ((and (eq window-system 'ns) (fboundp 'ns-display-pixel-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 'ns-display-pixel-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (sysdep-defalias 'device-mm-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
681 ((and (eq window-system 'x) (fboundp 'x-display-mm-width))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 'x-display-mm-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ((and (eq window-system 'ns) (fboundp 'ns-display-mm-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 'ns-display-mm-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (sysdep-defalias 'device-mm-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
689 ((and (eq window-system 'x) (fboundp 'x-display-mm-height))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 'x-display-mm-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ((and (eq window-system 'ns) (fboundp 'ns-display-mm-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 'ns-display-mm-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (sysdep-defalias 'device-bitplanes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
697 ((and (eq window-system 'x) (fboundp 'x-display-planes))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 'x-display-planes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ((and (eq window-system 'ns) (fboundp 'ns-display-planes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 'ns-display-planes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (t 'ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (sysdep-defalias 'device-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (cond
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
705 ;; First, Xwindows
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ((and (eq window-system 'x) (fboundp 'x-display-visual-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (lambda (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (let ((val (symbol-name (x-display-visual-class device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ((string-match "color" val) 'color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ((string-match "gray-scale" val) 'grayscale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (t 'mono))))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
714 ;; Now, Presentation-Manager under OS/2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
715 ((and (eq window-system 'pm) (fboundp 'pm-display-visual-class))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
716 (function
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
717 (lambda (&optional device)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
718 (let ((val (symbol-name (pm-display-visual-class device))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
719 (cond
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
720 ((string-match "color" val) 'color)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
721 ((string-match "gray-scale" val) 'grayscale)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
722 (t 'mono))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
723 ;; A slightly different way of doing it under OS/2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
724 ((and (eq window-system 'pm) (fboundp 'pm-display-color-p))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
725 (function
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
726 (lambda (&optional device)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
727 (if (pm-display-color-p)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
728 'color
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
729 'mono))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 ((fboundp 'number-of-colors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (lambda (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (if (= 2 (number-of-colors))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 'mono
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 'color))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ((and (eq window-system 'x) (fboundp 'x-color-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (lambda (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (if (x-color-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 'color
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 'mono))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ((and (eq window-system 'ns) (fboundp 'ns-display-visual-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (lambda (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (let ((val (symbol-name (ns-display-visual-class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 ((string-match "color" val) 'color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ((string-match "gray-scale" val) 'grayscale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (t 'mono))))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
750 (t (function (lambda (&optional device) 'mono)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (sysdep-defun device-class-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 "Returns a list of valid device classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (list 'color 'grayscale 'mono))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (sysdep-defun valid-device-class-p (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 "Given a CLASS, return t if it is valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 Valid classes are 'color, 'grayscale, and 'mono."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (memq class (device-class-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (sysdep-defun device-or-frame-type (device-or-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 "Return the type (e.g. `x' or `tty') of DEVICE-OR-FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 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
764 for a description of the possible types."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
765 (if (or (cdr-safe (assq 'display (frame-parameters device-or-frame)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
766 (cdr-safe (assq 'window-id (frame-parameters device-or-frame))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 'tty))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (sysdep-defun device-type (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 "Return the type of the specified device (e.g. `x' or `tty').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 Value is `tty' for a tty device (a character-only terminal),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 `x' for a device which is a connection to an X server,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 'ns' for a device which is a connection to a NeXTStep dps server,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 'win32' for a Windows-NT window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 'pm' for an OS/2 Presentation Manager window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 'intuition' for an Amiga screen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (device-or-frame-type device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (sysdep-defun device-type-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 "Return a list of valid console types."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (list window-system 'tty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (list 'tty)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (sysdep-defun valid-device-type-p (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 "Given a TYPE, return t if it is valid."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (memq type (device-type-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 36
diff changeset
790
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; Extent stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (sysdep-fset 'delete-extent 'delete-overlay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (sysdep-fset 'extent-end-position 'overlay-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (sysdep-fset 'extent-start-position 'overlay-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (sysdep-fset 'set-extent-endpoints 'move-overlay)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
796 (sysdep-fset 'set-extent-property 'overlay-put)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
797 (sysdep-fset 'make-extent 'make-overlay)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (sysdep-defun extent-property (extent property &optional default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (or (overlay-get extent property) default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (sysdep-defun extent-at (pos &optional object property before at-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (let ((tmp (overlays-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ovls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (if property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (while tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (if (extent-property (car tmp) property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (setq ovls (cons (car tmp) ovls)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (setq tmp (cdr tmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (setq ovls tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 tmp nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (car-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (sort ovls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (lambda (a b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (< (- (extent-end-position a) (extent-start-position a))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (- (extent-end-position b) (extent-start-position b)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (sysdep-defun overlays-in (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 "Return a list of the overlays that overlap the region BEG ... END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 Overlap means that at least one character is contained within the overlay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 and also contained within the specified region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 Empty overlays are included in the result if they are located at BEG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 or between BEG and END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (let ((ovls (overlay-lists))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 tmp retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (if (< end beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (setq tmp end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 end beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 beg tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (setq ovls (nconc (car ovls) (cdr ovls)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (while ovls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (setq tmp (car ovls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ovls (cdr ovls))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (if (or (and (<= (overlay-start tmp) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (>= (overlay-start tmp) beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (and (<= (overlay-end tmp) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (>= (overlay-end tmp) beg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (setq retval (cons tmp retval))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (sysdep-defun map-extents (function &optional object from to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 maparg flags property value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (let ((tmp (overlays-in (or from (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (or to (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ovls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (if property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (while tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (if (extent-property (car tmp) property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (setq ovls (cons (car tmp) ovls)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (setq tmp (cdr tmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (setq ovls tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 tmp nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (while ovls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (setq tmp (funcall function (car ovls) maparg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ovls (cdr ovls))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (if tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (throw 'done tmp))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; misc
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
862 (sysdep-fset 'make-local-hook 'make-local-variable)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
863
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
864 (sysdep-defun buffer-substring-no-properties (beg end)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
865 "Return the text from BEG to END, without text properties, as a string."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
866 (format "%s" (buffer-substring beg end)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
867
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (sysdep-defun symbol-value-in-buffer (symbol buffer &optional unbound-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 "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
870 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (if (not (boundp symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 unbound-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (symbol-value symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (sysdep-defun insert-file-contents-literally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (file &optional visit beg end replace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 "Like `insert-file-contents', q.v., but only reads in the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 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
880 to advanced Emacs features, such as file-name-handlers, format decoding,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 find-file-hooks, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 This function ensures that none of these modifications will take place."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (let ((file-name-handler-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (find-file-hooks nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (insert-file-contents file visit beg end replace)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (sysdep-defun alist-to-plist (alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 "Convert association list ALIST into the equivalent property-list form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 The plist is returned. This converts from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 \((a . 1) (b . 2) (c . 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 \(a 1 b 2 c 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 The original alist is not modified. See also `destructive-alist-to-plist'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (let (plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (let ((el (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (setq plist (cons (cdr el) (cons (car el) plist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (setq alist (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (nreverse plist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (sysdep-defun add-minor-mode (toggle name &optional keymap after toggle-fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 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
908 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
909 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
910 mode is active, and AFTER is the toggling symbol used for another minor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 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
912 minor-mode alists. TOGGLE-FUN specifies an interactive function that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 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
914 button2 is pressed on the mode, and when button3 is pressed somewhere
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 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
916 interactive function, TOGGLE is used as the toggle function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (if (not (assq toggle minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (setq minor-mode-alist (cons (list toggle name) minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (if (and keymap (not (assq toggle minor-mode-map-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (setq minor-mode-map-alist (cons (cons toggle keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 minor-mode-map-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (sysdep-defvar x-font-regexp-foundry-and-family
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (let ((- "[-?]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (foundry "[^-]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (family "[^-]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (concat "\\`[-?*]" foundry - "\\(" family "\\)" -)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (sysdep-defun match-string (num &optional string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 "Return string of text matched by last search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 NUM specifies which parenthesized expression in the last regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 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
936 Zero means the entire text matched by the whole regexp or whole string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 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
938 (if (match-beginning num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (if string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (substring string (match-beginning num) (match-end num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (buffer-substring (match-beginning num) (match-end num)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (sysdep-defun add-hook (hook-var function &optional at-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 "Add a function to a hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 First argument HOOK-VAR (a symbol) is the name of a hook, second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 argument FUNCTION is the function to add.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 Third (optional) argument AT-END means to add the function at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 of the hook list instead of the beginning. If the function is already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 present, this has no effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 Returns nil if FUNCTION was already present in HOOK-VAR, else new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 value of HOOK-VAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (if (not (boundp hook-var)) (set hook-var nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (let ((old (symbol-value hook-var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (if (or (not (listp old)) (eq (car old) 'lambda))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (setq old (list old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (if (member function old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (set hook-var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (if at-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (append old (list function)) ; don't nconc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (cons function old))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (sysdep-defalias 'valid-color-name-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ((fboundp 'x-valid-color-name-p) ; XEmacs/Lucid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 'x-valid-color-name-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 ((and window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (fboundp 'color-defined-p)) ; NS/Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 'color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ((and window-system
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
971 (fboundp 'pm-color-defined-p))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
972 'pm-color-defined-p)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
973 ((and window-system
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (fboundp 'x-color-defined-p)) ; Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 'x-color-defined-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ((fboundp 'get-color) ; Epoch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (function (lambda (color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (let ((x (get-color color)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (if x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (setq x (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (free-color x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (t 'identity))) ; All others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 ;; Misc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (sysdep-defun split-string (string pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 "Return a list of substrings of STRING which are separated by PATTERN."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (let (parts (start 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (while (string-match pattern string start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (setq parts (cons (substring string start (match-beginning 0)) parts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 start (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (nreverse (cons (substring string start) parts))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (sysdep-defun member (elt list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (while (and list (not (equal elt (car list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (sysdep-defun rassoc (key list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (let ((found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (while (and list (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (if (equal (cdr (car list)) key) (setq found (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (sysdep-defun display-error (error-object stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 "Display `error-object' on `stream' in a user-friendly way."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (funcall (or (let ((type (car-safe error-object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (catch 'error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (and (consp error-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (symbolp type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 ;;(stringp (get type 'error-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (consp (get type 'error-conditions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (let ((tail (cdr error-object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (while (not (null tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (if (consp tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (setq tail (cdr tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (throw 'error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 ;; (check-type condition condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (get type 'error-conditions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 ;; Search class hierarchy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (let ((tail (get type 'error-conditions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (while (not (null tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (cond ((not (and (consp tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (symbolp (car tail))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (throw 'error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ((get (car tail) 'display-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (throw 'error (get (car tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 'display-error)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (setq tail (cdr tail)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;; Default method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (lambda (error-object stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (let ((type (car error-object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (tail (cdr error-object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (first t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (if (eq type 'error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (progn (princ (car tail) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (setq tail (cdr tail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (princ (or (get type 'error-message) type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (while tail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (princ (if first ": " ", ") stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (prin1 (car tail) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (setq tail (cdr tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 first nil)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (lambda (error-object stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (princ "Peculiar error " stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (prin1 error-object stream))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 error-object stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1057 (sysdep-defun decode-time (&optional specified-time)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1058 (let* ((date (current-time-string specified-time))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1059 (dateinfo (and date (timezone-parse-date date)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1060 (timeinfo (and dateinfo (timezone-parse-time (aref dateinfo 3)))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1061 (list (aref timeinfo 2) (aref timeinfo 1)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1062 (aref timeinfo 0) (aref dateinfo 2)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1063 (aref dateinfo 1) (aref dateinfo 0)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1064 "unknown" nil 0)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1065
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (sysdep-defun find-face (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (car-safe (memq face (face-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1069 (sysdep-defun set-marker-insertion-type (marker type)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1070 "Set the insertion-type of MARKER to TYPE.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1071 If TYPE is t, it means the marker advances when you insert text at it.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1072 If TYPE is nil, it means the marker stays behind when you insert text at it."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1073 nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1074
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 ;; window functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 ;; not defined in v18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (sysdep-defun eval-buffer (bufname &optional printflag)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1079 (interactive)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (set-buffer bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (eval-current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (sysdep-defun window-minibuffer-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 "Returns non-nil if WINDOW is a minibuffer window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (eq window (minibuffer-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (sysdep-defun window-live-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 "Returns t if OBJ is a window which is currently visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (and (windowp window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (window-point window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1093 (provide 'w3-sysdp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 ;;; sysdep.el ends here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 ;;;(sysdep.el) Local Variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ;;;(sysdep.el) eval: (put 'sysdep-defun 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;;;(sysdep.el) eval: (put 'sysdep-defalias 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;;;(sysdep.el) eval: (put 'sysdep-defconst 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 ;;;(sysdep.el) eval: (put 'sysdep-defvar 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;;;(sysdep.el) End: