emacs-devel
[Top][All Lists]
Advanced

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

Re: POLL: make C-x o transient


From: Juri Linkov
Subject: Re: POLL: make C-x o transient
Date: Wed, 27 Jan 2021 19:55:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>>> Which will make `C-x o` invoke a transient version of `other-window'
>>> like `text-scale-adjust’ does.
>>
>> I think the pattern is clear: `C-x <letter>` are good candidates ;-)
>
> And non-letters too, especially `C-x {`, `C-x }`, `C-x ^`, ...
> need to be repeatable.  I'm using such quite messy blob of code,
> it would be nice if someone would generalize this mess
> without using advice-add.

Maybe something simple like:

#+begin_src emacs-lisp
(put 'other-window 'repeatable-command t)
(put 'enlarge-window 'repeatable-command t)
(put 'enlarge-window-horizontally 'repeatable-command t)
(put 'shrink-window-horizontally 'repeatable-command t)

(add-hook 'post-command-hook 'repeatable-command)

(defun repeatable-command ()
  (when (get this-command 'repeatable-command)
    (let* ((keys (this-single-command-keys))
           (last-key (elt keys (1- (length keys)))))
      (set-transient-map
       (let ((map (make-sparse-keymap)))
         (define-key map (vector last-key) this-command)
         map)))))
#+end_src



reply via email to

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