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.

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