diff options
author | Richard M. Stallman <rms@gnu.org> | 1992-10-23 09:38:44 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1992-10-23 09:38:44 +0000 |
commit | 45ca32a63ded7eefdb3e871430e1b2d679746401 (patch) | |
tree | ec8d19dce5c29453bbbe77cc5dc3c4d15750757c /lisp/macros.el | |
parent | b4b3b736039138f81c825f92eb124b5878abf5f0 (diff) | |
download | emacs-45ca32a63ded7eefdb3e871430e1b2d679746401.tar.gz |
(insert-kbd-macros): If arg is empty, use last macro as default.
Diffstat (limited to 'lisp/macros.el')
-rw-r--r-- | lisp/macros.el | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/lisp/macros.el b/lisp/macros.el index 4344a04f306..b0673db2824 100644 --- a/lisp/macros.el +++ b/lisp/macros.el @@ -1,6 +1,6 @@ ;;; macros.el --- non-primitive commands for keyboard macros. -;; Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc. +;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc. ;; Maintainer: FSF @@ -52,42 +52,48 @@ bindings. To save a kbd macro, visit a file of Lisp code such as your `~/.emacs', use this command, and then save the file." (interactive "CInsert kbd macro (name): \nP") - (insert "(fset '") - (prin1 macroname (current-buffer)) - (insert "\n ") - (let ((beg (point)) end) - (prin1 (symbol-function macroname) (current-buffer)) - (setq end (point-marker)) - (goto-char beg) - (while (< (point) end) - (let ((char (following-char))) - (cond ((< char 32) - (delete-region (point) (1+ (point))) - (insert "\\C-" (+ 96 char))) - ((< char 127) - (forward-char 1)) - ((= char 127) - (delete-region (point) (1+ (point))) - (insert "\\C-?")) - ((< char 160) - (delete-region (point) (1+ (point))) - (insert "\\M-C-" (- char 32))) - ((< char 255) - (delete-region (point) (1+ (point))) - (insert "\\M-" (- char 128))) - ((= char 255) - (delete-region (point) (1+ (point))) - (insert "\\M-C-?")))))) - (insert ")\n") - (if keys - (let ((keys (where-is-internal macroname nil))) - (while keys - (insert "(global-set-key ") - (prin1 (car keys) (current-buffer)) - (insert " '") - (prin1 macroname (current-buffer)) - (insert ")\n") - (setq keys (cdr keys)))))) + (let (definition) + (if (string= (symbol-name macroname) "") + (progn + (setq macroname 'last-kbd-macro definition last-kbd-macro) + (insert "(setq ")) + (setq definition (symbol-function macroname)) + (insert "(fset '")) + (prin1 macroname (current-buffer)) + (insert "\n ") + (let ((beg (point)) end) + (prin1 definition (current-buffer)) + (setq end (point-marker)) + (goto-char beg) + (while (< (point) end) + (let ((char (following-char))) + (cond ((< char 32) + (delete-region (point) (1+ (point))) + (insert "\\C-" (+ 96 char))) + ((< char 127) + (forward-char 1)) + ((= char 127) + (delete-region (point) (1+ (point))) + (insert "\\C-?")) + ((< char 160) + (delete-region (point) (1+ (point))) + (insert "\\M-C-" (- char 32))) + ((< char 255) + (delete-region (point) (1+ (point))) + (insert "\\M-" (- char 128))) + ((= char 255) + (delete-region (point) (1+ (point))) + (insert "\\M-C-?")))))) + (insert ")\n") + (if keys + (let ((keys (where-is-internal macroname nil))) + (while keys + (insert "(global-set-key ") + (prin1 (car keys) (current-buffer)) + (insert " '") + (prin1 macroname (current-buffer)) + (insert ")\n") + (setq keys (cdr keys))))))) ;;;###autoload (defun kbd-macro-query (flag) |