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.

135 lines
4.2 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. (require 'evil-visualstar)
  33. (setq evil-mode-line-format 'before)
  34. (setq evil-emacs-state-cursor '("red" box))
  35. (setq evil-normal-state-cursor '("gray" box))
  36. (setq evil-visual-state-cursor '("gray" box))
  37. (setq evil-insert-state-cursor '("gray" bar))
  38. (setq evil-motion-state-cursor '("gray" box))
  39. ;; prevent esc-key from translating to meta-key in terminal mode
  40. (setq evil-esc-delay 0)
  41. (evil-mode 1)
  42. (global-evil-surround-mode 1)
  43. (define-key evil-normal-state-map (kbd "C-A")
  44. 'evil-numbers/inc-at-pt)
  45. (define-key evil-normal-state-map (kbd "C-S-A")
  46. 'evil-numbers/dec-at-pt)
  47. ;;
  48. ;; Other useful Commands
  49. ;;
  50. (evil-ex-define-cmd "W" 'evil-write-all)
  51. (evil-ex-define-cmd "Tree" 'speedbar-get-focus)
  52. (evil-ex-define-cmd "linum" 'linum-mode)
  53. (evil-ex-define-cmd "Align" 'align-regexp)
  54. (defun prelude-yank-to-end-of-line ()
  55. "Yank to end of line."
  56. (interactive)
  57. (evil-yank (point) (point-at-eol)))
  58. (define-key evil-normal-state-map
  59. (kbd "Y") 'prelude-yank-to-end-of-line)
  60. ;; Scrolling
  61. (defun prelude-evil-scroll-down-other-window ()
  62. (interactive)
  63. (scroll-other-window))
  64. (defun prelude-evil-scroll-up-other-window ()
  65. (interactive)
  66. (scroll-other-window '-))
  67. (define-key evil-normal-state-map
  68. (kbd "C-S-d") 'prelude-evil-scroll-down-other-window)
  69. (define-key evil-normal-state-map
  70. (kbd "C-S-u") 'prelude-evil-scroll-up-other-window)
  71. ;;
  72. ;; Magit from avsej
  73. ;;
  74. (evil-add-hjkl-bindings magit-log-mode-map 'emacs)
  75. (evil-add-hjkl-bindings magit-commit-mode-map 'emacs)
  76. (evil-add-hjkl-bindings magit-branch-manager-mode-map 'emacs
  77. "K" 'magit-discard-item
  78. "L" 'magit-key-mode-popup-logging)
  79. (evil-add-hjkl-bindings magit-status-mode-map 'emacs
  80. "K" 'magit-discard-item
  81. "l" 'magit-key-mode-popup-logging
  82. "h" 'magit-toggle-diff-refine-hunk)
  83. (setq evil-shift-width 2)
  84. ;;; enable ace-jump mode with evil-mode
  85. (define-key evil-normal-state-map (kbd "SPC") 'ace-jump-mode)
  86. ;;; snagged from Eric S. Fraga
  87. ;;; http://lists.gnu.org/archive/html/emacs-orgmode/2012-05/msg00153.html
  88. (defun prelude-evil-key-bindings-for-org ()
  89. ;;(message "Defining evil key bindings for org")
  90. (evil-declare-key 'normal org-mode-map
  91. "gk" 'outline-up-heading
  92. "gj" 'outline-next-visible-heading
  93. "H" 'org-beginning-of-line ; smarter behaviour on headlines etc.
  94. "L" 'org-end-of-line ; smarter behaviour on headlines etc.
  95. "t" 'org-todo ; mark a TODO item as DONE
  96. ",c" 'org-cycle
  97. (kbd "TAB") 'org-cycle
  98. ",e" 'org-export-dispatch
  99. ",n" 'outline-next-visible-heading
  100. ",p" 'outline-previous-visible-heading
  101. ",t" 'org-set-tags-command
  102. ",u" 'outline-up-heading
  103. "$" 'org-end-of-line ; smarter behaviour on headlines etc.
  104. "^" 'org-beginning-of-line ; ditto
  105. "-" 'org-ctrl-c-minus ; change bullet style
  106. "<" 'org-metaleft ; out-dent
  107. ">" 'org-metaright ; indent
  108. ))
  109. (prelude-evil-key-bindings-for-org)
  110. (provide 'prelude-evil)