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

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

Re: Can I use 'C-x o o o o o' instead of C-x o C-x o C-x o C-x o C-x o?


From: Jorge A. Alfaro-Murillo
Subject: Re: Can I use 'C-x o o o o o' instead of C-x o C-x o C-x o C-x o C-x o?
Date: Tue, 28 Apr 2015 10:22:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Jorge A. Alfaro-Murillo writes:

張國良 writes:
Scenario 1 - I split many windows. - I wish to switch to some other windows. - I type C-x o, C-x o, C-x o repeatedly until the cursor landed on the desired window. Is there a way to use C-x o o o instead? I aware that I can use C-u num C-x o, if I know the desired window is num step away. But there are times that I do not know 'num'. Scenario 2 - I use the windmove package. - I bind the windmove-up/down/left/right to C-o i, C-o k, C-o j, C-o l respectively. Now, if I want to windmove to up-left, I type C-o i, C-o j. Is there a way to use C-o i j instead?

You could try something like: #+BEGIN_SRC emacs-lisp (defvar your-extended-keymap (make-sparse-keymap)) (define-key your-extended-keymap (kbd "o") 'other-window) (advice-add 'other-window :after (lambda () (set-transient-map your-extended-keymap))) #+END_SRC

Sorry, I hit send before finishing, this works:

#+BEGIN_SRC emacs-lisp
 (defvar your-extended-keymap (make-sparse-keymap))
 (define-key your-extended-keymap (kbd "o") 'your-other-window)
 (defun your-other-window ()
   (interactive)
   (other-window 1)
(set-transient-map your-extended-keymap)) (global-set-key (kbd "C-x o") 'your-other-window) #+END_SRC

But as Tassilo said, you probably do not want this. Check ace-window (https://github.com/abo-abo/ace-window) which solves both scenarios very elegantly.

Best,
--
Jorge.




reply via email to

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