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.

123 lines
3.9 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 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-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. ;; Scrolling
  52. (defun prelude-evil-scroll-down-other-window ()
  53. (interactive)
  54. (scroll-other-window))
  55. (defun prelude-evil-scroll-up-other-window ()
  56. (interactive)
  57. (scroll-other-window '-))
  58. (define-key evil-normal-state-map
  59. (kbd "C-S-d") 'prelude-evil-scroll-down-other-window)
  60. (define-key evil-normal-state-map
  61. (kbd "C-S-u") 'prelude-evil-scroll-up-other-window)
  62. ;;
  63. ;; Magit from avsej
  64. ;;
  65. (evil-add-hjkl-bindings magit-log-mode-map 'emacs)
  66. (evil-add-hjkl-bindings magit-commit-mode-map 'emacs)
  67. (evil-add-hjkl-bindings magit-branch-manager-mode-map 'emacs
  68. "K" 'magit-discard-item
  69. "L" 'magit-key-mode-popup-logging)
  70. (evil-add-hjkl-bindings magit-status-mode-map 'emacs
  71. "K" 'magit-discard-item
  72. "l" 'magit-key-mode-popup-logging
  73. "h" 'magit-toggle-diff-refine-hunk)
  74. (setq evil-shift-width 2)
  75. ;;; enable ace-jump mode with evil-mode
  76. (define-key evil-normal-state-map (kbd "SPC") 'ace-jump-mode)
  77. ;;; snagged from Eric S. Fraga
  78. ;;; http://lists.gnu.org/archive/html/emacs-orgmode/2012-05/msg00153.html
  79. (defun prelude-evil-key-bindings-for-org ()
  80. ;;(message "Defining evil key bindings for org")
  81. (evil-declare-key 'normal org-mode-map
  82. "gk" 'outline-up-heading
  83. "gj" 'outline-next-visible-heading
  84. "H" 'org-beginning-of-line ; smarter behaviour on headlines etc.
  85. "L" 'org-end-of-line ; smarter behaviour on headlines etc.
  86. "t" 'org-todo ; mark a TODO item as DONE
  87. ",c" 'org-cycle
  88. (kbd "TAB") 'org-cycle
  89. ",e" 'org-export-dispatch
  90. ",n" 'outline-next-visible-heading
  91. ",p" 'outline-previous-visible-heading
  92. ",t" 'org-set-tags-command
  93. ",u" 'outline-up-heading
  94. "$" 'org-end-of-line ; smarter behaviour on headlines etc.
  95. "^" 'org-beginning-of-line ; ditto
  96. "-" 'org-ctrl-c-minus ; change bullet style
  97. "<" 'org-metaleft ; out-dent
  98. ">" 'org-metaright ; indent
  99. ))
  100. (prelude-evil-key-bindings-for-org)
  101. (provide 'prelude-evil)