summaryrefslogtreecommitdiff
path: root/lisp/kmacro.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2021-05-18 10:37:57 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2021-05-18 10:37:57 -0400
commit6a7e503ccaf7ccdc47916fa12012ae19b30a016c (patch)
tree9a3dff9bf1adef0c63337b96be8176eea9be73e9 /lisp/kmacro.el
parent2c90aa93a9d4d53c090dbb8a33501fa4e8cefc64 (diff)
downloademacs-6a7e503ccaf7ccdc47916fa12012ae19b30a016c.tar.gz
* lisp/kmacro.el: Fix test cases broken by last change
(kmacro-lambda-form): Remove unused args `counter` and `format`. Arrange to be able to extract `mac` from the function. (kmacro-extract-lambda): Use this new extraction instead of digging into the guts of a function's code.
Diffstat (limited to 'lisp/kmacro.el')
-rw-r--r--lisp/kmacro.el34
1 files changed, 21 insertions, 13 deletions
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index 4e92277d0f7..3700a1964a6 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -782,24 +782,32 @@ If kbd macro currently being defined end it before activating it."
;; executing the macro later on (but that's controversial...)
;;;###autoload
-(defun kmacro-lambda-form (mac &optional counter format)
+(defun kmacro-lambda-form (mac)
"Create lambda form for macro bound to symbol or key."
- (let ((mac (if counter (list mac counter format) mac)))
- (lambda (&optional arg)
- "Keyboard macro."
- (interactive "p")
+ ;; FIXME: This should be a "funcallable struct"!
+ (lambda (&optional arg)
+ "Keyboard macro."
+ ;; We put an "unused prompt" as a special marker so
+ ;; `kmacro-extract-lambda' can see it's "one of us".
+ (interactive "pkmacro")
+ (if (eq arg 'kmacro--extract-lambda)
+ (cons 'kmacro--extract-lambda mac)
(kmacro-exec-ring-item mac arg))))
(defun kmacro-extract-lambda (mac)
"Extract kmacro from a kmacro lambda form."
- (and (eq (car-safe mac) 'lambda)
- (setq mac (assoc 'kmacro-exec-ring-item mac))
- (setq mac (car-safe (cdr-safe (car-safe (cdr-safe mac)))))
- (listp mac)
- (= (length mac) 3)
- (arrayp (car mac))
- mac))
-
+ (let ((mac (cond
+ ((eq (car-safe mac) 'lambda)
+ (let ((e (assoc 'kmacro-exec-ring-item mac)))
+ (car-safe (cdr-safe (car-safe (cdr-safe e))))))
+ ((and (functionp mac)
+ (equal (interactive-form mac) '(interactive "pkmacro")))
+ (let ((r (funcall mac 'kmacro--extract-lambda)))
+ (and (eq (car-safe r) 'kmacro--extract-lambda) (cdr r)))))))
+ (and (consp mac)
+ (= (length mac) 3)
+ (arrayp (car mac))
+ mac)))
(defalias 'kmacro-p #'kmacro-extract-lambda
"Return non-nil if MAC is a kmacro keyboard macro.")