From: Peng Li Date: Fri, 8 Sep 2017 01:05:06 +0000 (+0800) Subject: Emacs - Move evil into a separate file X-Git-Url: http://47.100.26.94:8080/?a=commitdiff_plain;h=abf9d0c4f2f7fa4904d4488116c300c171c622c2;p=dotfiles.git Emacs - Move evil into a separate file --- diff --git a/emacs.d/config.org b/emacs.d/config.org index 5012da6..0493da3 100644 --- a/emacs.d/config.org +++ b/emacs.d/config.org @@ -1482,10 +1482,10 @@ Type =o= to go to the link ** Which key [[https://github.com/justbur/emacs-which-key][which-key]] show the key bindings #+BEGIN_SRC emacs-lisp :tangle yes :results silent - (use-package which-key - :ensure t - :config - (which-key-mode)) + ;; (use-package which-key + ;; :ensure t + ;; :config + ;; (which-key-mode)) #+END_SRC ** View only for some directory @@ -3523,20 +3523,11 @@ Refer [[https://github.com/fnwiya/dotfiles/blob/c9ca79f1b22c919d9f4c3a0f944ba828 #+END_SRC * Evil Mode #+BEGIN_SRC emacs-lisp :tangle yes :results silent - (use-package evil - :ensure t - :init - (setq evil-default-state 'emacs) - :config - (evil-mode t) - (defalias 'evil-insert-state 'evil-emacs-state) - (setq evil-emacs-state-cursor '("red" box)) - (setq evil-normal-state-cursor '("green" box)) - (setq evil-visual-state-cursor '("orange" box)) - (setq evil-insert-state-cursor '("red" bar)) - (setq evil-replace-state-cursor '("red" bar)) - (setq evil-operator-state-cursor '("red" hollow))) + (org-babel-load-file "~/.emacs.d/emacs-evil.org") + ;; (require 'init-evil-mode) #+END_SRC + + * Note ** Check if emacs is in terminal of graphic mode Use =display-graphic-p= instead of =window-system= diff --git a/emacs.d/emacs-evil.org b/emacs.d/emacs-evil.org new file mode 100644 index 0000000..340957c --- /dev/null +++ b/emacs.d/emacs-evil.org @@ -0,0 +1,72 @@ +#+TITLE:Emacs Evil Config +#+AUTHOR: Peng Li +#+EMAIL: seudut@gmail.com + +As the =Evil= mode is significant, and has lots of configurations, it's better put them +in a separate file. + +* Key-chord +[[https://www.emacswiki.org/emacs/KeyChord][KeyChord]] lets you bind commands to combination key-strokes. This will be used in Evil mode. +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + (use-package key-chord + :ensure t + :init + (setq key-chord-two-keys-delay 0.1) + (setq key-chord-one-keys-delay 0.2) + :config + (key-chord-mode 1)) +#+END_SRC + +* Evil mode +https://www.emacswiki.org/emacs/Evil + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + (defun my-evil-config () + "This should be called after evil-mode is loaded." + ;; Buffer operations + (define-key evil-normal-state-map ";w" 'evil-save) + (define-key evil-normal-state-map ";e" 'evil-edit) + ;; + ;; Window operations + (define-key evil-normal-state-map "\C-W s" 'evil-window-split) + (define-key evil-normal-state-map "\C-W v" 'evil-window-vsplit) + (define-key evil-normal-state-map ";s" 'evil-window-split) + (define-key evil-normal-state-map ";v" 'evil-window-vsplit) + (define-key evil-normal-state-map ";q" 'evil-window-delete) + (define-key evil-normal-state-map "\C-W o" 'delete-other-windows) + (define-key evil-normal-state-map "\C-W h" 'evil-window-left) + (define-key evil-normal-state-map "\C-W j" 'evil-window-down) + (define-key evil-normal-state-map "\C-W k" 'evil-window-up) + (define-key evil-normal-state-map "\C-W l" 'evil-window-right) + (define-key evil-normal-state-map "\C-h" 'evil-window-left) + (define-key evil-normal-state-map "\C-j" 'evil-window-down) + (define-key evil-normal-state-map "\C-k" 'evil-window-up) + (define-key evil-normal-state-map "\C-l" 'evil-window-right)) + + (use-package evil + :ensure t + :init + (setq evil-default-state 'emacs) + (setq evil-emacs-state-cursor '("red" box)) + (setq evil-normal-state-cursor '("green" box)) + (setq evil-visual-state-cursor '("orange" box)) + (setq evil-insert-state-cursor '("red" bar)) + (setq evil-replace-state-cursor '("red" bar)) + (setq evil-operator-state-cursor '("red" hollow)) + :config + (evil-mode t) + ;; (defalias 'evil-insert-state 'evil-emacs-state) + ;; switch to normal mode + ;; (key-chord-define evil-insert-state-map "jj" 'evil-normal-state) + ;; (key-chord-define evil-emacs-state-map "jj" 'evil-normal-state) + ;; + ;; Normal state map + (my-evil-config)) + + +#+END_SRC + + +#+BEGIN_SRC emacs-lisp :tangle yes :results silent + (provide 'init-evil-mode) +#+END_SRC