1 ;;; poe.el --- Portable Outfit for Emacsen; -*-byte-compile-dynamic: t;-*-
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
6 ;; Keywords: emulation, compatibility, NEmacs, MULE, Emacs/mule, XEmacs
8 ;; This file is part of APEL (A Portable Emacs Library).
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; This modules does not includes MULE related features.
28 ;; MULE related features are supported by `poem'.
34 (put 'defun-maybe 'lisp-indent-function 'defun)
35 (defmacro defun-maybe (name &rest everything-else)
36 "Define NAME as a function if NAME is not defined.
37 See also the function `defun'."
38 (or (and (fboundp name)
39 (not (get name 'defun-maybe)))
40 (` (or (fboundp (quote (, name)))
42 (defun (, name) (,@ everything-else))
43 (put (quote (, name)) 'defun-maybe t))))))
45 (put 'defmacro-maybe 'lisp-indent-function 'defun)
46 (defmacro defmacro-maybe (name &rest everything-else)
47 "Define NAME as a macro if NAME is not defined.
48 See also the function `defmacro'."
49 (or (and (fboundp name)
50 (not (get name 'defmacro-maybe)))
51 (` (or (fboundp (quote (, name)))
53 (defmacro (, name) (,@ everything-else))
54 (put (quote (, name)) 'defmacro-maybe t))))))
56 (put 'defsubst-maybe 'lisp-indent-function 'defun)
57 (defmacro defsubst-maybe (name &rest everything-else)
58 "Define NAME as an inline function if NAME is not defined.
59 See also the macro `defsubst'."
60 (or (and (fboundp name)
61 (not (get name 'defsubst-maybe)))
62 (` (or (fboundp (quote (, name)))
64 (defsubst (, name) (,@ everything-else))
65 (put (quote (, name)) 'defsubst-maybe t))))))
67 (defmacro defalias-maybe (symbol definition)
68 "Define SYMBOL as an alias for DEFINITION if SYMBOL is not defined.
69 See also the function `defalias'."
70 (setq symbol (eval symbol))
71 (or (and (fboundp symbol)
72 (not (get symbol 'defalias-maybe)))
73 (` (or (fboundp (quote (, symbol)))
75 (defalias (quote (, symbol)) (, definition))
76 (put (quote (, symbol)) 'defalias-maybe t))))))
78 (defmacro defvar-maybe (name &rest everything-else)
79 "Define NAME as a variable if NAME is not defined.
80 See also the function `defvar'."
81 (or (and (boundp name)
82 (not (get name 'defvar-maybe)))
83 (` (or (boundp (quote (, name)))
85 (defvar (, name) (,@ everything-else))
86 (put (quote (, name)) 'defvar-maybe t))))))
88 (defmacro defconst-maybe (name &rest everything-else)
89 "Define NAME as a constant variable if NAME is not defined.
90 See also the function `defconst'."
91 (or (and (boundp name)
92 (not (get name 'defconst-maybe)))
93 (` (or (boundp (quote (, name)))
95 (defconst (, name) (,@ everything-else))
96 (put (quote (, name)) 'defconst-maybe t))))))
98 (defmacro defun-maybe-cond (name args &optional doc &rest everything-else)
100 (setq everything-else (cons doc everything-else)
102 (or (and (fboundp name)
103 (not (get name 'defun-maybe)))
104 (` (or (fboundp (quote (, name)))
106 (cond (,@ (mapcar (function
110 (` (defun (, name) (, args)
113 (` (defun (, name) (, args)
114 (,@ (cdr case))))))))
116 (put (quote (, name)) 'defun-maybe t))))))
118 (defmacro defmacro-maybe-cond (name args &optional doc &rest everything-else)
120 (setq everything-else (cons doc everything-else)
122 (or (and (fboundp name)
123 (not (get name 'defmacro-maybe)))
124 (` (or (fboundp (quote (, name)))
126 (cond (,@ (mapcar (function
130 (` (defmacro (, name) (, args)
133 (` (defmacro (, name) (, args)
134 (,@ (cdr case))))))))
136 (put (quote (, name)) 'defmacro-maybe t))))))
138 (defun subr-fboundp (symbol)
139 "Return t if SYMBOL's function definition is a built-in function."
140 (and (fboundp symbol)
141 (subrp (symbol-function symbol))))
143 (defconst-maybe emacs-major-version (string-to-int emacs-version))
144 (defconst-maybe emacs-minor-version
146 (substring emacs-version
147 (string-match (format "%d\\." emacs-major-version)
150 (cond ((featurep 'xemacs)
151 (require 'poe-xemacs)
153 ((string-match "XEmacs" emacs-version)
155 (require 'poe-xemacs)
157 ((> emacs-major-version 20))
158 ((= emacs-major-version 20)
159 (cond ((subr-fboundp 'string)
160 ;; Emacs 20.3 or later
162 ((subr-fboundp 'concat-chars)
163 ;; Emacs 20.1 or later
164 (defalias 'string 'concat-chars)
167 ((= emacs-major-version 19)
168 ;; XXX: should do compile-time and load-time check before loading
169 ;; "localhook". But, it is difficult since "localhook" is
170 ;; already loaded via "install" at compile-time. any idea?
171 (if (< emacs-minor-version 29)
172 (require 'localhook)))
175 ;; XXX: should do compile-time and load-time check before loading
176 ;; "localhook". But, it is difficult since "localhook" is
177 ;; already loaded via "install" at compile-time. any idea?
178 (require 'localhook)))
180 ;;; `eval-when-compile' is defined in "poe-18" under v18 with old compiler.
181 (eval-when-compile (require 'static))
183 ;; imported from emacs-20.3/lisp/emacs-lisp/edebug.el.
184 ;; `def-edebug-spec' is an autoloaded macro in v19 and later.
185 (defmacro-maybe def-edebug-spec (symbol spec)
186 "Set the edebug-form-spec property of SYMBOL according to SPEC.
187 Both SYMBOL and SPEC are unevaluated. The SPEC can be 0, t, a symbol
188 \(naming a function\), or a list."
189 (` (put (quote (, symbol)) 'edebug-form-spec (quote (, spec)))))
191 (def-edebug-spec defun-maybe defun)
192 (def-edebug-spec defmacro-maybe defmacro)
193 (def-edebug-spec defsubst-maybe defun)
195 ;;; Emacs 20.1 emulation
197 ;; imported from emacs-20.3/lisp/subr.el.
198 (defmacro-maybe when (cond &rest body)
199 "If COND yields non-nil, do BODY, else return nil."
200 (list 'if cond (cons 'progn body)))
201 ;; (def-edebug-spec when (&rest form))
203 ;; imported from emacs-20.3/lisp/subr.el.
204 (defmacro-maybe unless (cond &rest body)
205 "If COND yields nil, do BODY, else return nil."
206 (cons 'if (cons cond (cons nil body))))
207 ;; (def-edebug-spec unless (&rest form))
210 ;;; @ Emacs 19.23 emulation
213 (defun-maybe minibuffer-prompt-width ()
214 "Return the display width of the minibuffer prompt."
216 (set-buffer (window-buffer (minibuffer-window)))
220 ;;; @ Emacs 19.29 emulation
223 (defvar-maybe path-separator ":"
224 "The directory separator in search paths, as a string.")
226 (defun-maybe buffer-substring-no-properties (start end)
227 "Return the characters of part of the buffer, without the text properties.
228 The two arguments START and END are character positions;
229 they can be in either order.
230 \[Emacs 19.29 emulating function]"
231 (let ((string (buffer-substring start end)))
232 (set-text-properties 0 (length string) nil string)
235 ;; imported from emacs-19.34/lisp/subr.el.
236 (defun-maybe match-string (num &optional string)
237 "Return string of text matched by last search.
238 NUM specifies which parenthesized expression in the last regexp.
239 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
240 Zero means the entire text matched by the whole regexp or whole string.
241 STRING should be given if the last search was by `string-match' on STRING.
242 \[Emacs 19.29 emulating function]"
243 (if (match-beginning num)
245 (substring string (match-beginning num) (match-end num))
246 (buffer-substring (match-beginning num) (match-end num)))))
248 (static-unless (or (featurep 'xemacs)
249 (>= emacs-major-version 20)
250 (and (= emacs-major-version 19)
251 (>= emacs-minor-version 29)))
252 ;; for Emacs 19.28 or earlier
253 (unless (fboundp 'si:read-string)
254 (fset 'si:read-string (symbol-function 'read-string))
255 (defun read-string (prompt &optional initial-input history)
256 "Read a string from the minibuffer, prompting with string PROMPT.
257 If non-nil, second arg INITIAL-INPUT is a string to insert before reading.
258 The third arg HISTORY, is dummy for compatibility.
259 See `read-from-minibuffer' for details of HISTORY argument."
260 (si:read-string prompt initial-input))
263 (defun-maybe rassoc (key list)
264 "Return non-nil if KEY is `equal' to the cdr of an element of LIST.
265 The value is actually the element of LIST whose cdr equals KEY.
266 \[Emacs 19.29 emulating function]"
269 (if (equal (cdr (car list)) key)
270 (throw 'found (car list)))
271 (setq list (cdr list)))))
273 ;; imported from emacs-19.34/lisp/files.el.
274 (defun-maybe file-name-sans-extension (filename)
275 "Return FILENAME sans final \"extension\".
276 The extension, in a file name, is the part that follows the last `.'.
277 \[Emacs 19.29 emulating function]"
279 (let ((file (file-name-sans-versions (file-name-nondirectory filename)))
281 (if (string-match "\\.[^.]*\\'" file)
282 (if (setq directory (file-name-directory filename))
283 (expand-file-name (substring file 0 (match-beginning 0))
285 (substring file 0 (match-beginning 0)))
289 ;;; @ Emacs 19.30 emulation
292 ;; imported from emacs-19.34/lisp/subr.el.
293 (defun-maybe add-to-list (list-var element)
294 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
295 The test for presence of ELEMENT is done with `equal'.
296 If you want to use `add-to-list' on a variable that is not defined
297 until a certain package is loaded, you should put the call to `add-to-list'
298 into a hook function that will be run only after loading the package.
299 `eval-after-load' provides one way to do this. In some cases
300 other hooks, such as major mode hooks, can do the job.
301 \[Emacs 19.30 emulating function]"
302 (or (member element (symbol-value list-var))
303 (set list-var (cons element (symbol-value list-var)))))
305 (cond ((fboundp 'insert-file-contents-literally))
306 ((boundp 'file-name-handler-alist)
307 (defun insert-file-contents-literally
308 (filename &optional visit beg end replace)
309 "Like `insert-file-contents', q.v., but only reads in the file.
310 A buffer may be modified in several ways after reading into the buffer due
311 to advanced Emacs features, such as file-name-handlers, format decoding,
312 find-file-hooks, etc.
313 This function ensures that none of these modifications will take place.
314 \[Emacs 19.30 emulating function]"
315 (let (file-name-handler-alist)
316 (insert-file-contents filename visit beg end replace)))
319 (defalias 'insert-file-contents-literally 'insert-file-contents)
323 ;;; @ Emacs 19.31 emulation
326 (defun-maybe buffer-live-p (object)
327 "Return non-nil if OBJECT is a buffer which has not been killed.
328 Value is nil if OBJECT is not a buffer or if it has been killed.
329 \[Emacs 19.31 emulating function]"
332 (buffer-name (get-buffer object))
335 ;; imported from emacs-19.34/lisp/window.el.
336 (defmacro-maybe save-selected-window (&rest body)
337 "Execute BODY, then select the window that was selected before BODY.
338 \[Emacs 19.31 emulating function]"
340 '((save-selected-window-window (selected-window)))
341 (list 'unwind-protect
343 (list 'select-window 'save-selected-window-window))))
346 ;;; @ Emacs 20.1 emulation
349 ;; imported from emacs-20.3/lisp/subr.el.
350 (defsubst-maybe caar (x)
351 "Return the car of the car of X."
354 ;; imported from emacs-20.3/lisp/subr.el.
355 (defsubst-maybe cadr (x)
356 "Return the car of the cdr of X."
359 ;; imported from emacs-20.3/lisp/subr.el.
360 (defsubst-maybe cdar (x)
361 "Return the cdr of the car of X."
364 ;; imported from emacs-20.3/lisp/subr.el.
365 (defsubst-maybe cddr (x)
366 "Return the cdr of the cdr of X."
369 ;; imported from emacs-20.3/lisp/subr.el.
370 (defun-maybe last (x &optional n)
371 "Return the last link of the list X. Its car is the last element.
372 If X is nil, return nil.
373 If N is non-nil, return the Nth-to-last link of X.
374 If N is bigger than the length of X, return X."
378 (setq m (1+ m) p (cdr p)))
380 (if (< n m) (nthcdr (- m n) x) x)))
385 ;; In Emacs 20.3, save-current-buffer is defined in src/editfns.c.
386 (defmacro-maybe save-current-buffer (&rest body)
387 "Save the current buffer; execute BODY; restore the current buffer.
388 Executes BODY just like `progn'."
389 (` (let ((orig-buffer (current-buffer)))
392 (if (buffer-live-p orig-buffer)
393 (set-buffer orig-buffer))))))
395 ;; imported from emacs-20.3/lisp/subr.el. (with macro style change)
396 (defmacro-maybe with-current-buffer (buffer &rest body)
397 "Execute the forms in BODY with BUFFER as the current buffer.
398 The value returned is the value of the last form in BODY.
399 See also `with-temp-buffer'."
400 (` (save-current-buffer
401 (set-buffer (, buffer))
404 ;; imported from emacs-20.3/lisp/subr.el. (with macro style change)
405 (defmacro-maybe with-temp-file (file &rest forms)
406 "Create a new buffer, evaluate FORMS there, and write the buffer to FILE.
407 The value of the last form in FORMS is returned, like `progn'.
408 See also `with-temp-buffer'."
409 (let ((temp-file (make-symbol "temp-file"))
410 (temp-buffer (make-symbol "temp-buffer")))
411 (` (let (((, temp-file) (, file))
413 (get-buffer-create (generate-new-buffer-name " *temp file*"))))
416 (with-current-buffer (, temp-buffer)
418 (with-current-buffer (, temp-buffer)
420 (write-region (point-min) (point-max) (, temp-file) nil 0)))
421 (and (buffer-name (, temp-buffer))
422 (kill-buffer (, temp-buffer))))))))
424 ;; imported from emacs-20.3/lisp/subr.el. (with macro style change)
425 (defmacro-maybe with-temp-buffer (&rest forms)
426 "Create a temporary buffer, and evaluate FORMS there like `progn'.
427 See also `with-temp-file' and `with-output-to-string'."
428 (let ((temp-buffer (make-symbol "temp-buffer")))
429 (` (let (((, temp-buffer)
430 (get-buffer-create (generate-new-buffer-name " *temp*"))))
432 (with-current-buffer (, temp-buffer)
434 (and (buffer-name (, temp-buffer))
435 (kill-buffer (, temp-buffer))))))))
437 (defmacro-maybe combine-after-change-calls (&rest body)
441 ;; imported from emacs-20.3/lisp/subr.el.
442 (defun-maybe functionp (object)
443 "Non-nil if OBJECT is a type of object that can be called as a function."
444 (or (subrp object) (byte-code-function-p object)
445 (eq (car-safe object) 'lambda)
446 (and (symbolp object) (fboundp object))))
448 ;; imported from emacs-20.3/lisp/emacs-lisp/cl.el.
449 (defun-maybe butlast (x &optional n)
450 "Returns a copy of LIST with the last N elements removed."
451 (if (and n (<= n 0)) x
452 (nbutlast (copy-sequence x) n)))
454 ;; imported from emacs-20.3/lisp/emacs-lisp/cl.el.
455 (defun-maybe nbutlast (x &optional n)
456 "Modifies LIST to remove the last N elements."
457 (let ((m (length x)))
461 (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
464 ;; imported from XEmacs 21.
465 (defun-maybe split-string (string &optional pattern)
466 "Return a list of substrings of STRING which are separated by PATTERN.
467 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
469 (setq pattern "[ \f\t\n\r\v]+"))
470 ;; The FSF version of this function takes care not to cons in case
471 ;; of infloop. Maybe we should synch?
472 (let (parts (start 0))
473 (while (string-match pattern string start)
474 (setq parts (cons (substring string start (match-beginning 0)) parts)
475 start (match-end 0)))
476 (nreverse (cons (substring string start) parts))))
478 ;; emulating char-before of Emacs 20.
479 (static-condition-case nil
480 ;; compile-time check.
482 ;; XXX: this file is already loaded at compile-time,
483 ;; so this test will always success.
485 ;; If our definition is found at compile-time, signal an error.
486 ;; XXX: should signal more specific error.
487 (if (get 'char-before 'defun-maybe)
489 (wrong-number-of-arguments ; Mule 1.*, 2.*.
491 (or (fboundp 'si:char-before)
493 (fset 'si:char-before (symbol-function 'char-before))
494 (put 'char-before 'defun-maybe t)
495 ;; takes IGNORED for backward compatibility.
496 (defun char-before (&optional pos ignored)
498 Return character in current buffer preceding position POS.
499 POS is an integer or a buffer pointer.
500 If POS is out of range, the value is nil."
501 (si:char-before (or pos (point)))))))
502 (void-function ; non-Mule.
504 (defun-maybe char-before (&optional pos)
506 Return character in current buffer preceding position POS.
507 POS is an integer or a buffer pointer.
508 If POS is out of range, the value is nil."
511 (and (= (goto-char pos) (point))
516 (error ; found our definition at compile-time.
520 (wrong-number-of-arguments ; Mule 1.*, 2.*.
521 (or (fboundp 'si:char-before)
523 (fset 'si:char-before (symbol-function 'char-before))
524 (put 'char-before 'defun-maybe t)
525 ;; takes IGNORED for backward compatibility.
526 (defun char-before (&optional pos ignored)
528 Return character in current buffer preceding position POS.
529 POS is an integer or a buffer pointer.
530 If POS is out of range, the value is nil."
531 (si:char-before (or pos (point)))))))
532 (void-function ; non-Mule.
533 (defun-maybe char-before (&optional pos)
535 Return character in current buffer preceding position POS.
536 POS is an integer or a buffer pointer.
537 If POS is out of range, the value is nil."
540 (and (= (goto-char pos) (point))
544 (preceding-char))))))))
546 ;; emulating char-after of Emacs 20.
547 (static-condition-case nil
548 ;; compile-time check.
550 ;; XXX: this file is already loaded at compile-time,
551 ;; so this test will always success.
553 ;; If our definition is found at compile-time, signal an error.
554 ;; XXX: should signal more specific error.
555 (if (get 'char-after 'defun-maybe)
557 (wrong-number-of-arguments ; v18, v19
559 (or (fboundp 'si:char-after)
561 (fset 'si:char-after (symbol-function 'char-after))
562 (put 'char-after 'defun-maybe t)
563 (defun char-after (&optional pos)
565 Return character in current buffer at position POS.
566 POS is an integer or a buffer pointer.
567 If POS is out of range, the value is nil."
568 (si:char-after (or pos (point)))))))
569 (void-function ; NEVER happen?
571 (defun-maybe char-after (&optional pos)
573 Return character in current buffer at position POS.
574 POS is an integer or a buffer pointer.
575 If POS is out of range, the value is nil."
578 (and (= (goto-char pos) (point))
583 (error ; found our definition at compile-time.
587 (wrong-number-of-arguments ; v18, v19
588 (or (fboundp 'si:char-after)
590 (fset 'si:char-after (symbol-function 'char-after))
591 (put 'char-after 'defun-maybe t)
592 (defun char-after (&optional pos)
594 Return character in current buffer at position POS.
595 POS is an integer or a buffer pointer.
596 If POS is out of range, the value is nil."
597 (si:char-after (or pos (point)))))))
598 (void-function ; NEVER happen?
599 (defun-maybe char-after (&optional pos)
601 Return character in current buffer at position POS.
602 POS is an integer or a buffer pointer.
603 If POS is out of range, the value is nil."
606 (and (= (goto-char pos) (point))
610 (following-char))))))))
613 ;;; @ Emacs 20.3 emulation
616 ;; imported from emacs-20.3/lisp/files.el.
617 (defvar-maybe temporary-file-directory
618 (file-name-as-directory
619 (cond ((memq system-type '(ms-dos windows-nt))
620 (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP") "c:/temp"))
621 ((memq system-type '(vax-vms axp-vms))
622 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "SYS$SCRATCH:"))
624 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp"))))
625 "The directory for writing temporary files.")
627 (defun-maybe line-beginning-position (&optional n)
628 "Return the character position of the first character on the current line.
629 With argument N not nil or 1, move forward N - 1 lines first.
630 If scan reaches end of buffer, return that position.
631 This function does not move point."
633 (forward-line (1- (or n 1)))
636 (defun-maybe line-end-position (&optional n)
637 "Return the character position of the last character on the current line.
638 With argument N not nil or 1, move forward N - 1 lines first.
639 If scan reaches end of buffer, return that position.
640 This function does not move point."
642 (end-of-line (or n 1))
645 (defun-maybe string (&rest chars)
646 "Concatenate all the argument characters and make the result a string."
647 (mapconcat (function char-to-string) chars ""))
650 ;;; @ XEmacs emulation
653 (defun-maybe find-face (face-or-name)
654 "Retrieve the face of the given name.
655 If FACE-OR-NAME is a face object, it is simply returned.
656 Otherwise, FACE-OR-NAME should be a symbol. If there is no such face,
657 nil is returned. Otherwise the associated face object is returned.
658 \[XEmacs emulating function]"
659 (car (memq face-or-name (face-list))))
661 (defun-maybe point-at-bol (&optional n buffer)
662 "Return the character position of the first character on the current line.
663 With argument N not nil or 1, move forward N - 1 lines first.
664 If scan reaches end of buffer, return that position.
665 This function does not move point.
666 \[XEmacs emulating function]"
668 (if buffer (set-buffer buffer))
669 (forward-line (1- (or n 1)))
672 (defun-maybe point-at-eol (&optional n buffer)
673 "Return the character position of the last character on the current line.
674 With argument N not nil or 1, move forward N - 1 lines first.
675 If scan reaches end of buffer, return that position.
676 This function does not move point.
677 \[XEmacs emulating function]"
679 (if buffer (set-buffer buffer))
680 (end-of-line (or n 1))
683 (defsubst-maybe define-obsolete-function-alias (oldfun newfun)
684 "Define OLDFUN as an obsolete alias for function NEWFUN.
685 This makes calling OLDFUN equivalent to calling NEWFUN and marks OLDFUN
687 \[XEmacs emulating function]"
688 (defalias oldfun newfun)
689 (make-obsolete oldfun newfun))
691 (when (subr-fboundp 'read-event)
692 ;; for Emacs 19 or later
694 (defun-maybe-cond next-command-event (&optional event prompt)
695 "Read an event object from the input stream.
696 If EVENT is non-nil, it should be an event object and will be filled
697 in and returned; otherwise a new event object will be created and
699 If PROMPT is non-nil, it should be a string and will be displayed in
700 the echo area while this function is waiting for an event.
701 \[XEmacs emulating function]"
702 ((subr-fboundp 'string)
703 ;; for Emacs 20.3 or later
704 (read-event prompt t)
707 (if prompt (message prompt))
711 (defsubst-maybe character-to-event (ch)
712 "Convert keystroke CH into an event structure, replete with bucky bits.
713 Note that CH (the keystroke specifier) can be an integer, a character
714 or a symbol such as 'clear. [XEmacs emulating function]"
717 (defsubst-maybe event-to-character (event)
718 "Return the character approximation to the given event object.
719 If the event isn't a keypress, this returns nil.
720 \[XEmacs emulating function]"
721 (cond ((symbolp event)
722 ;; mask is (BASE-TYPE MODIFIER-BITS) or nil.
723 (let ((mask (get event 'event-symbol-element-mask)))
725 (let ((base (get (car mask) 'ascii-character)))
727 (logior base (car (cdr mask)))
729 ((integerp event) event)))
733 ;;; @ MULE 2 emulation
736 (defun-maybe-cond cancel-undo-boundary ()
737 "Cancel undo boundary. [MULE 2.3 emulating function]"
738 ((boundp 'buffer-undo-list)
739 ;; for Emacs 19.7 or later
740 (if (and (consp buffer-undo-list)
742 (null (car buffer-undo-list)))
743 (setq buffer-undo-list (cdr buffer-undo-list))
746 ;; for anything older than Emacs 19.7.