code_junkie

Emacs, switch active window

Nov 10th, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. (global-set-key (kbd "C-x <up>") 'windmove-up)
  2. (global-set-key (kbd "C-x <down>") 'windmove-down)
  3. (global-set-key (kbd "C-x <right>") 'windmove-right)
  4. (global-set-key (kbd "C-x <left>") 'windmove-left)
  5.  
  6. ;; Windows Cycling
  7. (defun windmove-up-cycle()
  8. (interactive)
  9. (condition-case nil (windmove-up)
  10. (error (condition-case nil (windmove-down)
  11. (error (condition-case nil (windmove-right) (error (condition-case nil (windmove-left) (error (windmove-up))))))))))
  12.  
  13. (defun windmove-down-cycle()
  14. (interactive)
  15. (condition-case nil (windmove-down)
  16. (error (condition-case nil (windmove-up)
  17. (error (condition-case nil (windmove-left) (error (condition-case nil (windmove-right) (error (windmove-down))))))))))
  18.  
  19. (defun windmove-right-cycle()
  20. (interactive)
  21. (condition-case nil (windmove-right)
  22. (error (condition-case nil (windmove-left)
  23. (error (condition-case nil (windmove-up) (error (condition-case nil (windmove-down) (error (windmove-right))))))))))
  24.  
  25. (defun windmove-left-cycle()
  26. (interactive)
  27. (condition-case nil (windmove-left)
  28. (error (condition-case nil (windmove-right)
  29. (error (condition-case nil (windmove-down) (error (condition-case nil (windmove-up) (error (windmove-left))))))))))
  30.  
  31. (global-set-key (kbd "C-x <up>") 'windmove-up-cycle)
  32. (global-set-key (kbd "C-x <down>") 'windmove-down-cycle)
  33. (global-set-key (kbd "C-x <right>") 'windmove-right-cycle)
  34. (global-set-key (kbd "C-x <left>") 'windmove-left-cycle)
Add Comment
Please, Sign In to add comment