1

When I am defining keyboard macro with kmacro-start-macro and I press C-g (for example to deactivate mark or I press it accidentally), macro definition is aborted and I have to start over. Is there any way to disable this behavior?

2

You could write some function like this, to only run keyboard-quit if no macro is running, and bind to C-g:

(defun keyboard-quit-only-if-no-macro ()
  (interactive)
  (if defining-kbd-macro
      (progn
        (if (region-active-p)
            (deactivate-mark)
          (message "Macro running. Can't quit.")))

    (keyboard-quit)))

(define-key global-map (kbd "C-g") 'keyboard-quit-only-if-no-macro)
  • I was hoping there would be some variable to set to make this simpler. It seems that it's very basic and should be customizable but I looked at definition at keyboard-quit and quitting macros is hardcoded there. – mkcms Mar 16 '18 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.