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

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

[nongnu] elpa/evil-matchit 8540a4c12a 068/244: supports inner text objec


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit 8540a4c12a 068/244: supports inner text object, v1.5.0
Date: Thu, 6 Jan 2022 02:58:50 -0500 (EST)

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

    supports inner text object, v1.5.0
---
 README.org          | 15 ++++++++-------
 evil-matchit-pkg.el |  2 +-
 evil-matchit.el     | 43 ++++++++++++++++++++++++++++++++-----------
 pkg.sh              |  2 +-
 4 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/README.org b/README.org
index 16b6249c26..ac933ff5cd 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (v1.4.3)
+* evil-matchit (v1.5.0)
 
 Vim [[http://www.vim.org/scripts/script.php?script_id=39][matchit.vim]] by 
Benji Fisher ported into Emacs.
 
@@ -9,7 +9,8 @@ Many modern languages are supported:
 - Python
 - Java
 - C++/C
-- Javascript, JSON
+- Javascript
+- JSON
 - Perl
 - Latex
 - CMake
@@ -18,6 +19,8 @@ Many modern languages are supported:
 - Bash
 - Lua
 - PHP
+- Fortran
+- SQL
 - Laravel Blade Templating
 - Vim script
 - Emacs email (mesage-mode)
@@ -52,13 +55,11 @@ Alternatively, you can enable evil-matchit-mode along a 
major mode by adding `tu
 * Usage
 Press "%" to jump inside between tags in evil-normal-mode. Please note 
evil-matchit is smart enough to *detect the beginning of tag automatically*.
 
-Text object "%" is also created. It roughly equal the region when you press 
"%" from  evil-matchit.
+Inner/outer text object "%" is also created. It roughly equal the region when 
you press "%" from evil-matchit.
 
-Inner text object or outer object is the same thing in evil-matchit.
+Press "va%" to select line(s) wrapped by tags including tags themselves. `M-x 
evilmi-select-items` does the same thing.
 
-Press "va%" or "vi%" to select line(s) wrapped by tags. `M-x 
evilmi-select-items` does the same thing.
-
-Press "da%" or "di%" to delete line(s) wrapped by tags. `M-x 
evilmi-delete-items` does the same thing.
+Press "da%" to delete line(s) wrapped by tags including tags themselves. `M-x 
evilmi-delete-items` does the same thing.
 
 All commands support numeric argument like "3%", "5va%" or "9da%"
 
diff --git a/evil-matchit-pkg.el b/evil-matchit-pkg.el
index 73ad3fc7e2..937eaeed05 100644
--- a/evil-matchit-pkg.el
+++ b/evil-matchit-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-matchit" "1.4.3"
+(define-package "evil-matchit" "1.5.0"
                 "Vim matchit ported into Emacs (requires EVIL)")
diff --git a/evil-matchit.el b/evil-matchit.el
index 51f1802390..8e76a49c47 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.4.3
+;; Version: 1.5.0
 ;; Keywords: matchit vim evil
 ;; Package-Requires: ((evil "1.0.7"))
 ;;
@@ -176,7 +176,7 @@ If this flag is nil, then 50 means jump 50 times.")
         '(ruby-mode))
   )
 
-(defun evilmi--region-to-select-or-delete (NUM)
+(defun evilmi--region-to-select-or-delete (NUM &optional is-inner)
   (let (where-to-jump-in-theory b e)
     (save-excursion
       (setq where-to-jump-in-theory (evilmi--operate-on-item NUM 
'evilmi--push-mark))
@@ -184,21 +184,42 @@ If this flag is nil, then 50 means jump 50 times.")
       (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
-        ))
+
+      ;; for inner text object, forward a line at the beginning
+      (cond
+       (is-inner
+        (forward-line 1)
+        (setq b (line-beginning-position)))
+       (t
+        (if (string-match "[ \t]*" (buffer-substring-no-properties 
(line-beginning-position) b))
+            (setq b (line-beginning-position))
+          ;; 1+ because the line feed
+          )))
+
+      ;; for inner text object, backward a line at the end
+      (when is-inner
+        (goto-char e)
+        (forward-line -1)
+        (setq e (line-end-position)))
+      )
     (list b e)))
 
-(evil-define-text-object evilmi-text-object (&optional NUM begin end type)
-  "text object describing the region selected when you press % from 
evil-matchit"
+(evil-define-text-object evilmi-inner-text-object (&optional NUM begin end 
type)
+  "Inner text object describing the region selected when you press % from 
evil-matchit"
+  :type line
+  (let (selected-region)
+    (setq 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 you press % from 
evil-matchit"
   :type line
   (let (selected-region)
     (setq 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-text-object)
-(define-key evil-outer-text-objects-map "%" 'evilmi-text-object)
+(define-key evil-inner-text-objects-map "%" 'evilmi-inner-text-object)
+(define-key evil-outer-text-objects-map "%" 'evilmi-outer-text-object)
 
 ;;;###autoload
 (defun evilmi-select-items (&optional NUM)
@@ -251,7 +272,7 @@ If this flag is nil, then 50 means jump 50 times.")
    ))
 
 ;;;###autoload
-(defun evilmi-version() (interactive) (message "1.4.3"))
+(defun evilmi-version() (interactive) (message "1.5.0"))
 
 ;;;###autoload
 (define-minor-mode evil-matchit-mode
diff --git a/pkg.sh b/pkg.sh
index b5b6a61ace..37488d85e6 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-pkg=evil-matchit-1.4.3
+pkg=evil-matchit-1.5.0
 mkdir $pkg
 cp README.org $pkg
 cp *.el $pkg



reply via email to

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