help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to bind isearch-repeat-forward to F3 in a certain mode only?


From: Yuri Khan
Subject: Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
Date: Tue, 28 Jul 2015 22:15:09 +0600

On Tue, Jul 28, 2015 at 2:30 PM, Marcin Borkowski <mbork@mbork.pl> wrote:

> BTW, how do you guys use keyboard macros?  "C-x (", "C-x )" and "C-x e"
> are so inconvenient compared to F3 and F4...

I am a recent (≈8 years) migrant from a different be-all-end-all tool
on a different OS, and I’ve kept some habits.

So if I could figure out how to make the same C-. key start and end
macro recording, and immediately after stopping recording ask for a
key binding… hm, in fact I can.

===
(define-minor-mode yk-kmacro-mode
  "Record a keyboard macro and bind it to a key."
  :global t
  :init-value nil
  :lighter " ●"
  (if yk-kmacro-mode
      (kmacro-start-macro nil)
    ;; KLUDGE
    (let ((yk-kmacro-ring (cdr kmacro-ring)))
      (kmacro-end-macro nil)
      (when (eq yk-kmacro-ring kmacro-ring)
        (kmacro-push-ring)
        (setq last-kbd-macro "")))
    (kmacro-bind-to-key nil)))
(global-set-key (kbd "C-.") 'yk-kmacro-mode)
===

The kludge is there in order to remove macros when they are no longer
needed. It would be even better to restore the original binding (if
any) but that would basically require reimplementing
kmacro-bind-to-key.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]