[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: POLL: make C-x o transient
From: |
Omar Polo |
Subject: |
Re: POLL: make C-x o transient |
Date: |
Mon, 25 Jan 2021 18:21:43 +0100 |
User-agent: |
mu4e 1.4.13; emacs 28.0.50 |
Juri Linkov <juri@linkov.net> writes:
>>> 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.
FWIW, I completely agree, and I'm using various hydras to achieve the
same
(defhydra hydra-other-window (global-map "C-x")
("o" other-window "next window")
("O" (other-window -1) "previous window"))
(defhydra hydra-grep-like (global-map "M-g")
("n" next-error "next")
("p" previous-error "prev")
("RET" nil :exit t)
("q" nil :exit t))
(defhydra hydra-windowsize (global-map "C-x")
("{" shrink-window-horizontally)
("}" enlarge-window-horizontally))
(defhydra hydra-pages (global-map "C-x" :hint nil)
("[" backward-page)
("]" forward-page)
("RET" nil :exit t)
("q" nil :exit t))
(defhydra hydra-hscroll (global-map "C-x" :hint nil)
(">" scroll-left)
("<" scroll-right))
> #+begin_src emacs-lisp
> (defvar window-command-keymap
> (let ((map (make-sparse-keymap)))
> ;; Standard keys:
> (define-key map "0" 'delete-window)
> (define-key map "1" 'delete-other-windows)
> (define-key map "2" 'split-window-below)
> (define-key map "3" 'split-window-right)
> (define-key map "o" 'other-window)
> (define-key map "^" 'enlarge-window)
> (define-key map "}" 'enlarge-window-horizontally)
> (define-key map "{" 'shrink-window-horizontally)
> (define-key map "-" 'shrink-window-if-larger-than-buffer)
> (define-key map "+" 'balance-windows)
> ;; Additional keys:
> (define-key map "v" 'shrink-window)
> (define-key map [down] 'shrink-window)
> (define-key map [up] 'enlarge-window)
> (define-key map [left] 'shrink-window-horizontally)
> (define-key map [right] 'enlarge-window-horizontally)
> map)
> "Keymap for commands that operate on windows.")
>
> (advice-add 'enlarge-window-horizontally
> :after (lambda (&rest _args)
> (set-transient-map window-command-keymap)))
> (advice-add 'shrink-window-horizontally
> :after (lambda (&rest _args)
> (set-transient-map window-command-keymap)))
> (advice-add 'enlarge-window
> :after (lambda (&rest _args)
> (set-transient-map window-command-keymap)))
> (advice-add 'shrink-window
> :after (lambda (&rest _args)
> (set-transient-map window-command-keymap)))
> (defun window-command-prefix ()
> (interactive)
> (message "Use window prefix keys...")
> (set-transient-map window-command-keymap))
> (define-key ctl-x-map "wr" window-command-prefix)
>
> ;; (define-key window-command-keymap [digit-argument] 'ignore)
> ;; (define-key window-command-keymap [universal-argument] 'ignore)
> ;; (define-key window-command-keymap [?\C-u] 'universal-argument)
> #+end_src
- Re: POLL: make C-x o transient, (continued)
- Re: POLL: make C-x o transient, Stefan Monnier, 2021/01/25
- Re: POLL: make C-x o transient, aitor, 2021/01/25
- Re: POLL: make C-x o transient, Philip K., 2021/01/25
- Re: POLL: make C-x o transient, Colin Baxter, 2021/01/25
- Re: POLL: make C-x o transient, Richard Stallman, 2021/01/26
- Re: POLL: make C-x o transient, Olivier Certner, 2021/01/26
- Re: POLL: make C-x o transient, Sean Whitton, 2021/01/26
- Re: POLL: make C-x o transient, Colin Baxter, 2021/01/27
RE: [External] : Re: POLL: make C-x o transient, Drew Adams, 2021/01/25
Re: POLL: make C-x o transient, Juri Linkov, 2021/01/25
Re: POLL: make C-x o transient, martin rudalics, 2021/01/28
Re: POLL: make C-x o transient, Juri Linkov, 2021/01/28
Re: POLL: make C-x o transient, Gregory Heytings, 2021/01/28
Re: POLL: make C-x o transient, Kévin Le Gouguec, 2021/01/28
Re: POLL: make C-x o transient, Gregory Heytings, 2021/01/28
Re: POLL: make C-x o transient, Alan Mackenzie, 2021/01/28
Re: POLL: make C-x o transient, Philip K., 2021/01/28