Emacs personal configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 satır
2.8KB

  1. ;;----------------------------------------------------------------------------
  2. ;; Navigate window layouts with "C-c <left>" and "C-c <right>"
  3. ;;----------------------------------------------------------------------------
  4. (winner-mode 1)
  5. ;; Make "C-x o" prompt for a target window when there are more than 2
  6. (require-package 'switch-window)
  7. (require 'switch-window)
  8. ;;(setq switch-window-shortcut-style 'alphabet)
  9. (setq switch-window-shortcut-style 'qwerty)
  10. (global-set-key (kbd "C-x o") 'switch-window)
  11. ;;----------------------------------------------------------------------------
  12. ;; When splitting window, show (other-buffer) in the new window
  13. ;;----------------------------------------------------------------------------
  14. (defun split-window-func-with-other-buffer (split-function)
  15. (lexical-let ((s-f split-function))
  16. (lambda ()
  17. (interactive)
  18. (funcall s-f)
  19. (set-window-buffer (next-window) (other-buffer)))))
  20. (global-set-key "\C-x2" (split-window-func-with-other-buffer 'split-window-vertically))
  21. (global-set-key "\C-x3" (split-window-func-with-other-buffer 'split-window-horizontally))
  22. (defun sanityinc/toggle-delete-other-windows ()
  23. "Delete other windows in frame if any, or restore previous window config."
  24. (interactive)
  25. (if (and winner-mode
  26. (equal (selected-window) (next-window)))
  27. (winner-undo)
  28. (delete-other-windows)))
  29. (global-set-key "\C-x1" 'sanityinc/toggle-delete-other-windows)
  30. ;;----------------------------------------------------------------------------
  31. ;; Rearrange split windows
  32. ;;----------------------------------------------------------------------------
  33. (defun split-window-horizontally-instead ()
  34. (interactive)
  35. (save-excursion
  36. (delete-other-windows)
  37. (funcall (split-window-func-with-other-buffer 'split-window-horizontally))))
  38. (defun split-window-vertically-instead ()
  39. (interactive)
  40. (save-excursion
  41. (delete-other-windows)
  42. (funcall (split-window-func-with-other-buffer 'split-window-vertically))))
  43. (global-set-key "\C-x|" 'split-window-horizontally-instead)
  44. (global-set-key "\C-x_" 'split-window-vertically-instead)
  45. ;; Borrowed from http://postmomentum.ch/blog/201304/blog-on-emacs
  46. (defun sanityinc/split-window()
  47. "Split the window to see the most recent buffer in the other window.
  48. Call a second time to restore the original window configuration."
  49. (interactive)
  50. (if (eq last-command 'sanityinc/split-window)
  51. (progn
  52. (jump-to-register :sanityinc/split-window)
  53. (setq this-command 'sanityinc/unsplit-window))
  54. (window-configuration-to-register :sanityinc/split-window)
  55. (switch-to-buffer-other-window nil)))
  56. (global-set-key (kbd "<f7>") 'sanityinc/split-window)
  57. (global-set-key (kbd "<f6>")
  58. (lambda ()
  59. (interactive)
  60. (switch-to-buffer nil)))
  61. (provide 'init-windows)