Function: kmacro-menu-do-delete

kmacro-menu-do-delete is an interactive and byte-compiled function defined in kmacro.el.gz.

Signature

(kmacro-menu-do-delete)

Documentation

Delete macros in the region, those with markers, or the one at point.

If there's an active region, delete macros in the region; otherwise delete the marked macros or, if there are no marks, the macro on the current line.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/kmacro.el.gz
(defun kmacro-menu-do-delete ()
  "Delete macros in the region, those with markers, or the one at point.

If there's an active region, delete macros in the region; otherwise
delete the marked macros or, if there are no marks, the macro on the
current line."
  (declare (modes kmacro-menu-mode))
  (interactive nil kmacro-menu-mode)
  (kmacro-menu--query-revert)
  (let ((num-deletes 0)
        (id-alist (if (or (use-region-p)
                          (not (kmacro-menu--marks-exist-p)))
                      (let ((region-alist))
                        (kmacro-menu--do-region
                         (lambda (id)
                           (push (cons (kmacro-menu--id-position id)
                                       t)
                                 region-alist)))
                        region-alist)
                    kmacro-menu--marks)))
    (let ((res))
      (kmacro-menu--map-ids (lambda (id)
                              (if (alist-get (kmacro-menu--id-position id)
                                             id-alist)
                                  (setq num-deletes (1+ num-deletes))
                                (push (kmacro-menu--id-kmacro id) res))))
      (when (yes-or-no-p (if (= 1 num-deletes)
                             "Delete 1 keyboard macro?"
                           (format "Delete %d keyboard macros?"
                                   num-deletes)))
        (kmacro-menu--replace-all (nreverse res))
        (tabulated-list-revert)))))