aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2004-09-30 13:27:45 +0000
committerKim F. Storm2004-09-30 13:27:45 +0000
commit424e6532c86e9b5eb783bc68082ceede21a59329 (patch)
tree6a0c7efe477214d6c76e00c5f10f5b4c66384704
parent70e2ea115f807a4f8f7cc6bff538734c7b622290 (diff)
downloademacs-424e6532c86e9b5eb783bc68082ceede21a59329.tar.gz
emacs-424e6532c86e9b5eb783bc68082ceede21a59329.zip
(kmacro-lambda-form, kmacro-extract-lambda): Add.
(kmacro-bind-to-key, kmacro-name-last-macro): Use kmacro-lambda-form.
-rw-r--r--lisp/kmacro.el35
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."
740;; letters and digits, provided that we inhibit the keymap while 740;; letters and digits, provided that we inhibit the keymap while
741;; executing the macro later on (but that's controversial...) 741;; executing the macro later on (but that's controversial...)
742 742
743(defun kmacro-lambda-form (mac &optional counter format)
744 "Create lambda form for macro bound to symbol or key."
745 (if counter
746 (setq mac (list mac counter format)))
747 `(lambda (&optional arg)
748 "Keyboard macro."
749 (interactive "p")
750 (kmacro-exec-ring-item ',mac arg)))
751
752(defun kmacro-extract-lambda (mac)
753 "Extract kmacro from a kmacro lambda form."
754 (and (consp mac)
755 (eq (car mac) 'lambda)
756 (setq mac (assoc 'kmacro-exec-ring-item mac))
757 (consp (cdr mac))
758 (consp (car (cdr mac)))
759 (consp (cdr (car (cdr mac))))
760 (setq mac (car (cdr (car (cdr mac)))))
761 (listp mac)
762 (= (length mac) 3)
763 (arrayp (car mac))
764 mac))
765
766
743(defun kmacro-bind-to-key (arg) 767(defun kmacro-bind-to-key (arg)
744 "When not defining or executing a macro, offer to bind last macro to a key. 768 "When not defining or executing a macro, offer to bind last macro to a key.
745The key sequences [C-x C-k 0] through [C-x C-k 9] and [C-x C-k A] 769The 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."
775 (format-kbd-macro key-seq) 799 (format-kbd-macro key-seq)
776 cmd)))) 800 cmd))))
777 (define-key global-map key-seq 801 (define-key global-map key-seq
778 `(lambda (&optional arg) 802 (kmacro-lambda-form (kmacro-ring-head)))
779 "Keyboard macro."
780 (interactive "p")
781 (kmacro-exec-ring-item ',(kmacro-ring-head) arg)))
782 (message "Keyboard macro bound to %s" (format-kbd-macro key-seq)))))) 803 (message "Keyboard macro bound to %s" (format-kbd-macro key-seq))))))
783 804
784 805
@@ -798,11 +819,7 @@ Such a \"function\" cannot be called from Lisp, but it is a valid editor command
798 symbol)) 819 symbol))
799 (if (string-equal symbol "") 820 (if (string-equal symbol "")
800 (error "No command name given")) 821 (error "No command name given"))
801 (fset symbol 822 (fset symbol (kmacro-lambda-form (kmacro-ring-head)))
802 `(lambda (&optional arg)
803 "Keyboard macro."
804 (interactive "p")
805 (kmacro-exec-ring-item ',(kmacro-ring-head) arg)))
806 (put symbol 'kmacro t)) 823 (put symbol 'kmacro t))
807 824
808 825