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

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

[nongnu] elpa/evil-matchit 0be04f960f 049/244: use text objects v1.3.2


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit 0be04f960f 049/244: use text objects v1.3.2
Date: Thu, 6 Jan 2022 02:58:48 -0500 (EST)

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

    use text objects v1.3.2
---
 README.org          | 16 ++++++++------
 evil-matchit-pkg.el |  2 +-
 evil-matchit.el     | 60 ++++++++++++++++++++---------------------------------
 3 files changed, 34 insertions(+), 44 deletions(-)

diff --git a/README.org b/README.org
index b1737b7cf2..222d668b27 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (v1.3.1)
+* evil-matchit (v1.3.2)
 
 Vim [[http://www.vim.org/scripts/script.php?script_id=39][matchit.vim]] by 
Benji Fisher ported into Emacs.
 
@@ -22,7 +22,7 @@ Most modern languages are supported:
 
 This package uses Evil as its vi layer!
 
-* Why use evil-matchit 
+* Why use evil-matchit
 - No learning curve. Press "%" to jump between matched tags. That's all!
 - Stable! The ONLY dependency is evil-mode. So it should work in any major 
modes (web-mode, html-mode ...).
 - Support any modern languages (html/java/c/c++/python/latex/javascript ...).
@@ -49,11 +49,15 @@ Alternatively, you can enable evil-matchit-mode along a 
major mode by adding `tu
 * Usage
 Press "%" to jump inside item(s) between tags in evil-normal-mode whose 
command name is "evilmi-jump-items". Please note that you *DO NOT* need move 
cursor above the tag before jumping, evil-matchit is smart enough to *detect 
the beginning of tag automatically*.
 
-Press ",si" to select item(s) wrapped by tags in evil-normal-mode whose 
command name is "evilmi-select-items".
+Text object "%" is also created. It roughly equal the region when you press 
"%" from  evil-matchit. Its basic unit is line.
 
-Press ",di" to delete item(s) wrapped by tags in evil-normal-mode whose 
command name is "evilmi-delete-items".
+Please note inner text object or outer object is the same thing in 
evil-matchit.
 
-All commands support numeric argument like "3%", "5,si" or "9,di"
+Press "va%" or "vi%" to select line(s) wrapped by tags.
+
+Press "da%" or "di%" to delete line(s) wrapped by tags.
+
+All commands support numeric argument like "3%", "5va%" or "9da%"
 
 * Advanced tips
 ** Support more major modes
@@ -188,7 +192,7 @@ Basically you just need:
 ** Share your code to the world
 Tweak your code a little bit to make it a plugin and ask me to merge it into 
upstream.
 
-Please check "evil-matchit-latext.el" for technical details about plugin.
+Please check "evil-matchit-latex.el" for technical details about plugin.
 
 Key points about code quality of plugin:
 - minimum dependency. For example, if your plugin for html template files is 
only some web-mode API wrapper, it will break when user don't have web-mode
diff --git a/evil-matchit-pkg.el b/evil-matchit-pkg.el
index 53bccb9aac..16b99b3935 100644
--- a/evil-matchit-pkg.el
+++ b/evil-matchit-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-matchit" "1.3.1"
+(define-package "evil-matchit" "1.3.2"
                 "Vim matchit ported into Emacs (requires EVIL)")
diff --git a/evil-matchit.el b/evil-matchit.el
index 5692d2b332..1175ced7f1 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -4,7 +4,7 @@
 
 ;; Author: Chen Bin <chenbin.sh@gmail.com>
 ;; URL: http://github.com/redguardtoo/evil-matchit
-;; Version: 1.3.1
+;; Version: 1.3.2
 ;; Keywords: matchit vim evil
 ;; Package-Requires: ((evil "1.0.7"))
 ;;
@@ -152,6 +152,25 @@
         '(lua-mode ruby-mode vimrc-mode))
   )
 
+(evil-define-text-object evilmi-text-object (&optional NUM begin end type)
+  "text object describling the region selected when you press % from 
evil-matchit"
+  :type line
+  (let (where-to-jump-in-theory b e)
+    (save-excursion
+      (setq where-to-jump-in-theory (evilmi--operate-on-item NUM 
'evilmi--push-mark))
+      (if where-to-jump-in-theory (goto-char where-to-jump-in-theory))
+      (setq b (region-beginning))
+      (setq e (region-end))
+      (goto-char b)
+      (when (string-match "[ \t]*" (buffer-substring-no-properties 
(line-beginning-position) b))
+        (setq b (line-beginning-position))
+        ;; 1+ because the line feed
+        ))
+    (evil-range b e 'line)))
+
+(define-key evil-inner-text-objects-map "%" 'evilmi-text-object)
+(define-key evil-outer-text-objects-map "%" 'evilmi-text-object)
+
 ;;;###autoload
 (defun evilmi-jump-items (&optional NUM)
   "jump between item/tag(s)"
@@ -162,36 +181,7 @@
    ))
 
 ;;;###autoload
-(defun evilmi-select-items (&optional NUM)
-  "select item/tag(s)"
-  (interactive "p")
-  (let (where-to-jump-in-theory )
-    (setq where-to-jump-in-theory (evilmi--operate-on-item NUM 
'evilmi--push-mark))
-    (if where-to-jump-in-theory (goto-char where-to-jump-in-theory))
-    )
-  )
-
-;;;###autoload
-(defun evilmi-delete-items (&optional NUM)
-  "delete item/tag(s)"
-  (interactive "p")
-  (let (where-to-jump-in-theory )
-    (setq where-to-jump-in-theory (evilmi--operate-on-item NUM 
'evilmi--push-mark))
-    (if where-to-jump-in-theory (goto-char where-to-jump-in-theory))
-    (save-excursion
-      (let ((b (region-beginning))
-            (e (region-end)))
-        (goto-char b)
-        (when (string-match "[ \t]*" (buffer-substring-no-properties 
(line-beginning-position) b))
-          (setq b (line-beginning-position))
-          ;; 1+ because the line feed
-          (kill-region b (1+ e))
-          )))
-    ;; need some hook here
-    ))
-
-;;;###autoload
-(defun evilmi-version() (interactive) (message "1.3.1"))
+(defun evilmi-version() (interactive) (message "1.3.2"))
 
 ;;;###autoload
 (define-minor-mode evil-matchit-mode
@@ -200,14 +190,10 @@
   (if (fboundp 'evilmi-customize-keybinding)
       (evilmi-customize-keybinding)
     (evil-define-key 'normal evil-matchit-mode-map
-      "%" 'evilmi-jump-items
-      ",si" 'evilmi-select-items
-      ",di" 'evilmi-delete-items
-      )
+      "%" 'evilmi-jump-items)
     )
   (evil-normalize-keymaps)
-  (evilmi-init-plugins)
-  )
+  (evilmi-init-plugins))
 
 ;;;###autoload
 (defun turn-on-evil-matchit-mode ()



reply via email to

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