From bf0d58ef40c1b2985329297c8f4a177cf52873cd Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 19 Sep 2014 11:58:26 +0200 Subject: [PATCH] Revert "Stop using Evil (for now)" This reverts commit b03312fa4441c9708290b65182dffc23731c8508. --- emacs/.emacs.d/Cask | 4 ++++ emacs/.emacs.d/init.el | 44 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/Cask b/emacs/.emacs.d/Cask index e4e4a6b..40347ea 100644 --- a/emacs/.emacs.d/Cask +++ b/emacs/.emacs.d/Cask @@ -15,6 +15,7 @@ (depends-on "clojure-mode") (depends-on "closure-template-html-mode") (depends-on "coffee-mode") +(depends-on "colemak-evil" :git "git://github.com/ryuslash/colemak-evil.git") (depends-on "csharp-mode") (depends-on "css-eldoc") (depends-on "deferred") @@ -28,6 +29,9 @@ (depends-on "emms") (depends-on "eshell-fringe-status") (depends-on "esxml") +(depends-on "evil") +(depends-on "evil-nerd-commenter") +(depends-on "evil-surround") (depends-on "eww-lnum") (depends-on "expand-region") (depends-on "fill-column-indicator") diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index 1b28f88..d68499a 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -318,6 +318,13 @@ MODE1 is enabled and vice-versa." (when (fboundp 'prettify-symbols-mode) (prettify-symbols-mode arg))) +(defun oni:maybe-switch-to-normal-state () + "Switch the current buffer to normal state. + +Only do this when the mode is not in emacs state by default." + (unless (memql major-mode (oni:modes-starting-in 'emacs)) + (evil-normal-state))) + (defun oni:mini-fix-timestamp-string (date-string) "A minimal version of Xah Lee's `fix-timestamp-string'. Turn DATE-STRING into something else that can be worked with in @@ -354,6 +361,10 @@ extracts the parts I want to know about." (format "[%s - %s]" band title)) song))) +(defun oni:modes-starting-in (state) + "Get a list of the modes whose default state is STATE." + (symbol-value (evil-state-property state :modes))) + (defun oni:move-beginning-of-dwim () "Move to beginning of line either after indentation or before." (interactive) @@ -922,6 +933,11 @@ from myaethon2.core.decorators import ( (topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont)))) +(stante-after colemak-evil + (define-key evil-insert-state-map (kbd "C-g") #'evil-normal-state) + (define-key evil-replace-state-map (kbd "C-g") #'evil-normal-state) + (define-key evil-visual-state-map (kbd "C-g") #'evil-normal-state)) + (stante-after compile (setq compilation-scroll-output t)) @@ -1003,6 +1019,27 @@ from myaethon2.core.decorators import ( (add-to-list 'eshell-output-filter-functions #'oni:eshell-handle-url) (add-to-list 'eshell-output-filter-functions #'eshell-truncate-buffer)) +(stante-after evil + (evil-define-operator oni:evil-sort-lines-operator (beg end) + "Sort text." + :move-point nil + :type line + (sort-lines nil beg end)) + + (mapc (lambda (mode) (evil-set-initial-state mode 'emacs)) + '(jabber-roster-mode grep-mode avandu-overview-mode + avandu-article-mode gnus-summary-mode + gnus-article-mode gnus-group-mode + magit-status-mode magit-key-mode + sql-interactive-mode Info-mode + jabber-chat-mode diff-mode prodigy-mode + calculator-mode messages-buffer-mode + help-mode)) + (evil-set-initial-state 'git-commit-mode 'normal) + (require 'evil-nerd-commenter) + (define-key evil-normal-state-map ",s" 'oni:evil-sort-lines-operator) + (add-hook 'before-save-hook #'oni:maybe-switch-to-normal-state)) + (stante-after eww (setq eww-download-path ; Don't go to ~/Downloads "~/downloads/")) @@ -1427,7 +1464,12 @@ from myaethon2.core.decorators import ( (yas-global-mode) (require 'popwin) - (popwin-mode)) + (popwin-mode) + + (evil-mode) + (when (string-equal system-name "drd") + (require 'colemak-evil)) + (global-evil-surround-mode)) (when (equal system-name "drd") (load "eap-autoloads"))