diff options
author | Kim F. Storm <storm@cua.dk> | 2004-09-30 13:27:45 +0000 |
---|---|---|
committer | Kim F. Storm <storm@cua.dk> | 2004-09-30 13:27:45 +0000 |
commit | 424e6532c86e9b5eb783bc68082ceede21a59329 (patch) | |
tree | 6a0c7efe477214d6c76e00c5f10f5b4c66384704 /lisp/kmacro.el | |
parent | 70e2ea115f807a4f8f7cc6bff538734c7b622290 (diff) | |
download | emacs-424e6532c86e9b5eb783bc68082ceede21a59329.tar.gz |
(kmacro-lambda-form, kmacro-extract-lambda): Add.
(kmacro-bind-to-key, kmacro-name-last-macro): Use kmacro-lambda-form.
Diffstat (limited to 'lisp/kmacro.el')
-rw-r--r-- | lisp/kmacro.el | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/lisp/kmacro.el b/lisp/kmacro.el index 5aefe46625d..b2226d4a895 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -740,6 +740,30 @@ If kbd macro currently being defined end it before activating it." ;; letters and digits, provided that we inhibit the keymap while ;; executing the macro later on (but that's controversial...) +(defun kmacro-lambda-form (mac &optional counter format) + "Create lambda form for macro bound to symbol or key." + (if counter + (setq mac (list mac counter format))) + `(lambda (&optional arg) + "Keyboard macro." + (interactive "p") + (kmacro-exec-ring-item ',mac arg))) + +(defun kmacro-extract-lambda (mac) + "Extract kmacro from a kmacro lambda form." + (and (consp mac) + (eq (car mac) 'lambda) + (setq mac (assoc 'kmacro-exec-ring-item mac)) + (consp (cdr mac)) + (consp (car (cdr mac))) + (consp (cdr (car (cdr mac)))) + (setq mac (car (cdr (car (cdr mac))))) + (listp mac) + (= (length mac) 3) + (arrayp (car mac)) + mac)) + + (defun kmacro-bind-to-key (arg) "When not defining or executing a macro, offer to bind last macro to a key. The key sequences [C-x C-k 0] through [C-x C-k 9] and [C-x C-k A] @@ -775,10 +799,7 @@ may be shaded by a local key binding." (format-kbd-macro key-seq) cmd)))) (define-key global-map key-seq - `(lambda (&optional arg) - "Keyboard macro." - (interactive "p") - (kmacro-exec-ring-item ',(kmacro-ring-head) arg))) + (kmacro-lambda-form (kmacro-ring-head))) (message "Keyboard macro bound to %s" (format-kbd-macro key-seq)))))) @@ -798,11 +819,7 @@ Such a \"function\" cannot be called from Lisp, but it is a valid editor command symbol)) (if (string-equal symbol "") (error "No command name given")) - (fset symbol - `(lambda (&optional arg) - "Keyboard macro." - (interactive "p") - (kmacro-exec-ring-item ',(kmacro-ring-head) arg))) + (fset symbol (kmacro-lambda-form (kmacro-ring-head))) (put symbol 'kmacro t)) |