init-gui-frames.el 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. (when (fboundp 'tool-bar-mode)
  2. (tool-bar-mode -1))
  3. (defun my/toggle-window-split ()
  4. (interactive)
  5. (if (= (count-windows) 2)
  6. (let* ((this-win-buffer (window-buffer))
  7. (next-win-buffer (window-buffer (next-window)))
  8. (this-win-edges (window-edges (selected-window)))
  9. (next-win-edges (window-edges (next-window)))
  10. (this-win-2nd (not (and (<= (car this-win-edges)
  11. (car next-win-edges))
  12. (<= (cadr this-win-edges)
  13. (cadr next-win-edges)))))
  14. (splitter
  15. (if (= (car this-win-edges)
  16. (car (window-edges (next-window))))
  17. 'split-window-horizontally
  18. 'split-window-vertically)))
  19. (delete-other-windows)
  20. (let ((first-win (selected-window)))
  21. (funcall splitter)
  22. (if this-win-2nd (other-window 1))
  23. (set-window-buffer (selected-window) this-win-buffer)
  24. (set-window-buffer (next-window) next-win-buffer)
  25. (select-window first-win)
  26. (if this-win-2nd (other-window 1))))))
  27. (with-eval-after-load 'evil
  28. (define-key evil-emacs-state-map (kbd "C-w h") 'windmove-down)
  29. (define-key evil-emacs-state-map (kbd "C-w t") 'windmove-up)
  30. (define-key evil-emacs-state-map (kbd "C-w n") 'windmove-left)
  31. (define-key evil-emacs-state-map (kbd "C-w s") 'windmove-right)
  32. (define-key evil-emacs-state-map (kbd "C-w C-t") 'my/toggle-window-split)
  33. (define-key evil-window-map (kbd "C-t") 'my/toggle-window-split)
  34. (define-key evil-emacs-state-map (kbd "C-w C-t") 'my/toggle-window-split)
  35. (evil-define-key 'emacs evil-normal-state-map (kbd "C-w h") 'windmove-down)
  36. (evil-define-key 'emacs evil-normal-state-map (kbd "C-w t") 'windmove-up)
  37. (evil-define-key 'emacs evil-normal-state-map (kbd "C-w n") 'windmove-left)
  38. (evil-define-key 'emacs evil-normal-state-map (kbd "C-w s") 'windmove-ri)
  39. (evil-define-key 'emacs evil-normal-state-map (kbd "C-w C-t") 'my/toggle-window-split)
  40. ;;I don't think this would ever really be useful
  41. (evil-define-key 'normal help-mode-map (kbd "C-w h") 'windmove-down)
  42. (evil-define-key 'normal help-mode-map (kbd "C-w t") 'windmove-up)
  43. (evil-define-key 'normal help-mode-map (kbd "C-w n") 'windmove-left)
  44. (evil-define-key 'normal help-mode-map (kbd "C-w s") 'windmove-right)
  45. (evil-define-key 'normal help-mode-map (kbd "C-w C-t") 'my/toggle-window-split)
  46. (evil-define-key 'emacs help-mode-map (kbd "C-w h") 'windmove-down)
  47. (evil-define-key 'emacs help-mode-map (kbd "C-w t") 'windmove-up)
  48. (evil-define-key 'emacs help-mode-map (kbd "C-w n") 'windmove-left)
  49. (evil-define-key 'emacs help-mode-map (kbd "C-w s") 'windmove-right)
  50. (evil-define-key 'emacs help-mode-map (kbd "C-w C-t") 'my/toggle-window-split)
  51. (evil-define-key 'normal debugger-mode-map (kbd "C-w h") 'windmove-down)
  52. (evil-define-key 'normal debugger-mode-map (kbd "C-w t") 'windmove-up)
  53. (evil-define-key 'normal debugger-mode-map (kbd "C-w n") 'windmove-left)
  54. (evil-define-key 'normal debugger-mode-map (kbd "C-w s") 'windmove-right)
  55. (evil-define-key 'normal debugger-mode-map (kbd "C-w C-t") 'my/toggle-window-split)
  56. (evil-define-key 'emacs debugger-mode-map (kbd "C-w h") 'windmove-down)
  57. (evil-define-key 'emacs debugger-mode-map (kbd "C-w t") 'windmove-up)
  58. (evil-define-key 'emacs debugger-mode-map (kbd "C-w n") 'windmove-left)
  59. (evil-define-key 'emacs debugger-mode-map (kbd "C-w s") 'windmove-right)
  60. (evil-define-key 'emacs debugger-mode-map (kbd "C-w C-t") 'my/toggle-window-split)
  61. (evil-define-key 'emacs erc-mode-map (kbd "C-w h") 'windmove-down)
  62. (evil-define-key 'emacs erc-mode-map (kbd "C-w t") 'windmove-up)
  63. (evil-define-key 'emacs erc-mode-map (kbd "C-w n") 'windmove-left)
  64. (evil-define-key 'emacs erc-mode-map (kbd "C-w s") 'windmove-right)
  65. (evil-define-key 'emacs erc-mode-map (kbd "C-w C-t") 'my/toggle-window-split)
  66. (evil-define-key 'emacs gnus-article-mode-map (kbd "C-w h") 'windmove-down)
  67. (evil-define-key 'emacs gnus-article-mode-map (kbd "C-w t") 'windmove-up)
  68. (evil-define-key 'emacs gnus-article-mode-map (kbd "C-w n") 'windmove-left)
  69. (evil-define-key 'emacs gnus-article-mode-map (kbd "C-w s") 'windmove-right)
  70. (evil-define-key 'emacs gnus-article-mode-map (kbd "C-w C-t") 'my/toggle-window-split))
  71. (with-eval-after-load 'info
  72. (define-key Info-mode-map (kbd "C-w h") 'windmove-down)
  73. (define-key Info-mode-map (kbd "C-w t") 'windmove-up)
  74. (define-key Info-mode-map (kbd "C-w n") 'windmove-left)
  75. (define-key Info-mode-map (kbd "C-w s") 'windmove-right))
  76. (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
  77. (setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
  78. (setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
  79. (setq scroll-step 1) ;; keyboard scroll one line at a time
  80. (desktop-save-mode 1)
  81. (setq save-place-file (expand-file-name ".places" user-emacs-directory))
  82. (save-place-mode)
  83. (defun my/turn-on-hl-line-mode ()
  84. "This will turn on hl-line mode."
  85. (interactive)
  86. (when (display-graphic-p)
  87. (add-hook 'prog-mode-hook 'hl-line-mode)
  88. (add-hook 'text-mode-hook 'hl-line-mode)))
  89. (add-hook 'after-init-hook 'my/turn-on-hl-line-mode)
  90. ;;cr red
  91. ;;cg green
  92. ;;x like this
  93. (defface font-lock-comment-strike
  94. '((t (:strike-through t)))
  95. "For strike-through comments")
  96. (defface font-lock-comment-important
  97. '((t (:foreground "#00ff00")))
  98. "For important")
  99. (defface font-lock-comment-todo
  100. '((t (:foreground "#ff0000")))
  101. "For todo comments")
  102. (defun add-custom-keyw ()
  103. "adds a few special keywords"
  104. (font-lock-add-keywords
  105. nil
  106. '(("\\s<+x[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-strike prepend)
  107. ("\\s<+cr[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-todo prepend)
  108. ("\\s<+cg[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-important prepend))))
  109. (add-hook 'prog-mode-hook #'add-custom-keyw)
  110. (provide 'init-gui-frames)