emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-matchit 7a2a7384b6: make evil related code a single m


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit 7a2a7384b6: make evil related code a single module
Date: Sat, 14 May 2022 23:58:09 -0400 (EDT)

branch: elpa/evil-matchit
commit 7a2a7384b6e752a805d6fbb78cf9425e54c2b18b
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    make evil related code a single module
---
 README.org                  |  33 ++++++----
 evil-matchit-evil-setup.el  | 140 +++++++++++++++++++++++++++++++++++++++++
 evil-matchit-html.el        |   2 +-
 evil-matchit-ocaml.el       |   2 +-
 evil-matchit-sdk.el         |  42 ++++++++-----
 evil-matchit-simple.el      |   8 ++-
 evil-matchit.el             | 150 ++++++++++----------------------------------
 pkg.sh                      |   2 +-
 tests/evil-matchit-tests.el |   1 +
 9 files changed, 230 insertions(+), 150 deletions(-)

diff --git a/README.org b/README.org
index c48962d8f6..65ba054464 100644
--- a/README.org
+++ b/README.org
@@ -6,9 +6,9 @@
 
 Vim [[http://www.vim.org/scripts/script.php?script_id=39][matchit.vim]] by 
Benji Fisher is ported into Emacs.
 
-Press "%" to jump between matched tags in Emacs. For example, in HTML "<div>" 
and "</div>" are a pair of tags.
+Press "%" to jump between matched tags ("<div>" and "</div>" in html, etc).
 
-Supported programming languages and major modes:
+Built-in supported languages and documents:
 - HTML
 - Python
 - Java
@@ -18,13 +18,13 @@ Supported programming languages and major modes:
 - React JSX (rjsx-mode, react-mode)
 - JSON
 - OCaml
-- Markdown
 - Perl
 - Yaml
 - Latex
 - MATLAB/Octave
 - CMake
-- Org-mode (match tag of org-mode and tags of other languages embedded in org 
file)
+- Markdown
+- Org (matching tags of other languages embedded in org file is also 
supported!)
 - Ruby
 - Elixir
 - Bash
@@ -40,14 +40,13 @@ Supported programming languages and major modes:
 - Emacs email (message-mode)
 - VCS (Git/Subversion/Perforce ...) merge conflicts
 
-This package uses Evil as its vi layer!
+If [[https://www.emacswiki.org/emacs/Evil][EVIL]] is installed, this package 
use EVIL as its vi layer.
+
+If EVIL is not installed, most commands still work. So *EVIL is only optional 
dependency*.
 
 Tested on Emacs 25, 26, 27, 28
 
 * Why use evil-matchit
-- No learning curve. Press "%" to jump. That's all!
-- Stable
-- Perfect integration with Evil
 - Support any modern languages (html/java/c/c++/python/latex/javascript ...)
 - Powerful. If you mix jsp, freemarker, html, jquery template or any weird 
syntax into one file, it still works!
 - Extendable. Write a plugin for it takes only 5 minutes
@@ -59,16 +58,21 @@ Screen cast for python:
 It's already uploaded to [[http://melpa.org/]].
 
 * Set up
-Insert below code into =~/.emacs=:
+** EVIL is used
+Insert below code into =~/.emacs= to setup key bindings:
 #+BEGIN_SRC lisp
-(require 'evil-matchit)
 (global-evil-matchit-mode 1)
 #+END_SRC
 
 Alternatively, you can enable =evil-matchit-mode= along a major mode by adding 
=turn-on-evil-matchit-mode= to the mode hook.
+** EVIL is not used
+No setup is required.
 
 * Usage
-Press "%" to jump inside between tag pair in normal mode or visual mode (you 
press "v" to switch to visual mode). Please note evil-matchit is smart enough 
to *detect the tag automatically*.
+** EVIL is used
+You can press "%" or =M-x evilmi-jump-items= to jump between tag pair in 
normal mode or visual mode (you press "v" to switch to visual mode).
+
+Please note evil-matchit is smart enough to *detect the tag automatically*.
 
 Tag pair could be open/closed html tag, or character pair like "{}" "[]" "()", 
or the single/double quote(s) at the two ends of the string.
 
@@ -86,6 +90,11 @@ If you need visually select lines, you could use  
=evilmi-select-items=.
 
 This is actually an advantage of Emacs, you can tweak the select region 
without go into visual state at all.
 
+** EVIL is not used
+Use =evilmi-jump-items-native= to replace =evilmi-jump-items=. Evil text 
object "%" is de-activated.
+
+But all the other commands like =evilmi-delete-items= and 
=evilmi-select-items= still work.
+
 * Advanced tips
 ** Support new major modes
 In order to apply three matching rules =evilmi-template=, =evilmi-simple=, and 
=evilmi-html= on =mhtml-mode=, please insert below code *after* your 
evil-matchit setup:
@@ -236,7 +245,7 @@ Step 3, add below code to =~/.emacs.=,
 #+BEGIN_SRC lisp
 (evilmi-load-plugin-rules '(ruby-mode lua-mode) '(script))
 #+END_SRC
-*** Support languages using indentation to indentify a block of code
+*** Support languages using indentation to identify a block of code
 It's easy to support such language (Python, Yaml, ...).
 
 Here is a minimum example to support yaml,
diff --git a/evil-matchit-evil-setup.el b/evil-matchit-evil-setup.el
new file mode 100644
index 0000000000..1c78658b97
--- /dev/null
+++ b/evil-matchit-evil-setup.el
@@ -0,0 +1,140 @@
+;;; evil-matchit-evil-setup.el --- setup for evil -*- lexical-binding: t -*-
+
+;; Author: Chen Bin <chenbin.sh@gmail.com>
+
+;; This file is not part of GNU Emacs.
+
+;;; License:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Commentary:
+
+;; Provides setup for evil-mode.
+
+;;; Code:
+
+(require 'evil)
+(eval-when-compile (require 'evil-macros))
+
+(defcustom evilmi-may-jump-by-percentage t
+  "Simulate built-in jump item command in evil.
+For example, `50%' jumps to 50 percentage of buffer.
+If nil, `50%' jumps 50 times."
+  :group 'evil-matchit
+  :type 'boolean)
+
+(defcustom evilmi-shortcut "%"
+  "The keybinding of `evilmi-jump-items' and then text object shortcut.
+Some people prefer using \"m\" instead."
+  :group 'evil-matchit
+  :type 'string)
+
+;; {{ make linter happy
+(defvar evil-visual-char)
+(defvar evil-visual-direction)
+(defvar evil-this-type-modified)
+;; }}
+
+(evil-define-text-object evilmi-inner-text-object (&optional num begin end 
type)
+  "Inner text object describing the region selected when pressing %."
+  :type line
+  (let* ((selected-region (funcall 'evilmi--region-to-select-or-delete num t)))
+    (evil-range (car selected-region) (cadr selected-region) 'line)))
+
+(evil-define-text-object evilmi-outer-text-object (&optional num begin end 
type)
+  "Outer text object describing the region selected when pressing %."
+  :type line
+  (let ((selected-region (funcall 'evilmi--region-to-select-or-delete num)))
+    (evil-range (car selected-region) (cadr selected-region) 'line)))
+
+(define-key evil-inner-text-objects-map evilmi-shortcut 
'evilmi-inner-text-object)
+(define-key evil-outer-text-objects-map evilmi-shortcut 
'evilmi-outer-text-object)
+
+;;;###autoload
+(defun evilmi-jump-to-percentage (num)
+  "Like Vim %, NUM is the percentage of location."
+  (interactive "P")
+  (let* (dst)
+    (when (and num (> num 0))
+      (setq dst (let ((size (- (point-max) (point-min))))
+                  (+ (point-min)
+                     (if (> size 80000)
+                         (* num (/ size 100))
+                       (/ (* num size) 100)))))
+      (cond
+       ((< dst (point-min))
+        (setq dst (point-min)))
+       ((> dst (point-max))
+        (setq dst (point-max))))
+      (goto-char dst)
+      (back-to-indentation))))
+
+;;;###autoload (autoload 'evilmi-jump-items "evil-matchit" nil t)
+(evil-define-command evilmi-jump-items (&optional num)
+  "Jump between items NUM times."
+  :repeat nil
+  :jump t
+  (interactive "P")
+  (cond
+   ((and evilmi-may-jump-by-percentage num)
+    (evilmi-jump-to-percentage num))
+   (t
+    (funcall 'evilmi-jump-items-internal num))))
+
+(defvar evil-matchit-mode-map (make-sparse-keymap)
+  "Keymap used by the minor mode.")
+
+;;;###autoload
+(define-minor-mode evil-matchit-mode
+  "Buffer-local minor mode to emulate matchit.vim."
+  :keymap (make-sparse-keymap)
+  :group 'evil-matchit
+  ;; get correct value of `(point)` in visual-line mode
+  ;; @see 
https://bitbucket.org/lyro/evil/issues/540/get-the-char-under-cusor-in-visual-line
+  (evil-set-command-property 'evilmi-jump-items :keep-visual t)
+  (cond
+   ((fboundp 'evilmi-customize-keybinding)
+    ;; user's own key bindings
+    (evilmi-customize-keybinding))
+
+   (t
+    ;; fallback to default key bindings
+    (evil-define-key 'normal evil-matchit-mode-map evilmi-shortcut 
'evilmi-jump-items)
+    (evil-define-key 'visual evil-matchit-mode-map evilmi-shortcut 
'evilmi-jump-items)))
+
+  (evil-normalize-keymaps))
+
+;;;###autoload
+(defun turn-on-evil-matchit-mode ()
+  "Enable the minor mode in the current buffer."
+  (evil-matchit-mode 1))
+
+;;;###autoload
+(defun turn-off-evil-matchit-mode ()
+  "Disable the minor mode in the current buffer."
+  (evil-matchit-mode -1))
+
+;;;###autoload
+(define-globalized-minor-mode global-evil-matchit-mode
+  evil-matchit-mode turn-on-evil-matchit-mode
+  "Global minor mode to emulate matchit.vim.")
+
+(provide 'evil-matchit-evil-setup)
+;;; evil-matchit-evil-setup.el ends here
+
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
diff --git a/evil-matchit-html.el b/evil-matchit-html.el
index 568728b361..4ff30d9a53 100644
--- a/evil-matchit-html.el
+++ b/evil-matchit-html.el
@@ -106,7 +106,7 @@ Use CHAR at POSITION."
       ;; `sgml-skip-tag-forward' can't handle the open html tag whose 
attribute containing "<" or ">" character
       ;; unless the start position is above "<" character
       (goto-char position) ; move to the closest "<"
-      (when (or (evilmi-among-fonts-p (point) evilmi-ignored-fonts)
+      (when (or (evilmi-sdk-font-p (point) evilmi-ignored-fonts)
                 ;; In `rjsx-mode', the attribute value's font face could be nil
                 ;; like <Component a1={3 > 2} />
                 (and (eq ?< (following-char))
diff --git a/evil-matchit-ocaml.el b/evil-matchit-ocaml.el
index c95e353dbb..a558c093b4 100644
--- a/evil-matchit-ocaml.el
+++ b/evil-matchit-ocaml.el
@@ -57,7 +57,7 @@
 
 (defun evilmi-ocaml-in-keyword-p (pos)
   "Check character at POS is keyword by comparing font face."
-  (evilmi-among-fonts-p pos
+  (evilmi-sdk-font-p pos
                         '(tuareg-font-lock-governing-face
                           tuareg-font-lock-operator-face  ; for parentheses
                           tuareg-font-double-colon-face   ; for double 
semicolon
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index 14bc6a1635..51ceaf9f98 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -23,10 +23,11 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+;;; Commentary:
+;;
 
 ;;; Code:
 
-(require 'evil nil t)
 (require 'subr-x)
 (require 'cl-lib)
 (require 'semantic/lex)
@@ -121,11 +122,11 @@ If font-face-under-cursor is NOT nil, the quoted string 
is being processed."
   (cond
    ;; @see https://github.com/redguardtoo/evil-matchit/issues/92
    ((eq major-mode 'tuareg-mode)
-    (evilmi-among-fonts-p pos '(font-lock-comment-face
+    (evilmi-sdk-font-p pos '(font-lock-comment-face
                                 font-lock-comment-delimiter-face
                                 font-lock-doc-face)))
    (t
-    (evilmi-among-fonts-p pos '(font-lock-comment-face
+    (evilmi-sdk-font-p pos '(font-lock-comment-face
                                 font-lock-comment-delimiter-face)))))
 
 (defun evilmi-sdk-defun-p ()
@@ -137,7 +138,7 @@ If font-face-under-cursor is NOT nil, the quoted string is 
being processed."
       (goto-char b)
       (while (and (< (point) e)
                   (not (setq defun-p
-                             (evilmi-among-fonts-p (point)
+                             (evilmi-sdk-font-p (point)
                                                    
'(font-lock-function-name-face)))))
         (forward-word)))
     defun-p))
@@ -145,7 +146,8 @@ If font-face-under-cursor is NOT nil, the quoted string is 
being processed."
 (defun evilmi-sdk-scan-sexps (is-forward character)
   "Get the position of matching tag with CHARACTER at point.
 If IS-FORWARD is t, jump forward; or else jump backward."
-  (if evilmi-debug (message "evilmi-sdk-scan-sexps called => (%s)" is-forward 
character))
+  (when evilmi-debug
+    (message "evilmi-sdk-scan-sexps called => %s %s" is-forward character))
   (let* ((start-pos (if is-forward (point) (+ 1 (point))))
          (arg (if is-forward 1 -1))
          (limit (if is-forward (point-max) (point-min)))
@@ -200,9 +202,15 @@ If IS-FORWARD is t, jump forward; or else jump backward."
       (message "evilmi-sdk-scan-sexps => rlt=%s lvl=%s is-forward=%s" rlt lvl 
is-forward))
     rlt))
 
+(defmacro evilmi-sdk-visual-state-p ()
+  "Test if it's evil visual state."
+  `(and (boundp 'evil-state) (eq evil-state 'visual)))
+
 (defun evilmi-sdk-adjust-jumpto (is-forward rlt)
   ;; normal-state hack!
-  (when (and (not (eq evil-state 'visual)) rlt is-forward)
+  (when (and (not (evilmi-sdk-visual-state-p))
+             rlt
+             is-forward)
     (setq rlt (1- rlt)))
   (if evilmi-debug (message "evilmi-sdk-adjust-jumpto => is-forward=%s rlt=%s" 
is-forward rlt))
   rlt)
@@ -220,17 +228,17 @@ If IS-FORWARD is t, jump forward; or else jump backward."
 (defun evilmi-sdk-tweak-selected-region (font-face jump-forward)
   "Tweak selected region using FONT-FACE and JUMP-FORWARD."
   ;; visual-state hack!
-  (when (and jump-forward (eq evil-state 'visual) (not font-face))
-    ;; if font-face is non-nil, I control the jump flow from character level,
-    ;; so hack to workaround scan-sexps is NOT necessary
-    (evil-backward-char)))
+  (when (and jump-forward (evilmi-sdk-visual-state-p) (not font-face))
+    ;; If font-face is non-nil, control the jump flow from character level.
+    ;; So hack `scan-sexps` is NOT necessary.
+    (backward-char)))
 
 (defun evilmi-sdk-skip-whitespace ()
   "Skip whitespace characters at point."
   (let ((old (point)))
     (skip-syntax-forward " ")
-    ;; If we move from a non-comment to before a comment,
-    ;; `evilmi-sdk-jumpto-where' wont skip it:
+    ;; When moving from a non-comment to position before the comment,
+    ;; `evilmi-sdk-jumpto-where' will not skip it:
     ;;
     ;; <point> /* comment */ {}
     ;;
@@ -362,7 +370,7 @@ is-function-exit-point could be unknown status"
     (save-excursion
       (goto-char begin)
       (while (search-forward keyword end t)
-        (when (not (evilmi-among-fonts-p (point)
+        (when (not (evilmi-sdk-font-p (point)
                                          evilmi-ignored-fonts))
           (setq rlt keyword))))
     rlt))
@@ -518,7 +526,7 @@ after calling this function."
 
 
 ;;;###autoload
-(defun evilmi-among-fonts-p (pos fonts)
+(defun evilmi-sdk-font-p (pos fonts)
   "If current font at POS is among FONTS."
   (let* ((fontfaces (get-text-property pos 'face)))
     (when (not (listp fontfaces))
@@ -537,7 +545,8 @@ after calling this function."
       (setq start (match-end 0)))
     count))
 
-(defun evilmi-semantic-flex (start end &optional depth length)
+;;;###autoload
+(defun evilmi-sdk-semantic-flex (start end &optional depth length)
   "Using the syntax table, do something roughly equivalent to flex.
 Semantically check between START and END.  Optional argument DEPTH
 indicates at what level to scan over entire lists.
@@ -667,6 +676,7 @@ The last argument, LENGTH specifies that only LENGTH tokens 
are returned."
     ;;(message "Flexing muscles...done")
     (nreverse ts)))
 
+;;;###autoload
 (defun evilmi-sdk-tokens (n)
   "Get semantic tokens of current N lines."
   (unless (and n (> n 1)) (setq n 1))
@@ -677,7 +687,7 @@ The last argument, LENGTH specifies that only LENGTH tokens 
are returned."
       (setq e (line-end-position)))
     (save-restriction
       (narrow-to-region b e)
-      (setq tokens (evilmi-semantic-flex b e)))
+      (setq tokens (evilmi-sdk-semantic-flex b e)))
     tokens))
 
 (provide 'evil-matchit-sdk)
diff --git a/evil-matchit-simple.el b/evil-matchit-simple.el
index 5fdd3c9d17..b31175a2a2 100644
--- a/evil-matchit-simple.el
+++ b/evil-matchit-simple.el
@@ -147,7 +147,7 @@ If it's t, use simple jump.")
          rlt)
 
     (cond
-     ;; In evil-visual-state, the (preceding-char) is actually the character 
under cursor
+     ;; In `evil-visual-state', (preceding-char) is the character under cursor
      ((not (evilmi--char-is-simple ch))
       (evilmi--simple-find-open-brace (evilmi-sdk-curline)))
 
@@ -175,8 +175,10 @@ If it's t, use simple jump.")
     ;; In latex-mode `scan-sexps' does NOT work properly between "[]"
     ;; so we have to fallback to evil's API.
     (cond
-     ((memq major-mode '(latex-mode))
-      (evil-jump-item))
+     ((and (memq major-mode '(latex-mode))
+           (functionp 'evil-jump-item))
+      ;; I'm sorry for non-evil users
+      (funcall 'evil-jump-item))
 
      (t
       (evilmi-sdk-simple-jump)))
diff --git a/evil-matchit.el b/evil-matchit.el
index f1e9cbe059..dcfa78c50a 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -4,9 +4,9 @@
 
 ;; Author: Chen Bin <chenbin.sh@gmail.com>
 ;; URL: http://github.com/redguardtoo/evil-matchit
-;; Version: 2.4.4
+;; Version: 3.0.0
 ;; Keywords: matchit vim evil
-;; Package-Requires: ((evil "1.14.0") (emacs "25.1"))
+;; Package-Requires: ((emacs "25.1"))
 ;;
 ;; This file is not part of GNU Emacs.
 
@@ -30,21 +30,31 @@
 ;;; Commentary:
 ;;
 ;; This program emulates matchit.vim by Benji Fisher.
-;; Add `(global-evil-matchit-mode 1)' into Emacs setup.
-;; Then press % or `evilmi-jump-items' to jump between then matched pair.
-;; Text object "%" is also provided.
 ;;
-;; The shortcut "%" is defined in `evilmi-shortcut'.  It's both the name of
-;; text object and shortcut of `evilmi-jump-items'.  Some people prefer set it
-;; to "m".  Here is sample setup:
+;; If EVIL is installed,
+;;   - Add `(global-evil-matchit-mode 1)' into Emacs setup.
+;;   Then press % or `evilmi-jump-items' to jump between then matched pair.
+;;   Text object "%" is also provided.
+;;
+;;   - The shortcut "%" is defined in `evilmi-shortcut'.  It's both the name of
+;;   text object and shortcut of `evilmi-jump-items'.  Some people prefer set 
it
+;;   to "m".  Here is sample setup:
 ;;
 ;;   (setq evilmi-shortcut "m")
 ;;   (global-evil-matchit-mode 1)
 ;;
+;;
+;; If EVIL is NOT installed,
+;;  - Use `evilmi-jump-items-native' to replace `evilmi-jump-items'
+;;
+;;  - Forget `evilmi-shortcut' and `global-evil-matchit-mode'
+;;
 ;; See https://github.com/redguardtoo/evil-matchit/ for help.
 ;;
 ;; This program requires EVIL (https://github.com/emacs-evil/evil)
 ;;
+;; The other commands like `evilmi-select-items' and `evil-delete-items'
+;; always work with or without EVIL.
 
 ;;; Code:
 
@@ -53,8 +63,6 @@
   :group 'evil
   :prefix "evil-matchit")
 
-(eval-when-compile
-  (require 'evil-macros))
 (require 'evil-matchit-sdk)
 
 (defcustom evilmi-plugins
@@ -63,29 +71,11 @@
   :group 'evil-matchit
   :type '(repeat sexp))
 
-(defcustom evilmi-may-jump-by-percentage t
-  "Simulate built-in jump item command in evil.
-For example, `50%' jumps to 50 percentage of buffer.
-If nil, `50%' jumps 50 times."
-  :group 'evil-matchit
-  :type 'boolean)
-
-(defcustom evilmi-shortcut "%"
-  "The keybinding of `evilmi-jump-items' and then text object shortcut.
-Some people prefer using \"m\" instead."
-  :group 'evil-matchit
-  :type 'string)
-
-;; {{ make linter happy
-(defvar evil-visual-char)
-(defvar evil-visual-direction)
-(defvar evil-this-type-modified)
-;; }}
-
-(defun evilmi--operate-on-item (num &optional func)
-  "Jump NUM times and apply function FUNC."
+;;;###autoload
+(defun evilmi-jump-items-internal (num &optional func)
+  "Jump between items NUM times and apply function FUNC."
   (when evilmi-debug
-    (message "evilmi--operate-on-item called => %s (point)=%d" num (point)))
+    (message "evilmi-jump-items-internal called => %s (point)=%d" num (point)))
   (let* ((jump-rules (plist-get evilmi-plugins major-mode))
          rlt
          jumped
@@ -124,9 +114,15 @@ Some people prefer using \"m\" instead."
       (evilmi-sdk-simple-jump)
       (setq ideal-dest (point)))
 
-    (if evilmi-debug (message "evilmi--operate-on-item called. Return: %s" 
ideal-dest))
+    (if evilmi-debug (message "evilmi-jump-items-internal called. Return: %s" 
ideal-dest))
     ideal-dest))
 
+;;;###autoload
+(defun evilmi-jump-items-native (&optional num)
+  "Jump between items NUM times."
+  (interactive "P")
+  (evilmi-jump-items-internal num))
+
 (defun evilmi--push-mark (position)
   "Pus POSITION as marker."
   (push-mark (nth 0 position) t t))
@@ -259,7 +255,7 @@ Some people prefer using \"m\" instead."
 If IS-INNER is t, the region is inner text object."
   (let* (ideal-dest b e)
     (save-excursion
-      (setq ideal-dest (evilmi--operate-on-item num #'evilmi--push-mark))
+      (setq ideal-dest (evilmi-jump-items-internal num #'evilmi--push-mark))
       (if ideal-dest (goto-char ideal-dest))
       (setq b (region-beginning))
       (setq e (region-end))
@@ -284,21 +280,6 @@ If IS-INNER is t, the region is inner text object."
     (if evilmi-debug (message "evilmi--region-to-select-or-delete called. 
Return: %s" (list b e)))
     (list b e)))
 
-(evil-define-text-object evilmi-inner-text-object (&optional num begin end 
type)
-  "Inner text object describing the region selected when pressing %."
-  :type line
-  (let* ((selected-region (evilmi--region-to-select-or-delete num t)))
-    (evil-range (car selected-region) (cadr selected-region) 'line)))
-
-(evil-define-text-object evilmi-outer-text-object (&optional num begin end 
type)
-  "Outer text object describing the region selected when pressing %."
-  :type line
-  (let ((selected-region (evilmi--region-to-select-or-delete num)))
-    (evil-range (car selected-region) (cadr selected-region) 'line)))
-
-(define-key evil-inner-text-objects-map evilmi-shortcut 
'evilmi-inner-text-object)
-(define-key evil-outer-text-objects-map evilmi-shortcut 
'evilmi-outer-text-object)
-
 ;;;###autoload
 (defun evilmi-select-items (&optional num)
   "Select NUM items/tags and the region between them."
@@ -316,80 +297,17 @@ If IS-INNER is t, the region is inner text object."
     ;; 1+ because the line feed
     (kill-region (car selected-region) (1+ (cadr selected-region)))))
 
-;;;###autoload
-(defun evilmi-jump-to-percentage (num)
-  "Like Vim %, NUM is the percentage of location."
-  (interactive "P")
-  (let* (dst)
-    (when (and num (> num 0))
-      (setq dst (let ((size (- (point-max) (point-min))))
-                  (+ (point-min)
-                     (if (> size 80000)
-                         (* num (/ size 100))
-                       (/ (* num size) 100)))))
-      (cond
-       ((< dst (point-min))
-        (setq dst (point-min)))
-       ((> dst (point-max))
-        (setq dst (point-max))))
-      (goto-char dst)
-      (back-to-indentation))))
-
-;;;###autoload (autoload 'evilmi-jump-items "evil-matchit" nil t)
-(evil-define-command evilmi-jump-items (&optional num)
-  "Jump between items NUM times."
-  :repeat nil
-  :jump t
-  (interactive "P")
-  (cond
-   ((and evilmi-may-jump-by-percentage num)
-    (evilmi-jump-to-percentage num))
-   (t
-    (evilmi--operate-on-item num))))
-
 ;;;###autoload
 (defun evilmi-version()
   "Print version."
   (interactive)
-  (message "2.4.4"))
-
-(defvar evil-matchit-mode-map (make-sparse-keymap)
-  "Keymap used by the minor mode.")
-
-;;;###autoload
-(define-minor-mode evil-matchit-mode
-  "Buffer-local minor mode to emulate matchit.vim."
-  :keymap (make-sparse-keymap)
-  :group 'evil-matchit
-  ;; get correct value of `(point)` in visual-line mode
-  ;; @see 
https://bitbucket.org/lyro/evil/issues/540/get-the-char-under-cusor-in-visual-line
-  (evil-set-command-property 'evilmi-jump-items :keep-visual t)
-  (if (fboundp 'evilmi-customize-keybinding)
-      ;; use user's own key bindings
-      (evilmi-customize-keybinding)
-    ;; else use default key bindings
-    (evil-define-key 'normal evil-matchit-mode-map evilmi-shortcut 
'evilmi-jump-items)
-    (evil-define-key 'visual evil-matchit-mode-map evilmi-shortcut 
'evilmi-jump-items))
-
-  (evil-normalize-keymaps))
-
-;;;###autoload
-(defun turn-on-evil-matchit-mode ()
-  "Enable the minor mode in the current buffer."
-  (evil-matchit-mode 1))
-
-;;;###autoload
-(defun turn-off-evil-matchit-mode ()
-  "Disable the minor mode in the current buffer."
-  (evil-matchit-mode -1))
-
-;;;###autoload
-(define-globalized-minor-mode global-evil-matchit-mode
-  evil-matchit-mode turn-on-evil-matchit-mode
-  "Global minor mode to emulate matchit.vim.")
+  (message "3.0.0"))
 
 ;; initialize evilmi-plugins only once
 (evilmi-init-plugins)
 
+(with-eval-after-load 'evil
+  (require 'evil-matchit-evil-setup))
+
 (provide 'evil-matchit)
 ;;; evil-matchit.el ends here
diff --git a/pkg.sh b/pkg.sh
index a02e9972fb..49821b97f1 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 name=evil-matchit
-version=2.4.4
+version=3.0.0
 pkg=$name-$version
 mkdir $pkg
 cp README.org $pkg
diff --git a/tests/evil-matchit-tests.el b/tests/evil-matchit-tests.el
index 6ef311bb17..8c46fdb30f 100644
--- a/tests/evil-matchit-tests.el
+++ b/tests/evil-matchit-tests.el
@@ -25,6 +25,7 @@
 
 (require 'ert)
 (require 'evil-matchit)
+(require 'evil-matchit-evil-setup)
 
 (setq evilmi-may-jump-by-percentage nil)
 (setq evilmi-debug nil) ; debug



reply via email to

[Prev in Thread] Current Thread [Next in Thread]