(defvar kmacro-view-item-no 0)
+(autoload 'macro--string-to-vector "macros")
(defun kmacro-ring-head ()
"Return pseudo head element in macro ring."
(and last-kbd-macro
- (kmacro last-kbd-macro kmacro-counter kmacro-counter-format-start)))
+ (kmacro (if (stringp last-kbd-macro)
+ (macro--string-to-vector last-kbd-macro)
+ last-kbd-macro)
+ kmacro-counter kmacro-counter-format-start)))
(defun kmacro-push-ring (&optional elt)
(setq mac (nth 0 mac)))
(when (stringp mac)
;; `kmacro' interprets a string according to `key-parse'.
- (require 'macros)
- (declare-function macro--string-to-vector "macros")
(setq mac (macro--string-to-vector mac)))
(kmacro mac counter format)))
(kmacro-tests-should-insert "bb"
(kmacro-tests-simulate-command '(kmacro-tests-symbol-for-test))))
+;; Bug#61700 inserting named macro when the definition contains things
+;; that `key-parse' thinks are named keys
+(kmacro-tests-deftest kmacro-tests-name-last-macro-key-parse-syntax ()
+ "Name last macro can rebind a symbol it binds."
+ ;; Make sure our symbol is unbound.
+ (when (fboundp 'kmacro-tests-symbol-for-test)
+ (fmakunbound 'kmacro-tests-symbol-for-test))
+ (setplist 'kmacro-tests-symbol-for-test nil)
+ (kmacro-tests-define-macro "<b> hello </>")
+ (kmacro-name-last-macro 'kmacro-tests-symbol-for-test)
+ ;; Now run the function bound to the symbol.
+ (kmacro-tests-should-insert "<b> hello </>"
+ (kmacro-tests-simulate-command '(kmacro-tests-symbol-for-test))))
+
(kmacro-tests-deftest kmacro-tests-store-in-register ()
"Macro can be stored in and retrieved from a register."
(use-local-map kmacro-tests-keymap)