0
|
1 ;;; subr.el --- basic lisp subroutines for XEmacs
|
|
2
|
|
3 ;;; Copyright (C) 1985, 1986, 1992, 1994, 1995 Free Software Foundation, Inc.
|
|
4 ;;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
|
|
5 ;;; Copyright (C) 1995 Sun Microsystems.
|
|
6
|
|
7 ;; This file is part of XEmacs.
|
|
8
|
|
9 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
10 ;; under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
14 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
17 ;; General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
70
|
20 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
21 ;; Free Software Foundation, 59 Temple Place - Suite 330,
|
|
22 ;; Boston, MA 02111-1307, USA.
|
0
|
23
|
70
|
24 ;;; Synched up with: FSF 19.30.
|
0
|
25
|
|
26 ;;; Code:
|
|
27
|
|
28
|
|
29 ;;;; Lisp language features.
|
|
30
|
|
31 (defmacro lambda (&rest cdr)
|
|
32 "Return a lambda expression.
|
|
33 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is
|
|
34 self-quoting; the result of evaluating the lambda expression is the
|
|
35 expression itself. The lambda expression may then be treated as a
|
|
36 function, i.e., stored as the function value of a symbol, passed to
|
|
37 funcall or mapcar, etc.
|
|
38
|
|
39 ARGS should take the same form as an argument list for a `defun'.
|
|
40 DOCSTRING is an optional documentation string.
|
|
41 If present, it should describe how to call the function.
|
|
42 But documentation strings are usually not useful in nameless functions.
|
|
43 INTERACTIVE should be a call to the function `interactive', which see.
|
|
44 It may also be omitted.
|
|
45 BODY should be a list of lisp expressions."
|
|
46 ;; Note that this definition should not use backquotes; subr.el should not
|
|
47 ;; depend on backquote.el.
|
|
48 ;; #### - I don't see why. So long as backquote.el doesn't use anything
|
|
49 ;; from subr.el, there's no problem with using backquotes here. --Stig
|
4
|
50 ;;(list 'function (cons 'lambda cdr)))
|
|
51 `(function (lambda ,@cdr)))
|
|
52
|
|
53 (defmacro defun-when-void (&rest args)
|
|
54 "Define a function, just like `defun', unless it's already defined.
|
|
55 Used for compatibility among different emacs variants."
|
|
56 `(if (fboundp ',(car args))
|
|
57 nil
|
|
58 (defun ,@args)))
|
0
|
59
|
4
|
60 (defmacro define-function-when-void (&rest args)
|
|
61 "Define a function, just like `define-function', unless it's already defined.
|
|
62 Used for compatibility among different emacs variants."
|
|
63 `(if (fboundp ,(car args))
|
|
64 nil
|
|
65 (define-function ,@args)))
|
|
66
|
0
|
67 (define-function 'not 'null)
|
70
|
68 (define-function-when-void 'numberp 'intergerp) ; different when floats
|
0
|
69
|
|
70 (defun local-variable-if-set-p (sym buffer)
|
|
71 "Return t if SYM would be local to BUFFER after it is set.
|
|
72 A nil value for BUFFER is *not* the same as (current-buffer), but
|
|
73 can be used to determine whether `make-variable-buffer-local' has been
|
|
74 called on SYM."
|
|
75 (local-variable-p sym buffer t))
|
|
76
|
|
77
|
|
78 ;;;; Hook manipulation functions.
|
|
79
|
|
80 (defun make-local-hook (hook)
|
|
81 "Make the hook HOOK local to the current buffer.
|
|
82 When a hook is local, its local and global values
|
|
83 work in concert: running the hook actually runs all the hook
|
|
84 functions listed in *either* the local value *or* the global value
|
|
85 of the hook variable.
|
|
86
|
|
87 This function works by making `t' a member of the buffer-local value,
|
|
88 which acts as a flag to run the hook functions in the default value as
|
|
89 well. This works for all normal hooks, but does not work for most
|
|
90 non-normal hooks yet. We will be changing the callers of non-normal
|
|
91 hooks so that they can handle localness; this has to be done one by
|
|
92 one.
|
|
93
|
|
94 This function does nothing if HOOK is already local in the current
|
|
95 buffer.
|
|
96
|
|
97 Do not use `make-local-variable' to make a hook variable buffer-local."
|
70
|
98 (if (local-variable-p hook (current-buffer))
|
0
|
99 nil
|
|
100 (or (boundp hook) (set hook nil))
|
|
101 (make-local-variable hook)
|
|
102 (set hook (list t))))
|
|
103
|
|
104 (defun add-hook (hook function &optional append local)
|
|
105 "Add to the value of HOOK the function FUNCTION.
|
|
106 FUNCTION is not added if already present.
|
|
107 FUNCTION is added (if necessary) at the beginning of the hook list
|
|
108 unless the optional argument APPEND is non-nil, in which case
|
|
109 FUNCTION is added at the end.
|
|
110
|
|
111 The optional fourth argument, LOCAL, if non-nil, says to modify
|
|
112 the hook's buffer-local value rather than its default value.
|
|
113 This makes no difference if the hook is not buffer-local.
|
|
114 To make a hook variable buffer-local, always use
|
|
115 `make-local-hook', not `make-local-variable'.
|
|
116
|
|
117 HOOK should be a symbol, and FUNCTION may be any valid function. If
|
|
118 HOOK is void, it is first set to nil. If HOOK's value is a single
|
|
119 function, it is changed to a list of functions."
|
70
|
120 ;(interactive "SAdd to hook-var (symbol): \naAdd which function to %s? ")
|
0
|
121 (or (boundp hook) (set hook nil))
|
|
122 (or (default-boundp hook) (set-default hook nil))
|
|
123 ;; If the hook value is a single function, turn it into a list.
|
|
124 (let ((old (symbol-value hook)))
|
|
125 (if (or (not (listp old)) (eq (car old) 'lambda))
|
|
126 (set hook (list old))))
|
|
127 (if (or local
|
|
128 ;; Detect the case where make-local-variable was used on a hook
|
|
129 ;; and do what we used to do.
|
70
|
130 (and (local-variable-if-set-p hook (current-buffer))
|
0
|
131 (not (memq t (symbol-value hook)))))
|
|
132 ;; Alter the local value only.
|
|
133 (or (if (consp function)
|
|
134 (member function (symbol-value hook))
|
|
135 (memq function (symbol-value hook)))
|
|
136 (set hook
|
|
137 (if append
|
|
138 (append (symbol-value hook) (list function))
|
|
139 (cons function (symbol-value hook)))))
|
|
140 ;; Alter the global value (which is also the only value,
|
|
141 ;; if the hook doesn't have a local value).
|
|
142 (or (if (consp function)
|
|
143 (member function (default-value hook))
|
|
144 (memq function (default-value hook)))
|
|
145 (set-default hook
|
|
146 (if append
|
|
147 (append (default-value hook) (list function))
|
|
148 (cons function (default-value hook)))))))
|
|
149
|
|
150 (defun remove-hook (hook function &optional local)
|
|
151 "Remove from the value of HOOK the function FUNCTION.
|
|
152 HOOK should be a symbol, and FUNCTION may be any valid function. If
|
|
153 FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
|
|
154 list of hooks to run in HOOK, then nothing is done. See `add-hook'.
|
|
155
|
|
156 The optional third argument, LOCAL, if non-nil, says to modify
|
|
157 the hook's buffer-local value rather than its default value.
|
|
158 This makes no difference if the hook is not buffer-local.
|
|
159 To make a hook variable buffer-local, always use
|
|
160 `make-local-hook', not `make-local-variable'."
|
|
161 (if (or (not (boundp hook)) ;unbound symbol, or
|
|
162 (not (default-boundp 'hook))
|
|
163 (null (symbol-value hook)) ;value is nil, or
|
|
164 (null function)) ;function is nil, then
|
|
165 nil ;Do nothing.
|
|
166 (if (or local
|
|
167 ;; Detect the case where make-local-variable was used on a hook
|
|
168 ;; and do what we used to do.
|
|
169 (and (local-variable-p hook (current-buffer))
|
|
170 (not (memq t (symbol-value hook)))))
|
|
171 (let ((hook-value (symbol-value hook)))
|
|
172 (if (consp hook-value)
|
|
173 (if (member function hook-value)
|
|
174 (setq hook-value (delete function (copy-sequence hook-value))))
|
|
175 (if (equal hook-value function)
|
|
176 (setq hook-value nil)))
|
|
177 (set hook hook-value))
|
|
178 (let ((hook-value (default-value hook)))
|
|
179 (if (consp hook-value)
|
|
180 (if (member function hook-value)
|
|
181 (setq hook-value (delete function (copy-sequence hook-value))))
|
|
182 (if (equal hook-value function)
|
|
183 (setq hook-value nil)))
|
|
184 (set-default hook hook-value)))))
|
|
185
|
|
186 (defun add-to-list (list-var element)
|
|
187 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
|
|
188 If you want to use `add-to-list' on a variable that is not defined
|
|
189 until a certain package is loaded, you should put the call to `add-to-list'
|
|
190 into a hook function that will be run only after loading the package.
|
|
191 `eval-after-load' provides one way to do this. In some cases
|
|
192 other hooks, such as major mode hooks, can do the job."
|
|
193 (or (member element (symbol-value list-var))
|
|
194 (set list-var (cons element (symbol-value list-var)))))
|
|
195
|
|
196 ;; called by Fkill_buffer()
|
|
197 (defvar kill-buffer-hook nil
|
|
198 "Function or functions to be called when a buffer is killed.
|
|
199 The value of this variable may be buffer-local.
|
|
200 The buffer about to be killed is current when this hook is run.")
|
|
201
|
|
202 ;; in C in FSFmacs
|
|
203 (defvar kill-emacs-hook nil
|
|
204 "Function or functions to be called when `kill-emacs' is called,
|
|
205 just before emacs is actually killed.")
|
|
206
|
|
207 ;; not obsolete.
|
|
208 (define-function 'rplaca 'setcar)
|
|
209 (define-function 'rplacd 'setcdr)
|
|
210
|
|
211 (defun mapvector (__function __seq)
|
|
212 "Apply FUNCTION to each element of SEQ, making a vector of the results.
|
|
213 The result is a vector of the same length as SEQ.
|
|
214 SEQ may be a list, a vector or a string."
|
|
215 (let* ((len (length __seq))
|
|
216 (vec (make-vector len 'nil))
|
|
217 (i 0))
|
|
218 (while (< i len)
|
|
219 (aset vec i (funcall __function (cond ((listp __seq)
|
|
220 (nth i __seq))
|
|
221 (t (aref __seq i)))))
|
|
222 (setq i (+ i 1)))
|
|
223 vec))
|
|
224
|
|
225 ;;;; String functions.
|
|
226
|
|
227 (defun replace-in-string (str regexp newtext &optional literal)
|
|
228 "Replaces all matches in STR for REGEXP with NEWTEXT string.
|
|
229 Optional LITERAL non-nil means do a literal replacement.
|
|
230 Otherwise treat \\ in NEWTEXT string as special:
|
|
231 \\& means substitute original matched text,
|
|
232 \\N means substitute match for \(...\) number N,
|
|
233 \\\\ means insert one \\."
|
|
234 (if (not (stringp str))
|
|
235 (error "(replace-in-string): First argument must be a string: %s" str))
|
|
236 (if (stringp newtext)
|
|
237 nil
|
|
238 (error "(replace-in-string): 3rd arg must be a string: %s"
|
|
239 newtext))
|
|
240 (let ((rtn-str "")
|
|
241 (start 0)
|
|
242 (special)
|
|
243 match prev-start)
|
|
244 (while (setq match (string-match regexp str start))
|
|
245 (setq prev-start start
|
|
246 start (match-end 0)
|
|
247 rtn-str
|
|
248 (concat
|
|
249 rtn-str
|
|
250 (substring str prev-start match)
|
|
251 (cond (literal newtext)
|
|
252 (t (mapconcat
|
|
253 (function
|
|
254 (lambda (c)
|
|
255 (if special
|
|
256 (progn
|
|
257 (setq special nil)
|
|
258 (cond ((eq c ?\\) "\\")
|
|
259 ((eq c ?&)
|
|
260 (substring str
|
|
261 (match-beginning 0)
|
|
262 (match-end 0)))
|
|
263 ((and (>= c ?0) (<= c ?9))
|
|
264 (if (> c (+ ?0 (length
|
|
265 (match-data))))
|
|
266 ;; Invalid match num
|
|
267 (error "(replace-in-string) Invalid match num: %c" c)
|
|
268 (setq c (- c ?0))
|
|
269 (substring str
|
|
270 (match-beginning c)
|
|
271 (match-end c))))
|
|
272 (t (char-to-string c))))
|
|
273 (if (eq c ?\\) (progn (setq special t) nil)
|
|
274 (char-to-string c)))))
|
|
275 newtext ""))))))
|
|
276 (concat rtn-str (substring str start))))
|
|
277
|
|
278 (defun split-string (string pattern)
|
|
279 "Return a list of substrings of STRING which are separated by PATTERN."
|
|
280 (let (parts (start 0))
|
|
281 (while (string-match pattern string start)
|
|
282 (setq parts (cons (substring string start (match-beginning 0)) parts)
|
|
283 start (match-end 0)))
|
|
284 (nreverse (cons (substring string start) parts))
|
|
285 ))
|
|
286
|
|
287 (defmacro with-output-to-string (&rest forms)
|
|
288 "Collect output to `standard-output' while evaluating FORMS and return
|
|
289 it as a string."
|
|
290 ;; by "William G. Dubuque" <wgd@zurich.ai.mit.edu> w/ mods from Stig
|
|
291 (` (save-excursion
|
|
292 (set-buffer (get-buffer-create " *string-output*"))
|
|
293 (setq buffer-read-only nil)
|
|
294 (buffer-disable-undo (current-buffer))
|
|
295 (erase-buffer)
|
|
296 (let ((standard-output (current-buffer)))
|
|
297 (,@ forms))
|
|
298 (prog1
|
|
299 (buffer-string)
|
|
300 (erase-buffer)))))
|
|
301
|
|
302 (defun insert-face (string face)
|
|
303 "Insert STRING and highlight with FACE. Returns the extent created."
|
|
304 (let ((p (point)) ext)
|
|
305 (insert string)
|
|
306 (setq ext (make-extent p (point)))
|
|
307 (set-extent-face ext face)
|
|
308 ext))
|
|
309
|
|
310 ;; not obsolete.
|
|
311 (define-function 'string= 'string-equal)
|
|
312 (define-function 'string< 'string-lessp)
|
|
313 (define-function 'int-to-string 'number-to-string)
|
|
314 (define-function 'string-to-int 'string-to-number)
|
|
315
|
|
316 ;; alist/plist functions
|
|
317 (defun plist-to-alist (plist)
|
|
318 "Convert property list PLIST into the equivalent association-list form.
|
|
319 The alist is returned. This converts from
|
|
320
|
|
321 \(a 1 b 2 c 3)
|
|
322
|
|
323 into
|
|
324
|
|
325 \((a . 1) (b . 2) (c . 3))
|
|
326
|
|
327 The original plist is not modified. See also `destructive-plist-to-alist'."
|
|
328 (let (alist)
|
|
329 (while plist
|
|
330 (setq alist (cons (cons (car plist) (cadr plist)) alist))
|
|
331 (setq plist (cddr plist)))
|
|
332 (nreverse alist)))
|
|
333
|
|
334 (defun destructive-plist-to-alist (plist)
|
|
335 "Convert property list PLIST into the equivalent association-list form.
|
|
336 The alist is returned. This converts from
|
|
337
|
|
338 \(a 1 b 2 c 3)
|
|
339
|
|
340 into
|
|
341
|
|
342 \((a . 1) (b . 2) (c . 3))
|
|
343
|
|
344 The original plist is destroyed in the process of constructing the alist.
|
|
345 See also `plist-to-alist'."
|
|
346 (let ((head plist)
|
|
347 next)
|
|
348 (while plist
|
|
349 ;; remember the next plist pair.
|
|
350 (setq next (cddr plist))
|
|
351 ;; make the cons holding the property value into the alist element.
|
|
352 (setcdr (cdr plist) (cadr plist))
|
|
353 (setcar (cdr plist) (car plist))
|
|
354 ;; reattach into alist form.
|
|
355 (setcar plist (cdr plist))
|
|
356 (setcdr plist next)
|
|
357 (setq plist next))
|
|
358 head))
|
|
359
|
|
360 (defun alist-to-plist (alist)
|
|
361 "Convert association list ALIST into the equivalent property-list form.
|
|
362 The plist is returned. This converts from
|
|
363
|
|
364 \((a . 1) (b . 2) (c . 3))
|
|
365
|
|
366 into
|
|
367
|
|
368 \(a 1 b 2 c 3)
|
|
369
|
|
370 The original alist is not modified. See also `destructive-alist-to-plist'."
|
|
371 (let (plist)
|
|
372 (while alist
|
|
373 (let ((el (car alist)))
|
|
374 (setq plist (cons (cdr el) (cons (car el) plist))))
|
|
375 (setq alist (cdr alist)))
|
|
376 (nreverse plist)))
|
|
377
|
|
378 ;; getf, remf in cl*.el.
|
|
379
|
|
380 (defmacro putf (plist prop val)
|
|
381 "Add property PROP to plist PLIST with value VAL.
|
|
382 Analogous to (setq PLIST (plist-put PLIST PROP VAL))."
|
|
383 `(setq ,plist (plist-put ,plist ,prop ,val)))
|
|
384
|
|
385 (defmacro laxputf (lax-plist prop val)
|
|
386 "Add property PROP to lax plist LAX-PLIST with value VAL.
|
|
387 Analogous to (setq LAX-PLIST (lax-plist-put LAX-PLIST PROP VAL))."
|
|
388 `(setq ,lax-plist (lax-plist-put ,lax-plist ,prop ,val)))
|
|
389
|
|
390 (defmacro laxremf (lax-plist prop)
|
|
391 "Remove property PROP from lax plist LAX-PLIST.
|
|
392 Analogous to (setq LAX-PLIST (lax-plist-remprop LAX-PLIST PROP))."
|
|
393 `(setq ,lax-plist (lax-plist-remprop ,lax-plist ,prop)))
|
|
394
|
|
395 ;;; Error functions
|
|
396
|
|
397 (defun error (&rest args)
|
|
398 "Signal an error, making error message by passing all args to `format'.
|
|
399 This error is not continuable: you cannot continue execution after the
|
|
400 error using the debugger `r' command. See also `cerror'."
|
|
401 (while t
|
|
402 (apply 'cerror args)))
|
|
403
|
|
404 (defun cerror (&rest args)
|
|
405 "Like `error' but signals a continuable error."
|
|
406 (signal 'error (list (apply 'format args))))
|
|
407
|
|
408 (defmacro check-argument-type (predicate argument)
|
|
409 "Check that ARGUMENT satisfies PREDICATE.
|
|
410 If not, signal a continuable `wrong-type-argument' error until the
|
70
|
411 returned value satifies PREDICATE, and assign the returned value
|
0
|
412 to ARGUMENT."
|
|
413 `(if (not (,(eval predicate) ,argument))
|
|
414 (setq ,argument
|
|
415 (wrong-type-argument ,predicate ,argument))))
|
|
416
|
|
417 (defun signal-error (error-symbol data)
|
|
418 "Signal a non-continuable error. Args are ERROR-SYMBOL, and associated DATA.
|
|
419 An error symbol is a symbol defined using `define-error'.
|
|
420 DATA should be a list. Its elements are printed as part of the error message.
|
|
421 If the signal is handled, DATA is made available to the handler.
|
|
422 See also `signal', and the functions to handle errors: `condition-case'
|
|
423 and `call-with-condition-handler'."
|
|
424 (while t
|
|
425 (signal error-symbol data)))
|
|
426
|
|
427 (defun define-error (error-sym doc-string &optional inherits-from)
|
|
428 "Define a new error, denoted by ERROR-SYM.
|
|
429 DOC-STRING is an informative message explaining the error, and will be
|
|
430 printed out when an unhandled error occurs.
|
|
431 ERROR-SYM is a sub-error of INHERITS-FROM (which defaults to `error').
|
|
432
|
|
433 \[`define-error' internally works by putting on ERROR-SYM an `error-message'
|
|
434 property whose value is DOC-STRING, and an `error-conditions' property
|
|
435 that is a list of ERROR-SYM followed by each of its super-errors, up
|
|
436 to and including `error'. You will sometimes see code that sets this up
|
|
437 directly rather than calling `define-error', but you should *not* do this
|
|
438 yourself.]"
|
|
439 (check-argument-type 'symbolp error-sym)
|
|
440 (check-argument-type 'stringp doc-string)
|
|
441 (put error-sym 'error-message doc-string)
|
|
442 (or inherits-from (setq inherits-from 'error))
|
|
443 (let ((conds (get inherits-from 'error-conditions)))
|
|
444 (or conds (signal-error 'error (list "Not an error symbol" error-sym)))
|
|
445 (put error-sym 'error-conditions (cons error-sym conds))))
|
|
446
|
|
447 ;;;; Miscellanea.
|
|
448
|
|
449 (defun buffer-substring-no-properties (beg end)
|
|
450 "Return the text from BEG to END, without text properties, as a string."
|
|
451 (let ((string (buffer-substring beg end)))
|
|
452 (set-text-properties 0 (length string) nil string)
|
|
453 string))
|
|
454
|
|
455 (defun ignore (&rest ignore)
|
|
456 "Do nothing and return nil.
|
|
457 This function accepts any number of arguments, but ignores them."
|
|
458 (interactive)
|
|
459 nil)
|
|
460
|
|
461 (defmacro save-current-buffer (&rest forms)
|
|
462 "Restore the current buffer setting after executing FORMS.
|
|
463 Does not restore the values of point and mark.
|
|
464 See also: `save-excursion'."
|
|
465 ;; by Stig@hackvan.com
|
|
466 (` (let ((_cur_buf_ (current-buffer)))
|
|
467 (unwind-protect
|
|
468 (progn (,@ forms))
|
|
469 (set-buffer _cur_buf_)))))
|
|
470
|
|
471 (defmacro eval-in-buffer (buffer &rest forms)
|
|
472 "Evaluate FORMS in BUFFER.
|
|
473 See also: `save-current-buffer' and `save-excursion'."
|
|
474 ;; by Stig@hackvan.com
|
|
475 (` (save-current-buffer
|
|
476 (set-buffer (, buffer))
|
|
477 (,@ forms))))
|
|
478
|
|
479 ;;; The real defn is in abbrev.el but some early callers
|
|
480 ;;; (eg lisp-mode-abbrev-table) want this before abbrev.el is loaded...
|
|
481
|
|
482 (if (not (fboundp 'define-abbrev-table))
|
|
483 (progn
|
|
484 (setq abbrev-table-name-list '())
|
|
485 (fset 'define-abbrev-table (function (lambda (name defs)
|
|
486 ;; These are fixed-up when abbrev.el loads.
|
|
487 (setq abbrev-table-name-list
|
|
488 (cons (cons name defs)
|
|
489 abbrev-table-name-list)))))))
|
|
490
|
|
491 (defun functionp (obj)
|
|
492 "Returns t if OBJ is a function, nil otherwise."
|
|
493 (cond
|
|
494 ((symbolp obj) (fboundp obj))
|
|
495 ((subrp obj))
|
|
496 ((compiled-function-p obj))
|
|
497 ((consp obj)
|
|
498 (if (eq (car obj) 'lambda) (listp (car (cdr obj)))))
|
|
499 (t nil)))
|
|
500
|
|
501 ;; This was not present before. I think Jamie had some objections
|
|
502 ;; to this, so I'm leaving this undefined for now. --ben
|
|
503
|
|
504 ;;; The objection is this: there is more than one way to load the same file.
|
70
|
505 ;;; "foo", "foo.elc", "foo.el", and "/some/path/foo.elc" are all differrent
|
0
|
506 ;;; ways to load the exact same code. `eval-after-load' is too stupid to
|
|
507 ;;; deal with this sort of thing. If this sort of feature is desired, then
|
|
508 ;;; it should work off of a hook on `provide'. Features are unique and
|
|
509 ;;; the arguments to (load) are not. --Stig
|
|
510
|
|
511 ;;;; Specifying things to do after certain files are loaded.
|
|
512
|
70
|
513 ;(defun eval-after-load (file form)
|
|
514 ; "Arrange that, if FILE is ever loaded, FORM will be run at that time.
|
|
515 ;This makes or adds to an entry on `after-load-alist'.
|
|
516 ;If FILE is already loaded, evaluate FORM right now.
|
|
517 ;It does nothing if FORM is already on the list for FILE.
|
|
518 ;FILE should be the name of a library, with no directory name."
|
|
519 ; ;; Make sure there is an element for FILE.
|
|
520 ; (or (assoc file after-load-alist)
|
|
521 ; (setq after-load-alist (cons (list file) after-load-alist)))
|
|
522 ; ;; Add FORM to the element if it isn't there.
|
|
523 ; (let ((elt (assoc file after-load-alist)))
|
|
524 ; (or (member form (cdr elt))
|
|
525 ; (progn
|
|
526 ; (nconc elt (list form))
|
|
527 ; ;; If the file has been loaded already, run FORM right away.
|
|
528 ; (and (assoc file load-history)
|
|
529 ; (eval form)))))
|
|
530 ; form)
|
|
531 ;
|
|
532 ;(defun eval-next-after-load (file)
|
|
533 ; "Read the following input sexp, and run it whenever FILE is loaded.
|
|
534 ;This makes or adds to an entry on `after-load-alist'.
|
|
535 ;FILE should be the name of a library, with no directory name."
|
|
536 ; (eval-after-load file (read)))
|
0
|
537
|
|
538 ; alternate names (not obsolete)
|
|
539 (if (not (fboundp 'mod)) (define-function 'mod '%))
|
|
540 (define-function 'move-marker 'set-marker)
|
2
|
541 (define-function 'beep 'ding) ; preserve lingual purity
|
0
|
542 (define-function 'indent-to-column 'indent-to)
|
|
543 (define-function 'backward-delete-char 'delete-backward-char)
|
|
544 (define-function 'search-forward-regexp (symbol-function 're-search-forward))
|
|
545 (define-function 'search-backward-regexp (symbol-function 're-search-backward))
|
|
546 (define-function 'remove-directory 'delete-directory)
|
|
547 (define-function 'set-match-data 'store-match-data)
|
|
548 (define-function 'send-string-to-terminal 'external-debugging-output)
|
|
549 (define-function 'buffer-string 'buffer-substring)
|