740 |
;; letters and digits, provided that we inhibit the keymap while |
;; letters and digits, provided that we inhibit the keymap while |
741 |
;; executing the macro later on (but that's controversial...) |
;; executing the macro later on (but that's controversial...) |
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 |
|
|
767 |
(defun kmacro-bind-to-key (arg) |
(defun kmacro-bind-to-key (arg) |
768 |
"When not defining or executing a macro, offer to bind last macro to a key. |
"When not defining or executing a macro, offer to bind last macro to a key. |
769 |
The key sequences [C-x C-k 0] through [C-x C-k 9] and [C-x C-k A] |
The key sequences [C-x C-k 0] through [C-x C-k 9] and [C-x C-k A] |
799 |
(format-kbd-macro key-seq) |
(format-kbd-macro key-seq) |
800 |
cmd)))) |
cmd)))) |
801 |
(define-key global-map key-seq |
(define-key global-map key-seq |
802 |
`(lambda (&optional arg) |
(kmacro-lambda-form (kmacro-ring-head))) |
|
"Keyboard macro." |
|
|
(interactive "p") |
|
|
(kmacro-exec-ring-item ',(kmacro-ring-head) arg))) |
|
803 |
(message "Keyboard macro bound to %s" (format-kbd-macro key-seq)))))) |
(message "Keyboard macro bound to %s" (format-kbd-macro key-seq)))))) |
804 |
|
|
805 |
|
|
819 |
symbol)) |
symbol)) |
820 |
(if (string-equal symbol "") |
(if (string-equal symbol "") |
821 |
(error "No command name given")) |
(error "No command name given")) |
822 |
(fset symbol |
(fset symbol (kmacro-lambda-form (kmacro-ring-head))) |
|
`(lambda (&optional arg) |
|
|
"Keyboard macro." |
|
|
(interactive "p") |
|
|
(kmacro-exec-ring-item ',(kmacro-ring-head) arg))) |
|
823 |
(put symbol 'kmacro t)) |
(put symbol 'kmacro t)) |
824 |
|
|
825 |
|
|