Function: kmacro-start-macro

kmacro-start-macro is an autoloaded, interactive and byte-compiled function defined in kmacro.el.gz.

Signature

(kmacro-start-macro ARG)

Documentation

Record subsequent keyboard input, defining a keyboard macro.

The commands are recorded even as they are executed. Use C-x ) (kmacro-end-macro) to finish recording and make the macro available. Use C-x e (kmacro-end-and-call-macro) to execute the macro.

Non-nil arg (prefix arg) means append to last macro defined.

With C-u (universal-argument) prefix, append to last keyboard macro defined. Depending on kmacro-execute-before-append, this may begin by re-executing the last macro as if you typed it again.

Otherwise, it sets kmacro-counter to ARG or 0 if missing before defining the macro.

Use C-x C-k TAB (kmacro-insert-counter) to insert (and increment) the macro counter. The counter value can be set or modified via C-x C-k C-c (kmacro-set-counter) and C-x C-k C-a (kmacro-add-counter). The format of the counter can be modified via C-x C-k C-f (kmacro-set-format).

Use C-x C-k n (kmacro-name-last-macro) to give it a name that will remain valid even after another macro is defined. Use C-x C-k b (kmacro-bind-to-key) to bind it to a key sequence.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/kmacro.el.gz
;;; Traditional bindings:


;;;###autoload
(defun kmacro-start-macro (arg)
  "Record subsequent keyboard input, defining a keyboard macro.
The commands are recorded even as they are executed.
Use \\[kmacro-end-macro] to finish recording and make the macro available.
Use \\[kmacro-end-and-call-macro] to execute the macro.

Non-nil arg (prefix arg) means append to last macro defined.

With \\[universal-argument] prefix, append to last keyboard macro
defined.  Depending on `kmacro-execute-before-append', this may begin
by re-executing the last macro as if you typed it again.

Otherwise, it sets `kmacro-counter' to ARG or 0 if missing before
defining the macro.

Use \\[kmacro-insert-counter] to insert (and increment) the macro counter.
The counter value can be set or modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
The format of the counter can be modified via \\[kmacro-set-format].

Use \\[kmacro-name-last-macro] to give it a name that will remain valid even
after another macro is defined.
Use \\[kmacro-bind-to-key] to bind it to a key sequence."
  (interactive "P")
  (if (or defining-kbd-macro executing-kbd-macro)
      (message "Already defining keyboard macro.")
    (let ((append (and arg (listp arg))))
      (unless append
	(if last-kbd-macro
	    (kmacro-push-ring))
	(setq kmacro-counter (or (if arg (prefix-numeric-value arg))
				 kmacro-initial-counter-value
				 0)
	      kmacro-initial-counter-value nil
	      kmacro-counter-value-start kmacro-counter
	      kmacro-last-counter kmacro-counter
	      kmacro-counter-format kmacro-default-counter-format
	      kmacro-counter-format-start kmacro-default-counter-format))

      (start-kbd-macro append
		       (and append
			    (if kmacro-execute-before-append
				(> (car arg) 4)
			      (= (car arg) 4))))
      (if (and defining-kbd-macro append)
	  (setq defining-kbd-macro 'append)))))