Function: kmacro-menu-transpose
kmacro-menu-transpose is an interactive and byte-compiled function
defined in kmacro.el.gz.
Signature
(kmacro-menu-transpose)
Documentation
Swap the keyboard macro at point with the one above, then move to the next line.
If point is on the first line (position number 0), then swap the macros at position numbers 0 and 1, then move point to the third line.
Note that this is the earlier position in the ring, not the sorted table.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/kmacro.el.gz
(defun kmacro-menu-transpose ()
"Swap the keyboard macro at point with the one above, then move to the next line.
If point is on the first line (position number 0), then swap the macros
at position numbers 0 and 1, then move point to the third line.
Note that this is the earlier position in the ring, not the sorted
table."
(declare (modes kmacro-menu-mode))
(interactive nil kmacro-menu-mode)
(let ((id (tabulated-list-get-id)))
(kmacro-menu--assert-row id)
(kmacro-menu--query-revert)
(let* ((old-pos (kmacro-menu--id-position id))
(first-line (= 0 old-pos))
(end-lines-forward (if first-line
2
(+ 3 old-pos))))
;; When transposing the first two macros, we don't use
;; `kmacro-swap-ring' here because it is possible for the user to
;; choose to not refresh the table when it is out of date.
(kmacro-menu--replace-all
(let ((res))
(kmacro-menu--map-ids
(if first-line
(let ((old-km (kmacro-menu--id-kmacro id)))
(lambda (this-id)
(let ((this-pos (kmacro-menu--id-position this-id)))
(unless (= 0 this-pos)
(push (kmacro-menu--id-kmacro this-id) res)
(when (= 1 this-pos)
(push old-km res))))))
(let ((new-pos (1- old-pos)))
(lambda (this-id)
(let ((this-pos (kmacro-menu--id-position this-id)))
(unless (= old-pos this-pos)
(when (= new-pos this-pos)
(push (kmacro-menu--id-kmacro id) res))
(push (kmacro-menu--id-kmacro this-id) res)))))))
(nreverse res)))
(tabulated-list-revert)
(goto-char (point-min))
(forward-line end-lines-forward))))