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

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

[nongnu] elpa/evil-matchit acd0b7401b 026/244: simple jump algorithm upg


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit acd0b7401b 026/244: simple jump algorithm upgraded v1.1.1
Date: Thu, 6 Jan 2022 02:58:46 -0500 (EST)

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

    simple jump algorithm upgraded v1.1.1
---
 README.org             |  5 ++--
 evil-matchit-simple.el | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++
 evil-matchit.el        | 32 +++-----------------
 3 files changed, 87 insertions(+), 30 deletions(-)

diff --git a/README.org b/README.org
index f2478a4b0a..21083924d0 100644
--- a/README.org
+++ b/README.org
@@ -111,8 +111,9 @@ Here is a complete sample:
   (push-mark (nth 0 rlt) t t)
   ;; say 999 is the where we jump to
   (goto-char 999)
-  ;; If you need where is the end of the region, you need return it
-  ;; at the end of the function
+  ;; If you need know where is the end of the region for region operation,
+  ;; you need return the end of region at the end of function
+  ;; region operation means selection/deletion of region.
   888
   )
 
diff --git a/evil-matchit-simple.el b/evil-matchit-simple.el
new file mode 100644
index 0000000000..960004d368
--- /dev/null
+++ b/evil-matchit-simple.el
@@ -0,0 +1,80 @@
+;;; evil-matchit-simple.el --- simple match plugin of evil-matchit
+
+;; Copyright (C) 2013  Chen Bin <chenbin.sh@gmail.com>
+
+;; Author: Chen Bin <chenbin.sh@gmail.com>
+
+;; This file is not part of GNU Emacs.
+
+;;; License:
+
+;; This file is part of evil-matchit
+;;
+;; evil-matchit 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 of the License, or
+;; (at your option) any later version.
+;;
+;; evil-matchit 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, see <http://www.gnu.org/licenses/>.
+
+
+;;; Code:
+
+(require 'evil-matchit)
+
+(defun evilmi--simple-find-open-brace (cur-line)
+  (let (rlt)
+    (if (string-match "^[ \t]*[a-zA-Z0-9]+.*{ *$" cur-line)
+        (setq rlt 1)
+      (save-excursion
+        (forward-line)
+        (setq cur-line (buffer-substring-no-properties
+                        (line-beginning-position) (line-end-position)))
+        (if (string-match "^[ \t]*{ *$" cur-line)
+            (setq rlt 2)
+          )
+        )
+      )
+    rlt
+    )
+  )
+
+;;;###autoload
+(defun evilmi-simple-get-tag ()
+  (let (p
+        forward-line-num
+        rlt
+        (cur-line (buffer-substring-no-properties
+                   (line-beginning-position) (line-end-position)))
+        )
+
+    ;; only handle open tag
+    (if (not (memq (following-char) (string-to-list "{[(}}])")))
+        (if (setq forward-line-num (evilmi--simple-find-open-brace cur-line))
+            (when forward-line-num
+              (setq p (line-beginning-position))
+              (forward-line (1- forward-line-num))
+              (search-forward "{" nil nil)
+              (backward-char)
+              (setq rlt (list p))
+              )
+          )
+      (setq rlt (list (point)))
+      )
+    rlt
+    )
+  )
+
+;;;###autoload
+(defun evilmi-simple-jump (rlt NUM)
+  (if rlt (evil-jump-item))
+  (1+ (point))
+  )
+
+(provide 'evil-matchit-simple)
\ No newline at end of file
diff --git a/evil-matchit.el b/evil-matchit.el
index f27ada90c9..eeaeee6e25 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -111,6 +111,10 @@
           )
         '(web-mode html-mode nxml-mode nxhtml-mode sgml-mode))
 
+  ;; simple matching for languages containing "{(["
+  (autoload 'evilmi-simple-get-tag "evil-matchit-simple" nil t)
+  (autoload 'evilmi-simple-jump "evil-matchit-simple" nil t)
+
   ;; latex
   (autoload 'evilmi-latex-get-tag "evil-matchit-latex" nil t)
   (autoload 'evilmi-latex-jump "evil-matchit-latex" nil t)
@@ -200,34 +204,6 @@
   evil-matchit-mode turn-on-evil-matchit-mode
   "Global minor mode to emulate matchit.vim")
 
-;; @return (list position-first-char tag-type tag-keyword)
-
-;; {{ simple find/jump
-;; @return (list position-first-char tag-type tag-keyword) or nil
-(defun evilmi-simple-get-tag ()
-  (interactive)
-  (let ((char (following-char))
-        (tag-type -1)
-        (tag-keyword "")
-        (rlt nil)
-        )
-
-    (if (memq char (string-to-list "{[("))
-        (setq rlt (list (point) 0 (char-to-string char)))
-      )
-    (if (memq char (string-to-list "}])"))
-        (setq rlt (list (point) 1 (char-to-string char)))
-      )
-    rlt
-    )
-  )
-
-(defun evilmi-simple-jump (rlt NUM)
-  (interactive)
-  (evil-jump-item)
-  )
-;; }}
-
 (provide 'evil-matchit)
 
 ;;; evil-matchit.el ends here



reply via email to

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