├── evil-ex-registers.el ├── evil-textobj-between.el ├── evil-relative-linum.el ├── evil-operator-moccur.el ├── evil-operator-comment.el ├── hexl-evil-patch.el ├── evil-mode-line.el ├── evil-little-word.el └── README.rdoc /evil-ex-registers.el: -------------------------------------------------------------------------------- 1 | ;;; evil-ex-registers.el --- Command to paste from register in ex mode 2 | 3 | ;; Author: INA Lintaro 4 | ;; URL: http://github.com/tarao/evil-plugins 5 | ;; Version: 0.1 6 | ;; Keywords: evil, plugin 7 | 8 | ;; This file is NOT part of GNU Emacs. 9 | 10 | ;;; License: 11 | ;; 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Code: 26 | 27 | (require 'evil) 28 | (eval-when-compile (require 'cl)) 29 | 30 | (defalias 'evil-orig-get-register (symbol-function 'evil-get-register)) 31 | 32 | (defun evil-get-spec-register (register &optional noerror) 33 | "Return contents of REGISTER. 34 | Signal an error if empty, unless NOERROR is non-nil. 35 | 36 | Support some registers listed below in addition to 37 | `evil-get-register'. 38 |  the file name under the cursor 39 |  the expanded file name under the cursor 40 |  the word under the cursor 41 |  the WORD under the cursor" 42 | (cond 43 | ((or (= register ?\C-f) ; ^F the filename under the cursor 44 | (= register ?\C-p)) ; ^P the expanded filename under the cursor 45 | (let ((file (thing-at-point 'filename))) 46 | (or (and file (= register ?\C-p) (expand-file-name file)) file))) 47 | ((or (= register ?\C-w) ; ^W the word under the cursor 48 | (= register ?\C-a)) ; ^A the WORD under the cursor 49 | (let* ((word (if (= register ?\C-a) #'evil-move-WORD #'evil-move-word)) 50 | (range (evil-inner-object-range nil nil nil nil word))) 51 | (filter-buffer-substring (nth 0 range) (nth 1 range)))) 52 | (t (evil-orig-get-register register noerror)))) 53 | 54 | (defun evil-ex-paste-from-register (&optional register) 55 | "Paste from REGISTER in command line." 56 | (interactive) 57 | (flet ((evil-get-register (register &optional noerror) 58 | (with-current-buffer evil-ex-current-buffer 59 | (evil-get-spec-register register noerror)))) 60 | (if (called-interactively-p 'any) 61 | (call-interactively #'evil-paste-from-register) 62 | (evil-paste-from-register register)))) 63 | 64 | (provide 'evil-ex-registers) 65 | ;;; evil-ex-registers.el ends here 66 | -------------------------------------------------------------------------------- /evil-textobj-between.el: -------------------------------------------------------------------------------- 1 | ;;; evil-textobj-between.el --- Text object to select text between a character 2 | 3 | ;; Author: INA Lintaro 4 | ;; URL: http://github.com/tarao/evil-plugins 5 | ;; Version: 0.1 6 | ;; Keywords: evil, plugin 7 | 8 | ;; This file is NOT part of GNU Emacs. 9 | 10 | ;;; License: 11 | ;; 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Code: 26 | 27 | (require 'evil) 28 | 29 | (defgroup evil-textobj-between nil 30 | "Text object between for Evil" 31 | :prefix "evil-textobj-between-" 32 | :group 'evil) 33 | 34 | (defcustom evil-textobj-between-i-key "f" 35 | "Keys for evil-inner-between" 36 | :type 'string 37 | :group 'evil-textobj-between) 38 | (defcustom evil-textobj-between-a-key "f" 39 | "Keys for evil-a-between" 40 | :type 'string 41 | :group 'evil-textobj-between) 42 | 43 | (defun evil-between-range (count beg end type &optional inclusive) 44 | (ignore-errors 45 | (let ((count (abs (or count 1))) 46 | (beg (and beg end (min beg end))) 47 | (end (and beg end (max beg end))) 48 | (ch (evil-read-key)) 49 | beg-inc end-inc) 50 | (save-excursion 51 | (when beg (goto-char beg)) 52 | (evil-find-char (- count) ch) 53 | (setq beg-inc (point))) 54 | (save-excursion 55 | (when end (goto-char end)) 56 | (backward-char) 57 | (evil-find-char count ch) 58 | (setq end-inc (1+ (point)))) 59 | (if inclusive 60 | (evil-range beg-inc end-inc) 61 | (if (and beg end (= (1+ beg-inc) beg) (= (1- end-inc) end)) 62 | (evil-range beg-inc end-inc) 63 | (evil-range (1+ beg-inc) (1- end-inc))))))) 64 | 65 | (evil-define-text-object evil-a-between (count &optional beg end type) 66 | "Select range between a character by which the command is followed." 67 | (evil-between-range count beg end type t)) 68 | (evil-define-text-object evil-inner-between (count &optional beg end type) 69 | "Select inner range between a character by which the command is followed." 70 | (evil-between-range count beg end type)) 71 | 72 | (define-key evil-outer-text-objects-map evil-textobj-between-a-key 73 | 'evil-a-between) 74 | (define-key evil-inner-text-objects-map evil-textobj-between-i-key 75 | 'evil-inner-between) 76 | 77 | (provide 'evil-textobj-between) 78 | ;;; evil-textobj-between.el ends here 79 | -------------------------------------------------------------------------------- /evil-relative-linum.el: -------------------------------------------------------------------------------- 1 | ;;; evil-relative-linum.el --- Show relative line numbers during operator state 2 | 3 | ;; Author: INA Lintaro 4 | ;; URL: http://github.com/tarao/evil-plugins 5 | ;; Version: 0.1 6 | ;; Keywords: evil, plugin 7 | 8 | ;; This file is NOT part of GNU Emacs. 9 | 10 | ;;; License: 11 | ;; 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Code: 26 | 27 | (require 'linum+) ;; See http://github.com/tarao/elisp/raw/master/linum+.el 28 | (require 'evil) 29 | 30 | (defgroup evil-relative-linum nil 31 | "Relative line numbers when operators are activated." 32 | :prefix "evil-relative-linum-" 33 | :group 'evil) 34 | 35 | (defcustom evil-relative-linum-delay 0.3 36 | "Delay in showing line numbers after the operator is activated." 37 | :group 'evil-relative-linum 38 | :type 'float) 39 | 40 | (defvar evil-relative-linum-timer nil) 41 | (defvar evil-relative-linum-activated nil) 42 | 43 | (define-minor-mode evil-relative-linum-mode 44 | "Show relative line numbers when operators are activated." 45 | :group 'evil-relative-linum 46 | (let ((exit-cmd `(lambda () 47 | (interactive) 48 | (save-excursion (set-buffer ,(current-buffer)) 49 | (evil-relative-linum-off))))) 50 | (if evil-relative-linum-mode 51 | (progn 52 | (add-hook 'pre-command-hook exit-cmd) 53 | (add-hook 'post-command-hook exit-cmd) 54 | (setq evil-relative-linum-timer 55 | (run-with-idle-timer evil-relative-linum-delay nil 56 | 'evil-relative-linum-activate))) 57 | (cancel-timer evil-relative-linum-timer) 58 | (when evil-relative-linum-activated 59 | (relative-linum-mode 0) 60 | (setq evil-relative-linum-activated nil)) 61 | (remove-hook 'pre-command-hook exit-cmd) 62 | (remove-hook 'post-command-hook exit-cmd)))) 63 | 64 | (defun evil-relative-linum-off () 65 | (interactive) 66 | (evil-relative-linum-mode 0)) 67 | 68 | (defun evil-relative-linum-on () 69 | (interactive) 70 | (evil-relative-linum-mode 1)) 71 | 72 | (defun evil-relative-linum-activate () 73 | (setq evil-relative-linum-activated t) 74 | (relative-linum-mode 1)) 75 | 76 | (add-hook 'evil-operator-state-entry-hook 'evil-relative-linum-on) 77 | 78 | (provide 'evil-relative-linum) 79 | ;;; evil-relative-linum.el ends here 80 | -------------------------------------------------------------------------------- /evil-operator-moccur.el: -------------------------------------------------------------------------------- 1 | ;;; evil-operator-moccur.el --- Operator for Evil to use color-moccur 2 | 3 | ;; Author: INA Lintaro 4 | ;; URL: http://github.com/tarao/evil-plugins 5 | ;; Version: 0.1 6 | ;; Keywords: evil, plugin 7 | 8 | ;; This file is NOT part of GNU Emacs. 9 | 10 | ;;; License: 11 | ;; 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Code: 26 | 27 | (require 'color-moccur) 28 | (require 'evil) 29 | 30 | (defgroup evil-operator-moccur nil 31 | "Moccur operator for Evil" 32 | :prefix "evil-operator-moccur-" 33 | :group 'evil) 34 | 35 | (defcustom evil-operator-moccur-grep-find-key (kbd "M") 36 | "A key for moccur-grep-find operator" 37 | :type `,(if (get 'key-sequence 'widget-type) 38 | 'key-sequence 39 | 'sexp) 40 | :group 'evil-operator-moccur) 41 | 42 | (defcustom evil-operator-moccur-use-current-directory nil 43 | "Uses current directory for grep and does not ask interactively." 44 | :type 'boolean 45 | :group 'evil-operator-moccur) 46 | 47 | (evil-define-operator evil-moccur-grep-find-region (beg end &optional dir) 48 | "Moccur on text from BEG to END." 49 | :move-point nil 50 | (interactive "") 51 | (unless dir 52 | (setq dir (or (and (not evil-operator-moccur-use-current-directory) 53 | (moccur-grep-read-directory)) 54 | (file-name-directory (buffer-file-name))))) 55 | (moccur-grep-find dir (list (buffer-substring-no-properties beg end)))) 56 | 57 | ;;;###autoload 58 | (define-minor-mode evil-operator-moccur-mode 59 | "Buffer local minor mode of moccur operator for Evil." 60 | :lighter "" 61 | :keymap (make-sparse-keymap) 62 | :group 'evil-operator-moccur 63 | (evil-normalize-keymaps)) 64 | 65 | (defun evil-operator-moccur-mode-install () (evil-operator-moccur-mode 1)) 66 | 67 | ;;;###autoload 68 | (define-globalized-minor-mode global-evil-operator-moccur-mode 69 | evil-operator-moccur-mode evil-operator-moccur-mode-install 70 | "Global minor mode of moccur operator for Evil.") 71 | 72 | (evil-define-key 'normal evil-operator-moccur-mode-map 73 | evil-operator-moccur-grep-find-key 74 | 'evil-moccur-grep-find-region) 75 | (evil-define-key 'visual evil-operator-moccur-mode-map 76 | evil-operator-moccur-grep-find-key 77 | 'evil-moccur-grep-find-region) 78 | 79 | (provide 'evil-operator-moccur) 80 | ;;; evil-operator-moccur.el ends here 81 | -------------------------------------------------------------------------------- /evil-operator-comment.el: -------------------------------------------------------------------------------- 1 | ;;; evil-operator-comment.el --- Comment/uncomment operator for Evil 2 | 3 | ;; Author: INA Lintaro 4 | ;; URL: http://github.com/tarao/evil-plugins 5 | ;; Version: 0.1 6 | ;; Keywords: evil, plugin 7 | 8 | ;; This file is NOT part of GNU Emacs. 9 | 10 | ;;; License: 11 | ;; 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Code: 26 | 27 | 28 | 29 | (require 'evil) 30 | 31 | (defgroup evil-operator-comment nil 32 | "Comment/uncomment operator for Evil" 33 | :prefix "evil-operator-comment-" 34 | :group 'evil) 35 | 36 | (defcustom evil-operator-comment-key (kbd "C") 37 | "A key for comment/uncomment operator" 38 | :type `,(if (get 'key-sequence 'widget-type) 39 | 'key-sequence 40 | 'sexp) 41 | :group 'evil-operator-comment) 42 | 43 | (defun evil-mark-on-lines (beg end lines) 44 | (let ((beg-marker (save-excursion (goto-char beg) (point-marker))) 45 | (end-marker (save-excursion (goto-char end) (point-marker)))) 46 | (set-marker-insertion-type end-marker t) 47 | (setcdr lines (cons (cons beg-marker end-marker) (cdr lines))))) 48 | 49 | (defun evil-apply-on-block-markers (func beg end &rest args) 50 | "Like `evil-apply-on-block' but first mark all lines and then 51 | call functions on the marked ranges." 52 | (let ((lines (list nil))) 53 | (evil-apply-on-block #'evil-mark-on-lines beg end nil lines) 54 | (dolist (range (nreverse (cdr lines))) 55 | (let ((beg (car range)) (end (cdr range))) 56 | (apply func beg end args) 57 | (set-marker beg nil) 58 | (set-marker end nil))))) 59 | 60 | (evil-define-operator evil-comment-or-uncomment-region (beg end type) 61 | "Comment out text from BEG to END with TYPE." 62 | (interactive "") 63 | (if (eq type 'block) 64 | (evil-apply-on-block-markers #'comment-or-uncomment-region beg end) 65 | (comment-or-uncomment-region beg end)) 66 | ;; place cursor on beginning of line 67 | (when (and (evil-called-interactively-p) (eq type 'line)) 68 | (evil-first-non-blank))) 69 | 70 | ;;;###autoload 71 | (define-minor-mode evil-operator-comment-mode 72 | "Buffer local minor mode of comment/uncomment operator for Evil." 73 | :lighter "" 74 | :keymap (make-sparse-keymap) 75 | :group 'evil-operator-comment 76 | (evil-normalize-keymaps)) 77 | 78 | (defun evil-operator-comment-mode-install () (evil-operator-comment-mode 1)) 79 | 80 | ;;;###autoload 81 | (define-globalized-minor-mode global-evil-operator-comment-mode 82 | evil-operator-comment-mode evil-operator-comment-mode-install 83 | "Global minor mode of comment/uncomment operator for Evil.") 84 | 85 | (evil-define-key 'normal evil-operator-comment-mode-map 86 | evil-operator-comment-key 'evil-comment-or-uncomment-region) 87 | (evil-define-key 'visual evil-operator-comment-mode-map 88 | evil-operator-comment-key 'evil-comment-or-uncomment-region) 89 | 90 | (provide 'evil-operator-comment) 91 | ;;; evil-operator-comment.el ends here 92 | -------------------------------------------------------------------------------- /hexl-evil-patch.el: -------------------------------------------------------------------------------- 1 | ;;; hexl-evil-patch.el --- Patch to use Evil in hexl-mode 2 | 3 | ;; Author: INA Lintaro 4 | ;; URL: http://github.com/tarao/evil-plugins 5 | ;; Version: 0.1 6 | ;; Keywords: evil, plugin 7 | 8 | ;; This file is NOT part of GNU Emacs. 9 | 10 | ;;; License: 11 | ;; 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Code: 26 | 27 | (setq hexl-mode-hook 28 | '(hexl-follow-line 29 | hexl-activate-ruler 30 | (lambda () 31 | (defadvice hexl-self-insert-command 32 | (around ad-evil-hexl first (&optional num) activate) 33 | (let ((c last-command-event) 34 | (address (hexl-current-address t))) 35 | (if (not num) (setq num 1)) 36 | (while (> num 0) 37 | (let ((hex-position 38 | (+ (* (/ address 16) 68) 39 | 11 40 | (* 2 (% address 16)) 41 | (/ (% address 16) 2))) 42 | (ascii-position 43 | (+ (* (/ address 16) 68) 52 (% address 16)))) 44 | (if (= (point) ascii-position) (hexl-insert-char c 1) 45 | (let ((pt (point)) hex next) 46 | (cond ((= pt (1+ hex-position)) 47 | ; ... 0a1b 2c3d ... 48 | ; ^ 49 | (setq hex (concat 50 | (buffer-substring (1- pt) pt) 51 | (char-to-string c))) 52 | (setq next t)) 53 | ((= pt hex-position) 54 | ; ... 0a1b 2c3d ... 55 | ; ^ 56 | (setq hex (concat 57 | (char-to-string c) 58 | (buffer-substring (1+ pt) 59 | (+ pt 2)))))) 60 | (if (stringp hex) 61 | (let ((ch (hexl-hex-string-to-integer hex))) 62 | (if (or (> ch 255) (< ch 0)) 63 | (error "Hex number out of range")) 64 | (setq pt (point)) 65 | (delete-char 1) 66 | (insert c) 67 | (goto-char ascii-position) 68 | (delete-char 1) 69 | (insert (hexl-printable-character ch)) 70 | (goto-char (1+ pt)) 71 | (if (and next 72 | (or (eq address hexl-max-address) 73 | (setq address (1+ address)))) 74 | (hexl-goto-address address))))))) 75 | (setq num (1- num)))))) 76 | (lambda () 77 | (progn 78 | (setq hexl-iso nil))))) 79 | 80 | (provide 'hexl-evil-patch) 81 | ;;; hexl-evil-patch.el ends here 82 | -------------------------------------------------------------------------------- /evil-mode-line.el: -------------------------------------------------------------------------------- 1 | ;;; evil-mode-line.el --- Mode line plugin for Evil 2 | 3 | ;; Author: INA Lintaro 4 | ;; URL: http://github.com/tarao/evil-plugins 5 | ;; Version: 0.1 6 | ;; Keywords: evil, plugin 7 | 8 | ;; This file is NOT part of GNU Emacs. 9 | 10 | ;;; License: 11 | ;; 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Code: 26 | 27 | (require 'evil) 28 | (require 'mode-line-color) 29 | 30 | (defgroup evil-mode-line nil 31 | "Mode line color and message for Evil" 32 | :group 'evil) 33 | 34 | (defcustom evil-mode-line-color 35 | `((normal . ,(face-background 'mode-line)) 36 | (insert . "#575735") 37 | (replace . "#575735") 38 | (operator . "DarkSeaGreen4") 39 | (visual . "SteelBlue4") 40 | (emacs . "#8c5353")) 41 | "Mode line color corresponds to Evil state." 42 | :type '(alist :key-type symbol :value-type string) 43 | :group 'evil-mode-line) 44 | (defcustom evil-normal-state-msg "" 45 | "Mode line message for Evil normal state." 46 | :type 'string 47 | :group 'evil-mode-line) 48 | (defcustom evil-insert-state-msg "INSERT" 49 | "Mode line message for Evil insert state." 50 | :type 'string 51 | :group 'evil-mode-line) 52 | (defcustom evil-replace-state-msg "REPLACE" 53 | "Mode line message for Evil replace state." 54 | :type 'string 55 | :group 'evil-mode-line) 56 | (defcustom evil-emacs-state-msg "x" 57 | "Mode line message for Evil emacs state." 58 | :type 'string 59 | :group 'evil-mode-line) 60 | (defcustom evil-visual-state-msg-alist 61 | '((normal . "VISUAL") (line . "VLINE") (block . "VBLOCK")) 62 | "Mode line messages for Evil visual states." 63 | :type '(list (cons symbol string)) 64 | :group 'evil-mode-line) 65 | 66 | (defun evil-mode-line-state-msg (&optional state) 67 | "Find a message string for STATE. 68 | If `evil-STATE-state-msg' is bound, use that value. Otherwise, 69 | if STATE is a visual state, then `evil-visual-state-msg-alist' is 70 | looked up by the return value of `evil-visual-type'. If no 71 | message string is found, return an empty string." 72 | (unless state (setq state evil-state)) 73 | (let ((sym (intern (concat "evil-" (symbol-name state) "-state-msg")))) 74 | (cond 75 | ((boundp sym) (symbol-value sym)) 76 | ((evil-visual-state-p) 77 | (or (cdr (assq (evil-visual-type) evil-visual-state-msg-alist)) 78 | (cdr (assq 'normal evil-visual-state-msg-alist)))) 79 | (t "")))) 80 | 81 | (defun evil-mode-line-state-msg-format (&optional state) 82 | "Make mode string for STATE. 83 | If `evil-mode-line-state-msg' returns non-empty string, the mode string 84 | is \"--STATE MESSAGE--\". Otherwise, the mode string is \"-\"." 85 | (let* ((msg (evil-mode-line-state-msg state)) (line msg) 86 | (empty (= (length msg) 0)) (tail (if empty "-" "--"))) 87 | (unless empty (setq line (concat "--" msg))) 88 | (list "" line tail))) 89 | (defadvice skk-mode-string-to-indicator 90 | (before evil-remove----from-skk-mode-string (mode string) activate) 91 | "Do not put \"--\" at the beginning of mode string. 92 | We have our own \"--\" put by `evil-mode-line-state-msg-format'." 93 | (when (string-match "^--" string) 94 | (setq string (substring string 2)))) 95 | 96 | (defvar evil-mode-line-msg (evil-mode-line-state-msg-format 'emacs-state)) 97 | 98 | (defun evil-update-mode-line-state-msg () 99 | "Update `evil-mode-line-msg' and update mode line color." 100 | (condition-case () 101 | (progn 102 | (set (make-local-variable 'evil-mode-line-msg) 103 | (evil-mode-line-state-msg-format)) 104 | (mode-line-color-update)) 105 | (error nil))) 106 | 107 | (defadvice evil-refresh-mode-line (after evil-update-mode-line-msg activate) 108 | "Update our own mode string by `evil-update-mode-line-msg'." 109 | (evil-update-mode-line-state-msg)) 110 | 111 | ;; setup 112 | 113 | (define-mode-line-color (color) 114 | (unless color (cdr (assq evil-state evil-mode-line-color)))) 115 | 116 | (setq-default mode-line-format 117 | (append '("" evil-mode-line-msg) mode-line-format)) 118 | 119 | (provide 'evil-mode-line) 120 | ;;; evil-mode-line.el ends here 121 | -------------------------------------------------------------------------------- /evil-little-word.el: -------------------------------------------------------------------------------- 1 | ;;; evil-little-word.el --- Emulate camelcasemotion.vim 2 | 3 | ;; Author: INA Lintaro 4 | ;; URL: http://github.com/tarao/evil-plugins 5 | ;; Version: 0.1 6 | ;; Keywords: evil, plugin 7 | 8 | ;; This file is NOT part of GNU Emacs. 9 | 10 | ;;; License: 11 | ;; 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Code: 26 | 27 | (require 'evil) 28 | 29 | (defun maybe-define-category (cat doc &optional table) 30 | (unless (category-docstring cat table) (define-category cat doc table))) 31 | 32 | (let (uc lc defs (table (standard-category-table))) 33 | (map-char-table 34 | #'(lambda (key value) 35 | (when (natnump value) 36 | (let (from to) 37 | (if (consp key) 38 | (setq from (car key) to (cdr key)) 39 | (setq from (setq to key))) 40 | (while (<= from to) 41 | (cond ((/= from (downcase from)) 42 | (add-to-list 'uc from)) 43 | ((/= from (upcase from)) 44 | (add-to-list 'lc from))) 45 | (setq from (1+ from)))))) 46 | (standard-case-table)) 47 | (setq defs `(("Uppercase" ?U ,uc) 48 | ("Lowercase" ?u ,lc) 49 | ("Underscore" ?_ (?_)))) 50 | (dolist (elt defs) 51 | (maybe-define-category (cadr elt) (car elt) table) 52 | (dolist (ch (car (cddr elt))) 53 | (modify-category-entry ch (cadr elt) table)))) 54 | 55 | (defgroup evil-little-word nil 56 | "CamelCase and snake_case word movement support." 57 | :prefix "evil-little-word-" 58 | :group 'evil) 59 | 60 | (defcustom evil-little-word-separating-categories 61 | (append evil-cjk-word-separating-categories '((?u . ?U) (?_ . ?u) (?_ . ?U))) 62 | "List of pair (cons) of categories to determine word boundary 63 | for little word movement. See the documentation of 64 | `word-separating-categories'. Use `describe-categories' to see 65 | the list of categories." 66 | :type '((character . character)) 67 | :group 'evil-little-word) 68 | 69 | (defcustom evil-little-word-combining-categories 70 | (append evil-cjk-word-combining-categories '()) 71 | "List of pair (cons) of categories to determine word boundary 72 | for little word movement. See the documentation of 73 | `word-combining-categories'. Use `describe-categories' to see the 74 | list of categories." 75 | :type '((character . character)) 76 | :group 'evil-little-word) 77 | 78 | (defmacro evil-with-little-word (&rest body) 79 | (declare (indent defun) (debug t)) 80 | `(let ((evil-cjk-word-separating-categories 81 | evil-little-word-separating-categories) 82 | (evil-cjk-word-combining-categories 83 | evil-little-word-combining-categories)) 84 | ,@body)) 85 | 86 | (defun forward-evil-little-word (&optional count) 87 | "Forward by little words." 88 | (evil-with-little-word (forward-evil-word count))) 89 | 90 | (evil-define-motion evil-forward-little-word-begin (count) 91 | "Move the cursor to the beginning of the COUNT-th next little word." 92 | :type exclusive 93 | (evil-with-little-word (evil-forward-word-begin count))) 94 | 95 | (evil-define-motion evil-forward-little-word-end (count) 96 | "Move the cursor to the end of the COUNT-th next little word." 97 | :type inclusive 98 | (evil-with-little-word (evil-forward-word-end count))) 99 | 100 | (evil-define-motion evil-backward-little-word-begin (count) 101 | "Move the cursor to the beginning of the COUNT-th previous little word." 102 | :type exclusive 103 | (evil-with-little-word (evil-backward-word-begin count))) 104 | 105 | (evil-define-motion evil-backward-little-word-end (count) 106 | "Move the cursor to the end of the COUNT-th previous little word." 107 | :type inclusive 108 | (evil-with-little-word (evil-backward-word-end count))) 109 | 110 | (evil-define-text-object evil-a-little-word (count &optional beg end type) 111 | "Select a little word." 112 | (evil-select-an-object 'evil-little-word beg end type count)) 113 | 114 | (evil-define-text-object evil-inner-little-word (count &optional beg end type) 115 | "Select inner little word." 116 | (evil-select-inner-object 'evil-little-word beg end type count)) 117 | 118 | (define-key evil-motion-state-map (kbd "glw") 'evil-forward-little-word-begin) 119 | (define-key evil-motion-state-map (kbd "glb") 'evil-backward-little-word-begin) 120 | (define-key evil-motion-state-map (kbd "glW") 'evil-forward-little-word-end) 121 | (define-key evil-motion-state-map (kbd "glB") 'evil-backward-little-word-end) 122 | (define-key evil-outer-text-objects-map (kbd "lw") 'evil-a-little-word) 123 | (define-key evil-inner-text-objects-map (kbd "lw") 'evil-inner-little-word) 124 | 125 | (provide 'evil-little-word) 126 | ;;; evil-little-word.el ends here 127 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = evil-plugin by tarao 2 | 3 | Plugins for Evil ( http://www.emacswiki.org/emacs/Evil ). 4 | 5 | == evil-ex-registers.el 6 | 7 | === Usage 8 | 9 | (require 'evil-ex-registers) 10 | (define-key evil-ex-completion-map (kbd "C-r") #'evil-ex-paste-from-register) 11 | 12 | It provides special registers for ex mode. 13 | 14 | == evil-little-word.el 15 | 16 | === Usage 17 | 18 | (require 'evil-little-word) 19 | 20 | It provides little-word motion commands and text objects with default 21 | key bindings listed below. The little-word motion commands are 22 | similar to those in 23 | {camelcasemotion.vim}[http://www.vim.org/scripts/script.php?script_id=1905]. 24 | The motions stop at upcase letters just after a lowercase letter and 25 | at underscores ('_'). Unlike camelcasemotion.vim, 26 | little-word motions are sensitive to non-ascii uppercase/lowercase 27 | letters as long as Emacs knows which character is uppercase or not. 28 | See 29 | https://lists.ourproject.org/pipermail/implementations-list/2012-June/001604.html 30 | for further design details. 31 | 32 | === Commands 33 | 34 | glw:: evil-forward-little-word-begin 35 | glb:: evil-backward-little-word-begin 36 | glW:: evil-forward-little-word-end 37 | glB:: evil-backward-little-word-end 38 | 39 | === Text objects 40 | 41 | lw:: evil-a-little-word 42 | lw:: evil-inner-little-word 43 | 44 | == evil-mode-line.el 45 | 46 | === Usage 47 | 48 | (require 'evil-mode-line) 49 | 50 | It gives a state indicator at the beginning of the mode line and 51 | changes the mode line color for each state. 52 | 53 | === Dependencies 54 | 55 | - mode-line-color.el http://github.com/tarao/elisp/raw/master/mode-line-color.el 56 | 57 | === Customization 58 | 59 | ==== evil-mode-line-color 60 | 61 | An associative list which specifies correspondence between Evil states 62 | and colors. The key of the associative list must be a symbol of an 63 | Evil state (such as normal, insert, etc.) and the 64 | value of the associative list must be a string of a color (such as 65 | "SteelBlue4", "#575735", etc.). 66 | 67 | ==== evil-normal-state-msg 68 | 69 | A string shown at the mode line as a state indicator of normal state. 70 | 71 | ==== evil-insert-state-msg 72 | 73 | A string shown at the mode line as a state indicator of insert state. 74 | 75 | ==== evil-replace-state-msg 76 | 77 | A string shown at the mode line as a state indicator of replace state. 78 | 79 | ==== evil-emacs-state-msg 80 | 81 | A string shown at the mode line as a state indicator of emacs state. 82 | 83 | ==== evil-visual-state-msg-alist 84 | 85 | An associative list which specifies correspondence between Evil visual 86 | state types and state indicator strings. The key of the associative 87 | list must be a symbol of visual state type (such as normal, 88 | line and block) and the value of the associative 89 | list must be a string of indicator. 90 | 91 | == evil-operator-comment.el 92 | 93 | === Usage 94 | 95 | (require 'evil-operator-comment) 96 | (global-evil-operator-comment-mode 1) 97 | 98 | It provides comment/uncomment operator. You can use it by typing 99 | C*, for example, CC for commenting out the line at 100 | the cursor, Ciw for commenting out the word at the 101 | cursor. The key can be changed by setting custom variable 102 | evil-operator-comment-key. 103 | 104 | === Examples 105 | 106 | | denotes the cursor position. 107 | 108 | Ciw on 109 | (foo ba|r) 110 | comments out 'bar', and Ci( comments out 'foo bar'. 111 | 112 | === Remarks 113 | 114 | The idea is taken from 115 | http://relaxedcolumn.blog8.fc2.com/blog-entry-154.html, which is to 116 | add comment/uncomment operator to Vim. 117 | 118 | == evil-operator-moccur.el 119 | 120 | === Usage 121 | 122 | (require 'evil-operator-moccur) 123 | (global-evil-operator-moccur-mode 1) 124 | 125 | It provides an operator for moccur-grep-find command. You can 126 | use it by typing M*, for example, Miw for grepping a 127 | word under the cursor. The key can be changed by setting custom 128 | variable evil-operator-moccur-grep-find-key. You will be 129 | asked in which directory files to be grepped are located. Setting 130 | custom variable evil-operator-moccur-use-current-directory 131 | disables asking a directory and files in the current directory are 132 | grepped. 133 | 134 | === Dependencies 135 | 136 | - color-moccur.el http://www.emacswiki.org/emacs/color-moccur.el 137 | 138 | == evil-relative-linum.el 139 | 140 | === Usage 141 | 142 | (require 'evil-relative-linum) 143 | 144 | It provides relative line numbers shown up when you hit operator keys. 145 | 146 | === Dependencies 147 | 148 | - linum.el http://stud4.tuwien.ac.at/~e0225855/linum/linum.html (you don't need this if emacs-version >= 23) 149 | - linum+.el http://github.com/tarao/elisp/raw/master/linum+.el 150 | 151 | == evil-textobj-between.el 152 | 153 | === Usage 154 | 155 | (require 'evil-textobj-between) 156 | 157 | It provides text object for selecting a range between a 158 | character. Default key bindings are if and af, which 159 | select a range between a character by which the command is 160 | followed. if selects an inner range. These bindings can be 161 | changed by setting custom variable evil-textobj-between-i-key 162 | and evil-textobj-between-a-key. 163 | 164 | === Examples 165 | 166 | | denotes the cursor position. 167 | 168 | dif, on 169 | foo, b|ar, baz 170 | deletes ' bar', and vif: on 171 | :foo :b|ar :baz 172 | selects 'bar '. 173 | 174 | === Remarks 175 | 176 | The idea is taken from 177 | http://d.hatena.ne.jp/thinca/20100614/1276448745, which is to define 178 | textobj-between for Vim. 179 | 180 | == hexl-evil-patch.el 181 | 182 | === Usage 183 | 184 | (require 'hexl-evil-patch) 185 | 186 | A patch for hexl-mode, a mode for editing binary files in hex 187 | dump format. 188 | --------------------------------------------------------------------------------