Emacs config utilizing prelude as a base
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.

130 lines
4.1 KiB

  1. ;;; prelude-evil.el --- Emacs Prelude: evil-mode configuration.
  2. ;;
  3. ;; Copyright © 2011-2013 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: http://batsov.com/prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Some basic configuration for evil-mode.
  12. ;;; License:
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 3
  16. ;; of the License, or (at your option) any later version.
  17. ;;
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  25. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  26. ;; Boston, MA 02110-1301, USA.
  27. ;;; Code:
  28. ;;; goto-chg lets you use the g-; and g-, to go to recent changes
  29. ;;; evil-visualstar enables searching visual selection with *
  30. ;;; evil-numbers enables vim style numeric incrementing and decrementing
  31. (prelude-require-packages '(evil goto-chg evil-surround evil-visualstar evil-numbers))
  32. (setq evil-mode-line-format 'before)
  33. (setq evil-emacs-state-cursor '("red" box))
  34. (setq evil-normal-state-cursor '("gray" box))
  35. (setq evil-visual-state-cursor '("gray" box))
  36. (setq evil-insert-state-cursor '("gray" bar))
  37. (setq evil-motion-state-cursor '("gray" box))
  38. (evil-mode 1)
  39. (global-evil-surround-mode 1)
  40. (define-key evil-normal-state-map (kbd "C-A")
  41. 'evil-numbers/inc-at-pt)
  42. (define-key evil-normal-state-map (kbd "C-S-A")
  43. 'evil-numbers/dec-at-pt)
  44. ;;
  45. ;; Other useful Commands
  46. ;;
  47. (evil-ex-define-cmd "W" 'evil-write-all)
  48. (evil-ex-define-cmd "Tree" 'speedbar-get-focus)
  49. (evil-ex-define-cmd "linum" 'linum-mode)
  50. (evil-ex-define-cmd "Align" 'align-regexp)
  51. (defun prelude-yank-to-end-of-line ()
  52. "Yank to end of line."
  53. (interactive)
  54. (evil-yank (point) (point-at-eol)))
  55. (define-key evil-normal-state-map
  56. (kbd "Y") 'prelude-yank-to-end-of-line)
  57. ;; Scrolling
  58. (defun prelude-evil-scroll-down-other-window ()
  59. (interactive)
  60. (scroll-other-window))
  61. (defun prelude-evil-scroll-up-other-window ()
  62. (interactive)
  63. (scroll-other-window '-))
  64. (define-key evil-normal-state-map
  65. (kbd "C-S-d") 'prelude-evil-scroll-down-other-window)
  66. (define-key evil-normal-state-map
  67. (kbd "C-S-u") 'prelude-evil-scroll-up-other-window)
  68. ;;
  69. ;; Magit from avsej
  70. ;;
  71. (evil-add-hjkl-bindings magit-log-mode-map 'emacs)
  72. (evil-add-hjkl-bindings magit-commit-mode-map 'emacs)
  73. (evil-add-hjkl-bindings magit-branch-manager-mode-map 'emacs
  74. "K" 'magit-discard-item
  75. "L" 'magit-key-mode-popup-logging)
  76. (evil-add-hjkl-bindings magit-status-mode-map 'emacs
  77. "K" 'magit-discard-item
  78. "l" 'magit-key-mode-popup-logging
  79. "h" 'magit-toggle-diff-refine-hunk)
  80. (setq evil-shift-width 2)
  81. ;;; enable ace-jump mode with evil-mode
  82. (define-key evil-normal-state-map (kbd "SPC") 'ace-jump-mode)
  83. ;;; snagged from Eric S. Fraga
  84. ;;; http://lists.gnu.org/archive/html/emacs-orgmode/2012-05/msg00153.html
  85. (defun prelude-evil-key-bindings-for-org ()
  86. ;;(message "Defining evil key bindings for org")
  87. (evil-declare-key 'normal org-mode-map
  88. "gk" 'outline-up-heading
  89. "gj" 'outline-next-visible-heading
  90. "H" 'org-beginning-of-line ; smarter behaviour on headlines etc.
  91. "L" 'org-end-of-line ; smarter behaviour on headlines etc.
  92. "t" 'org-todo ; mark a TODO item as DONE
  93. ",c" 'org-cycle
  94. (kbd "TAB") 'org-cycle
  95. ",e" 'org-export-dispatch
  96. ",n" 'outline-next-visible-heading
  97. ",p" 'outline-previous-visible-heading
  98. ",t" 'org-set-tags-command
  99. ",u" 'outline-up-heading
  100. "$" 'org-end-of-line ; smarter behaviour on headlines etc.
  101. "^" 'org-beginning-of-line ; ditto
  102. "-" 'org-ctrl-c-minus ; change bullet style
  103. "<" 'org-metaleft ; out-dent
  104. ">" 'org-metaright ; indent
  105. ))
  106. (prelude-evil-key-bindings-for-org)
  107. (provide 'prelude-evil)