Mercurial > hg > xemacs-beta
comparison lisp/utils/edmacro.el @ 136:b980b6286996 r20-2b2
Import from CVS: tag r20-2b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:31:12 +0200 |
parents | 34a5b81f86ba |
children | 59463afc5666 |
comparison
equal
deleted
inserted
replaced
135:4636a6841cd6 | 136:b980b6286996 |
---|---|
3 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Dave Gillespie <daveg@synaptics.com> | 5 ;; Author: Dave Gillespie <daveg@synaptics.com> |
6 ;; Hrvoje Niksic <hniksic@srce.hr> -- XEmacs port | 6 ;; Hrvoje Niksic <hniksic@srce.hr> -- XEmacs port |
7 ;; Maintainer: Hrvoje Niksic <hniksic@srce.hr> | 7 ;; Maintainer: Hrvoje Niksic <hniksic@srce.hr> |
8 ;; Version: 3.09 | 8 ;; Version: 3.10 |
9 ;; Keywords: abbrev | 9 ;; Keywords: abbrev |
10 | 10 |
11 ;; This file is part of XEmacs. | 11 ;; This file is part of XEmacs. |
12 | 12 |
13 ;; XEmacs is free software; you can redistribute it and/or modify | 13 ;; XEmacs is free software; you can redistribute it and/or modify |
24 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 24 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
26 ;; 02111-1307, USA. | 26 ;; 02111-1307, USA. |
27 | 27 |
28 ;;; Synched up with: FSF 19.34. | 28 ;;; Synched up with: FSF 19.34. |
29 ;;; The important parts of this file have been rewritten for XEmacs, | |
30 ;;; so it's completely different from the FSF version. The original | |
31 ;;; could not be used because it worked with the Emacs key | |
32 ;;; representation, and it mixed characters and integers too freely. | |
29 | 33 |
30 ;;; Commentary: | 34 ;;; Commentary: |
31 | 35 |
32 ;;; Usage: | 36 ;;; Usage: |
33 ;; | 37 ;; |
52 ;; Also, the `read-kbd-macro' command parses the region as | 56 ;; Also, the `read-kbd-macro' command parses the region as |
53 ;; a keyboard macro, and installs it as the "current" macro. | 57 ;; a keyboard macro, and installs it as the "current" macro. |
54 ;; This and `format-kbd-macro' can also be called directly as | 58 ;; This and `format-kbd-macro' can also be called directly as |
55 ;; Lisp functions. | 59 ;; Lisp functions. |
56 | 60 |
57 ;; The `kbd' function is a shorter name for `read-kbd-macro'. It is | 61 ;; The `kbd' macro is a shorter-named and more efficient form of |
58 ;; good to use in your programs and initializations, as you needn't | 62 ;; `read-kbd-macro'. Unlike `read-kbd-macro', it is evaluated at |
59 ;; know the internal keysym representation. For example: | 63 ;; read-time, and doesn't bring any overhead to compiled programs. It |
64 ;; is recommended to use in your programs and initializations, as you | |
65 ;; needn't know the internal keysym representation. For example: | |
60 ;; | 66 ;; |
61 ;; (define-key foo-mode-map (kbd "C-c <up>") 'foo-up) | 67 ;; (define-key foo-mode-map (kbd "C-c <up>") 'foo-up) |
62 ;; | 68 ;; |
63 ;; is the equivalent of | 69 ;; is the exact equivalent of |
64 ;; | 70 ;; |
65 ;; (define-key foo-mode-map [(control ?c) up] 'foo-up) | 71 ;; (define-key foo-mode-map [(control ?c) up] 'foo-up) |
66 ;; | 72 ;; |
67 | 73 |
68 ;; Type `C-h m', or see the documentation for `edmacro-mode' below, | 74 ;; Type `C-h m', or see the documentation for `edmacro-mode' below, |
224 (if (stringp start) | 230 (if (stringp start) |
225 (edmacro-parse-keys start end) | 231 (edmacro-parse-keys start end) |
226 (setq last-kbd-macro (edmacro-parse-keys (buffer-substring start end))))) | 232 (setq last-kbd-macro (edmacro-parse-keys (buffer-substring start end))))) |
227 | 233 |
228 ;;;###autoload | 234 ;;;###autoload |
229 (defun kbd (keys) | 235 (defmacro kbd (keys) |
230 "Convert KEYS to the internal Emacs key representation." | 236 "Convert KEYS to the internal Emacs key representation." |
231 (read-kbd-macro keys)) | 237 (read-kbd-macro keys)) |
232 | 238 |
233 ;;;###autoload | 239 ;;;###autoload |
234 (defun format-kbd-macro (&optional macro verbose) | 240 (defun format-kbd-macro (&optional macro verbose) |
368 the words described below, the characters of each word go directly | 374 the words described below, the characters of each word go directly |
369 as characters of the macro. The whitespace that separates words | 375 as characters of the macro. The whitespace that separates words |
370 is ignored. Whitespace in the macro must be written explicitly, | 376 is ignored. Whitespace in the macro must be written explicitly, |
371 as in \"foo SPC bar RET\". | 377 as in \"foo SPC bar RET\". |
372 | 378 |
373 * The special words RET, SPC, TAB, DEL, LFD, ESC, and NUL represent | 379 * The special words RET, SPC, TAB, DEL, BS, LFD, ESC, and NUL represent |
374 special control characters. The words must be written in uppercase. | 380 special control characters. The words must be written in uppercase. |
375 | 381 |
376 * A word in angle brackets, e.g., <return>, <down>, or <f1>, represents | 382 * A word in angle brackets, e.g., <return>, <down>, or <f1>, represents |
377 a function key. (Note that in the standard configuration, the | 383 a function key. (Note that in the standard configuration, the |
378 function key <return> and the control key RET are synonymous.) | 384 function key <return> and the control key RET are synonymous.) |
420 (defun edmacro-int-char (int) | 426 (defun edmacro-int-char (int) |
421 (if (fboundp 'char-to-int) | 427 (if (fboundp 'char-to-int) |
422 (char-to-int int) | 428 (char-to-int int) |
423 int)) | 429 int)) |
424 | 430 |
425 ;;; Formatting a keyboard macro as human-readable text. | 431 |
432 ;;; Parsing a human-readable keyboard macro. | |
426 | 433 |
427 ;; Changes for XEmacs -- these two functions re-written from scratch. | 434 ;; Changes for XEmacs -- these two functions re-written from scratch. |
428 ;; edmacro-parse-keys always returns a vector. edmacro-format-keys | 435 ;; edmacro-parse-keys always returns a vector. edmacro-format-keys |
429 ;; accepts a vector (but works with a string too). Vector may contain | 436 ;; accepts a vector (but works with a string too). Vector may contain |
430 ;; keypress events. -hniksic | 437 ;; keypress events. -hniksic |
431 (defun edmacro-parse-keys (string &optional ignored) | 438 (defun edmacro-parse-keys (string &optional ignored) |
432 (let* ((pos 0) | 439 (let* ((pos 0) |
433 (case-fold-search nil) | 440 (case-fold-search nil) |
434 (word-to-sym '(("NUL" . (control space)) | 441 (word-to-sym '(("NUL" . ?\0) |
435 ("RET" . return) | 442 ("RET" . return) |
436 ("LFD" . linefeed) | 443 ("LFD" . linefeed) |
437 ("TAB" . tab) | 444 ("TAB" . tab) |
438 ("ESC" . escape) | 445 ("ESC" . escape) |
439 ("SPC" . space) | 446 ("SPC" . space) |
673 (setq keys (cdr keys))) | 680 (setq keys (cdr keys))) |
674 (if (keymapp lookup) | 681 (if (keymapp lookup) |
675 (setq new (nconc new k))) | 682 (setq new (nconc new k))) |
676 new)) | 683 new)) |
677 | 684 |
685 ;;; Formatting a keyboard macro as human-readable text. | |
686 | |
678 (defun edmacro-format-keys (macro &optional verbose) | 687 (defun edmacro-format-keys (macro &optional verbose) |
679 ;; XEmacs: | 688 ;; XEmacs: |
680 ;; If we're dealing with events, convert them to symbols first. | 689 ;; If we're dealing with events, convert them to symbols first. |
681 (setq macro (edmacro-events-to-keys macro)) | 690 (setq macro (edmacro-events-to-keys macro)) |
682 (if (zerop (length macro)) | 691 (if (zerop (length macro)) |
776 (t | 785 (t |
777 (error "Macros with mouse clicks are not %s" | 786 (error "Macros with mouse clicks are not %s" |
778 "supported by this command")))) | 787 "supported by this command")))) |
779 (incf i)))) | 788 (incf i)))) |
780 macro) | 789 macro) |
781 | |
782 ;;; Parsing a human-readable keyboard macro. | |
783 | |
784 | 790 |
785 | 791 |
786 ;;; The following probably ought to go in macros.el: | 792 ;;; The following probably ought to go in macros.el: |
787 | 793 |
788 ;;;###autoload | 794 ;;;###autoload |