annotate lisp/symbols.el @ 5601:3e5d5e8e4bb7

Move etc/dbxrc.in to src/.dbxrc.in. 2011-11-21 Marcus Crestani <crestani@informatik.uni-tuebingen.de> * .hgignore: * configure.ac: Reflect move of etc/dbxrc.in to src/.dbxrc.in. * configure: Regenerate. 2011-11-21 Marcus Crestani <crestani@informatik.uni-tuebingen.de> * dbxrc.in: Move to src/.dbxrc.in. 2011-11-21 Marcus Crestani <crestani@informatik.uni-tuebingen.de> * .dbxrc.in: Move from etc/.dbxrc.in.
author Marcus Crestani <crestani@informatik.uni-tuebingen.de>
date Mon, 21 Nov 2011 19:46:04 +0100
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1 ;;; symbols.el --- functions for working with symbols and symbol values
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996 Ben Wing.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
4
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
5 ;; Maintainer: XEmacs Development Team
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
6 ;; Keywords: internal
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
7
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
9
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
10 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
11 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
12 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
13 ;; option) any later version.
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
14
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
18 ;; for more details.
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
19
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
21 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
22
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
23 ;;; Synched up with: Not in FSF.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
24
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
25 ;;; Commentary:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
26
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
27 ;; Not yet dumped into XEmacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
28
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
29 ;; The idea behind magic variables is that you can specify arbitrary
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
30 ;; behavior to happen when setting or retrieving a variable's value. The
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
31 ;; purpose of this is to make it possible to cleanly provide support for
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
32 ;; obsolete variables (e.g. unread-command-event, which is obsolete for
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
33 ;; unread-command-events) and variable compatibility
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
34 ;; (e.g. suggest-key-bindings, the FSF equivalent of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
35 ;; teach-extended-commands-p and teach-extended-commands-timeout).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
36
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
37 ;; There are a large number of functions pertaining to a variable's
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
38 ;; value:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
39
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
40 ;; boundp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
41 ;; globally-boundp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
42 ;; makunbound
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
43 ;; symbol-value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
44 ;; set / setq
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
45 ;; default-boundp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
46 ;; default-value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
47 ;; set-default / setq-default
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
48 ;; make-variable-buffer-local
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
49 ;; make-local-variable
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
50 ;; kill-local-variable
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
51 ;; kill-console-local-variable
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
52 ;; symbol-value-in-buffer
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
53 ;; symbol-value-in-console
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
54 ;; local-variable-p / local-variable-if-set-p
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
55
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
56 ;; Plus some "meta-functions":
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
57
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
58 ;; defvaralias
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
59 ;; variable-alias
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
60 ;; indirect-variable
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
61
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
62 ;; I wanted an implementation that:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
63
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
64 ;; -- would work with all the above functions, but (a) didn't require
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
65 ;; a separate handler for every function, and (b) would work OK
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
66 ;; even if more functions are added (e.g. `set-symbol-value-in-buffer'
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
67 ;; or `makunbound-default') or if more arguments are added to a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
68 ;; function.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
69 ;; -- avoided consing if at all possible.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
70 ;; -- didn't slow down operations on non-magic variables (therefore,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
71 ;; storing the magic information using `put' is ruled out).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
72 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
73
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
74 ;;; Code:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
75
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
76 ;; perhaps this should check whether the functions are bound, so that
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
77 ;; some handlers can be unspecified. That requires that all functions
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
78 ;; are defined before `define-magic-variable-handlers' is called,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
79 ;; though.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
80
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
81 ;; perhaps there should be something that combines
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
82 ;; `define-magic-variable-handlers' with `defvaralias'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
83
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 398
diff changeset
84 (globally-declare-fboundp
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 398
diff changeset
85 '(set-magic-variable-handler))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 398
diff changeset
86
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
87 (defun define-magic-variable-handlers (variable handler-class harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
88 "Set the magic variable handles for VARIABLE to those in HANDLER-CLASS.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
89 HANDLER-CLASS should be a symbol. The handlers are constructed by adding
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
90 the handler type to HANDLER-CLASS. HARG is passed as the HARG value for
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
91 each of the handlers."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
92 (mapcar
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
93 #'(lambda (htype)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
94 (set-magic-variable-handler variable htype
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
95 (intern (concat (symbol-value handler-class)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
96 "-"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
97 (symbol-value htype)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
98 harg))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
99 '(get-value set-value other-predicate other-action)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
100
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
101 ;; unread-command-event
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
102
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
103 (defun mvh-first-of-list-get-value (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
104 (car (apply fun harg args)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
105
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
106 (defun mvh-first-of-list-set-value (sym value setfun getfun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
107 (apply setfun harg (cons value (apply getfun harg args)) args))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
108
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
109 (defun mvh-first-of-list-other-predicate (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
110 (apply fun harg args))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
111
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
112 (defun mvh-first-of-list-other-action (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
113 (apply fun harg args))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
114
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
115 (define-magic-variable-handlers 'unread-command-event
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
116 'mvh-first-of-list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
117 'unread-command-events)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
118
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
119 ;; last-command-char, last-input-char, unread-command-char
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
120
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
121 (defun mvh-char-to-event-get-value (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
122 (event-to-character (apply fun harg args)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
123
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
124 (defun mvh-char-to-event-set-value (sym value setfun getfun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
125 (let ((event (apply getfun harg args)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
126 (if (event-live-p event)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
127 nil
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 217
diff changeset
128 (setq event (make-event))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
129 (apply setfun harg event args))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
130 (character-to-event value event)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
131
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
132 (defun mvh-char-to-event-other-predicate (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
133 (apply fun harg args))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
134
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
135 (defun mvh-char-to-event-other-action (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
136 (apply fun harg args))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
137
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
138 (define-magic-variable-handlers 'last-command-char
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
139 'mvh-char-to-event
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
140 'last-command-event)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
141
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
142 (define-magic-variable-handlers 'last-input-char
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
143 'mvh-char-to-event
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
144 'last-input-event)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
145
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
146 (define-magic-variable-handlers 'unread-command-char
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
147 'mvh-char-to-event
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
148 'unread-command-event)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
149
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
150 ;; suggest-key-bindings
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
151
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
152 (set-magic-variable-handler
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
153 'suggest-key-bindings 'get-value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
154 #'(lambda (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
155 (and (apply fun 'teach-extended-commands-p args)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
156 (apply fun 'teach-extended-commands-timeout args))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
157
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
158 (set-magic-variable-handler
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
159 'suggest-key-bindings 'set-value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
160 #'(lambda (sym value setfun getfun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
161 (apply setfun 'teach-extended-commands-p (not (null value)) args)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
162 (if value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
163 (apply 'teach-extended-commands-timeout
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
164 (if (numberp value) value 2) args))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
165
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
166 (set-magic-variable-handler
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
167 'suggest-key-bindings 'other-action
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
168 #'(lambda (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
169 (apply fun 'teach-extended-commands-p args)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
170 (apply fun 'teach-extended-commands-timeout args)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
171
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
172 (set-magic-variable-handler
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
173 'suggest-key-bindings 'other-predicate
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
174 #'(lambda (sym fun args harg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
175 (and (apply fun 'teach-extended-commands-p args)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
176 (apply fun 'teach-extended-commands-timeout args))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
177
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
178 ;;; symbols.el ends here