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

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

[nongnu] elpa/evil-matchit c2d3798650 054/244: support template lik PHP,


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit c2d3798650 054/244: support template lik PHP, better algorithm v1.4.0
Date: Thu, 6 Jan 2022 02:58:49 -0500 (EST)

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

    support template lik PHP, better algorithm v1.4.0
---
 README.org                                     |   7 +-
 evil-matchit-c.el                              |  21 +--
 evil-matchit-cmake.el                          |  18 +--
 evil-matchit-javascript.el                     |  10 +-
 evil-matchit-latex.el                          |  14 +-
 evil-matchit-org.el                            |  14 +-
 evil-matchit-pkg.el                            |   2 +-
 evil-matchit-python.el                         |  10 +-
 evil-matchit-ruby.el                           |  28 +---
 evil-matchit-script.el                         |  17 +--
 evil-matchit-sdk.el                            | 186 +++++++++++++++----------
 evil-matchit-sh.el                             |  10 +-
 evil-matchit-simple.el                         |   8 +-
 evil-matchit-sh.el => evil-matchit-template.el |  40 +++---
 evil-matchit.el                                |   9 +-
 15 files changed, 176 insertions(+), 218 deletions(-)

diff --git a/README.org b/README.org
index eba628503f..16d93c679a 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (v1.3.3)
+* evil-matchit (v1.4.0)
 
 Vim [[http://www.vim.org/scripts/script.php?script_id=39][matchit.vim]] by 
Benji Fisher ported into Emacs.
 
@@ -17,6 +17,7 @@ Most modern languages are supported:
 - Ruby
 - Bash
 - Lua
+- PHP
 - Vim script
 - Emacs email (mesage-mode)
 
@@ -157,8 +158,8 @@ I attached the full content of evil-matchit-script.el here:
 The first column contains the open tag(s).
 The second column contains the middle tag(s).
 The third column contains the closed tags(s).
-"
-  )
+The forth *optional* column defines the relationship between open and close 
tags. It could be FN_EXIT or MONOGAMY
+")
 
 ;;;###autoload
 (defun evilmi-script-get-tag ()
diff --git a/evil-matchit-c.el b/evil-matchit-c.el
index 5c7d68f9db..6b427dd57e 100644
--- a/evil-matchit-c.el
+++ b/evil-matchit-c.el
@@ -29,25 +29,14 @@
 
 ;; ruby/bash/lua/vimrc
 (defvar evilmi-c-match-tags
-  '((("ifdef" "ifndef" "if") ("elif" "else")  "endif")
-    ("switch" "case" "default"))
-  "The table we look up match tags. This is a three column table.
-The first column contains the open tag(s).
-The second column contains the middle tag(s).
-The third column contains the closed tags(s).
-"
-  )
+  '((("ifdef" "ifndef" "if") ("elif" "else")  "endif" "MONOGAMY")
+    ("switch" "case" "default" "MONOGAMY")
+    ))
 
 (defvar evilmi-c-extract-keyword-howtos
   '(("^[ \t]*#[ \t]*\\([a-z]+\\)\\( .*\\| *\\)$" 1)
-    ("^[ \t]*\\([a-z]+\\)\\([ (:].*\\| *\\)$" 1))
-  "The list of HOWTO on extracting keyword from current line.
-Each howto is actually a pair. The first element of pair is the regular
-expression to match the current line. The second is the index of sub-matches
-to extract the keyword which starts from one. The sub-match is the match 
defined
-between '\\(' and '\\)' in regular expression.
-"
-  )
+    ("^[ \t]*\\([a-z]+\\)\\([ (:].*\\| *\\)$" 1)
+    ))
 
 ;;;###autoload
 (defun evilmi-c-get-tag ()
diff --git a/evil-matchit-cmake.el b/evil-matchit-cmake.el
index 85d227d483..5281be4e29 100644
--- a/evil-matchit-cmake.el
+++ b/evil-matchit-cmake.el
@@ -37,18 +37,12 @@
 
 ;; CMake (http://www.cmake.org) syntax
 (defvar evilmi-cmake-match-tags
-  '((("if" "IF") ("elseif" "ELSEIF" "else" "ELSE") ("endif" "ENDIF"))
-    (("foreach" "FOREACH") () ("endforeach" "ENDFOREACH"))
-    (("macro" "MACRO") () ("endmacro" "ENDMACRO"))
-    (("while" "WHILE") () ("endwhile" "ENDWHILE"))
-    (("function" "FUNCTION") () ("endfunction" "ENDFUNCTION"))
-    )
-  "The table we look up match tags. This is a three column table.
-The first column contains the open tag(s).
-The second column contains the middle tag(s).
-The third column contains the closed tags(s).
-"
-  )
+  '((("if" "IF") ("elseif" "ELSEIF" "else" "ELSE") ("endif" "ENDIF") 
"MONOGAMY")
+    (("foreach" "FOREACH") () ("endforeach" "ENDFOREACH") "MONOGAMY")
+    (("macro" "MACRO") () ("endmacro" "ENDMACRO") "MONOGAMY")
+    (("while" "WHILE") () ("endwhile" "ENDWHILE") "MONOGAMY")
+    (("function" "FUNCTION") () ("endfunction" "ENDFUNCTION") "MONOGAMY")
+    ))
 
 ;;;###autoload
 (defun evilmi-cmake-get-tag ()
diff --git a/evil-matchit-javascript.el b/evil-matchit-javascript.el
index 5b1ede20cd..524e671ff3 100644
--- a/evil-matchit-javascript.el
+++ b/evil-matchit-javascript.el
@@ -45,9 +45,7 @@
           )
         )
       )
-    rlt
-    )
-  )
+    rlt))
 
 ;;;###autoload
 (defun evilmi-javascript-get-tag ()
@@ -57,7 +55,6 @@
         (cur-line (buffer-substring-no-properties
                    (line-beginning-position) (line-end-position)))
         )
-    (message "evilmi-javascript-get-tag called")
     ;; only handle open tag
     (if (not (memq (following-char) (string-to-list "{[(}}])")))
         (if (setq forward-line-num (evilmi--javascript-find-open-brace 
cur-line))
@@ -71,9 +68,7 @@
           )
       (setq rlt (list (point)))
       )
-    rlt
-    )
-  )
+    rlt))
 
 ;;;###autoload
 (defun evilmi-javascript-jump (rlt NUM)
@@ -85,7 +80,6 @@
                       (line-beginning-position)
                       (line-end-position)))
       ;; hack for javascript
-      (message "cur-line=%s" cur-line)
       (if (or (string-match "^[ \t]*}\)\(.*\)\; *$" cur-line)
               (string-match "^[ \t]*}\(.*\))\; *$" cur-line)
               (string-match "^[ \t]*}\])\; *$" cur-line))
diff --git a/evil-matchit-latex.el b/evil-matchit-latex.el
index 7bfb67c4aa..c64f55293c 100644
--- a/evil-matchit-latex.el
+++ b/evil-matchit-latex.el
@@ -30,14 +30,11 @@
 (defvar evilmi-latex-regexp "\\\\\\([a-zA-Z]+\\(\{[a-zA-Z]+\}\\)?\\)")
 
 (defvar evilmi-latex-match-tags
-  '((("if[a-zA-Z]+" "if") "else" "fi")
-    ("left" nil "right")
+  '((("if[a-zA-Z]+" "if") "else" "fi" "MONOGAMY")
+    ("left" nil "right" "MONOGAMY")
     ("begin[a-z]+" nil "end[a-z]+")
-    ("begin\{[a-z]+\}" nil "end\{[a-z]+\}"))
-  "The table we look up match tags. This is a three column table.
-The first column contains the open tag(s).
-The second column contains the middle tag(s).
-The third column contains the closed tags(s).")
+    ("begin\{[a-z]+\}" nil "end\{[a-z]+\}")
+    ))
 
 
 ;;;###autoload
@@ -72,8 +69,7 @@ The third column contains the closed tags(s).")
                    tag-info
                    ))))
     (if rlt (goto-char cursor-pos))
-    rlt
-    ))
+    rlt))
 
 ;;;###autoload
 (defun evilmi-latex-jump (rlt NUM)
diff --git a/evil-matchit-org.el b/evil-matchit-org.el
index 411ecb65fd..3d7d1e8cf9 100644
--- a/evil-matchit-org.el
+++ b/evil-matchit-org.el
@@ -43,16 +43,10 @@ between '\\(' and '\\)' in regular expression.
   )
 ;; ruby/bash/lua/vimrc
 (defvar evilmi-org-match-tags
-  '((("begin_src" "BEGIN_SRC") () ( "end_src" "END_SRC"))
-    (("begin_example" "BEGIN_EXAMPLE") () ( "end_example" "END_EXAMPLE"))
-    (("begin_html" "BEGIN_HTML") () ( "end_html" "END_HTML"))
-    )
-  "The table we look up match tags. This is a three column table.
-The first column contains the open tag(s).
-The second column contains the middle tag(s).
-The third column contains the closed tags(s).
-"
-  )
+  '((("begin_src" "BEGIN_SRC") () ( "end_src" "END_SRC") "MONOGAMY")
+    (("begin_example" "BEGIN_EXAMPLE") () ( "end_example" "END_EXAMPLE") 
"MONOGAMY")
+    (("begin_html" "BEGIN_HTML") () ( "end_html" "END_HTML") "MONOGAMY")
+    ))
 
 (defun evilmi--get-embedded-language-major-mode ()
   (let ((info (org-edit-src-find-region-and-lang))
diff --git a/evil-matchit-pkg.el b/evil-matchit-pkg.el
index 2cdc74d0e3..dcda1408dc 100644
--- a/evil-matchit-pkg.el
+++ b/evil-matchit-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-matchit" "1.3.3"
+(define-package "evil-matchit" "1.4.0"
                 "Vim matchit ported into Emacs (requires EVIL)")
diff --git a/evil-matchit-python.el b/evil-matchit-python.el
index 2453c3fa96..b3c9a38a9f 100644
--- a/evil-matchit-python.el
+++ b/evil-matchit-python.el
@@ -46,8 +46,7 @@
         0
         )
       )
-    )
-  )
+    ))
 
 ;; jump from else to if, jump from finally to try
 ;; only python need this hack, a wierd language
@@ -274,8 +273,7 @@
               ;; record the latest indented line info
               (setq where-to-jump-in-theory (line-end-position))
               )
-            )
-          )
+            ))
         ;; last line
         (if (= (point-max) (line-end-position)) (setq dendent t))
         )
@@ -285,8 +283,6 @@
       (evilmi--python-move-to-next-open-tag keyword cur-indent)
       )
      )
-    where-to-jump-in-theory
-    )
-  )
+    where-to-jump-in-theory))
 
 (provide 'evil-matchit-python)
diff --git a/evil-matchit-ruby.el b/evil-matchit-ruby.el
index 5d4a5280ad..4fede6e1a2 100644
--- a/evil-matchit-ruby.el
+++ b/evil-matchit-ruby.el
@@ -34,39 +34,23 @@
 (defvar evilmi-ruby-extract-keyword-howtos
   '(("^[ \t]*\\([a-z]+\\)\\( .*\\| *\\)$" 1)
     ("^.* \\(do\\) |[a-z0-9A-Z,|]+|$" 1)
-    )
-  "The list of HOWTO on extracting keyword from current line.
-Each howto is actually a pair. The first element of pair is the regular
-expression to match the current line. The second is the index of sub-matches
-to extract the keyword which starts from one. The sub-match is the match 
defined
-between '\\(' and '\\)' in regular expression.
-")
+    ))
 
 (defvar evilmi-ruby-match-tags
-  '((("unless" "if") ("elsif" "else") ("end"))
+  '((("unless" "if") ("elsif" "else") "end")
     ("begin" ("rescue" "ensure") "end")
-    ("case" ("when" "else") ("end"))
-    (("class" "def" "while" "do" "module" "for" "until") () ("end"))
-    )
-  "The table we look up match tags. This is a three column table.
-The first column contains the open tag(s).
-The second column contains the middle tag(s).
-The third column contains the closed tags(s).
-The forth column is optional, t means the tags could be function exit
-")
+    ("case" ("when" "else") "end")
+    (("class" "def" "while" "do" "module" "for" "until") () "end")
+    ))
 
 ;;;###autoload
 (defun evilmi-ruby-get-tag ()
   (let (rlt)
-    (message "evilmi-ruby-get-tag called")
     (setq rlt (evilmi-sdk-get-tag evilmi-ruby-match-tags 
evilmi-ruby-extract-keyword-howtos))
-    (message "rlt=%s" rlt)
     rlt))
 
 ;;;###autoload
 (defun evilmi-ruby-jump (rlt NUM)
-  (message "evilmi-ruby-jump called")
-  (evilmi-sdk-jump rlt NUM evilmi-ruby-match-tags 
evilmi-ruby-extract-keyword-howtos)
-  )
+  (evilmi-sdk-jump rlt NUM evilmi-ruby-match-tags 
evilmi-ruby-extract-keyword-howtos))
 
 (provide 'evil-matchit-ruby)
diff --git a/evil-matchit-script.el b/evil-matchit-script.el
index 62eca551ae..e4a42140b0 100644
--- a/evil-matchit-script.el
+++ b/evil-matchit-script.el
@@ -33,19 +33,12 @@
 
 ;; ruby/bash/lua/vimrc
 (defvar evilmi-script-match-tags
-  '((("unless" "if") ("elif" "elsif" "elseif" "else") ( "end" "fi" "endif"))
-    ("begin" ("rescue" "ensure") "end")
-    ("case" ("when" "else") ("esac" "end"))
-    (("fun!" "function!" "class" "def" "while" "function" "do") () ("end" 
"endfun" "endfunction"))
+  '((("unless" "if") ("elif" "elsif" "elseif" "else") ( "end" "fi" "endif") "")
+    ("begin" ("rescue" "ensure") "end" "")
+    ("case" ("when" "else") ("esac" "end") "")
+    (("fun!" "function!" "class" "def" "while" "function" "do") () ("end" 
"endfun" "endfunction") "")
     ("repeat" ()  "until")
-    )
-  "The table we look up match tags. This is a three column table.
-The first column contains the open tag(s).
-The second column contains the middle tag(s).
-The third column contains the closed tags(s).
-The forth column is optional, t means the tags could be function exit
-"
-  )
+    ))
 
 ;;;###autoload
 (defun evilmi-script-get-tag ()
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index fd543634d3..d345a1fd02 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -10,8 +10,10 @@ between '\\(' and '\\)' in regular expression.
 ")
 
 (defun evilmi-sdk-tags-is-matched (level orig-tag-info cur-tag-info match-tags)
-  (let (rlt)
-    (if (nth 2 cur-tag-info) ;; handle function exit point
+  (let (rlt
+        (tag-pair-status (nth 2 cur-tag-info)))
+    ;; handle function exit point
+    (if (string= tag-pair-status "FN_EXIT")
         (setq level 1))
 
     (if (= 1 level)
@@ -22,6 +24,9 @@ between '\\(' and '\\)' in regular expression.
               (orig-type (nth 1 orig-tag-info))
               (cur-type (nth 1 cur-tag-info)))
           ;; end tag could be the same
+          (if (and (string= tag-pair-status "MONOGAMY")
+                   (not (= orig-row-idx cur-row-idx)))
+              nil)
           (cond
            ((and (< orig-type 2) (= cur-type 2))
             (setq rlt (evilmi-sdk-member cur-keyword (nth 2 (nth orig-row-idx 
match-tags)))))
@@ -36,26 +41,34 @@ between '\\(' and '\\)' in regular expression.
   "check if KEYWORD exist in LIST"
   (let (rlt)
     (cond
+
      ((not KEYWORD) nil)
+
      ((not LIST) nil)
+
+     ((stringp LIST)
+      (string= LIST KEYWORD))
+
      ((stringp (car LIST))
       (if (string-match (concat "^" (car LIST) "$") KEYWORD) t
         (evilmi-sdk-member KEYWORD (cdr LIST)))
       )
+
      ((listp (car LIST))
       (setq rlt (evilmi-sdk-member KEYWORD (car LIST)))
       (if rlt rlt (evilmi-sdk-member KEYWORD (cdr LIST))))
+
      (t
       ;; just ignore first element
-      (evilmi-sdk-member KEYWORD (cdr LIST))))))
+      (evilmi-sdk-member KEYWORD (cdr LIST)))
+     )))
 
 
 ;;;###autoload
 (defun evilmi-sdk-get-tag-info (KEYWORD match-tags)
   "return (row column is-function-exit-point keyword),
 the row and column marked position in evilmi-mylang-match-tags
-is-function-exit-point could be t or nil
-"
+is-function-exit-point could be 'FN_EXIT' or other status"
   (let (rlt elems elem found i j)
 
     (setq i 0)
@@ -79,8 +92,13 @@ is-function-exit-point could be t or nil
       (if (not found) (setq i (1+ i)))
       )
     (when found
+      ;; function exit point maybe?
       (if (nth 3 (nth i match-tags))
-          (setq rlt (list i j t KEYWORD))
+          (setq rlt (list
+                     i
+                     j
+                     (nth 3 (nth i match-tags))
+                     KEYWORD))
         (setq rlt (list i j nil KEYWORD))
         ))
     rlt
@@ -101,9 +119,20 @@ is-function-exit-point could be t or nil
         )
       (setq i (1+ i))
       )
-    keyword
-    )
-  )
+    keyword))
+
+(defun evilmi--is-monogamy (tag-info)
+  (and (nth 2 tag-info) (string= (nth 2 tag-info) "MONOGAMY")))
+
+(defun evilmi--double-check-tags (i1 i2)
+  (let (rlt)
+    (if (and i1 i2)
+        ;; i1 and i2 should be at same row if either of them is monogamy
+      (if (or (evilmi--is-monogamy i1) (evilmi--is-monogamy i2))
+          (setq rlt (= (nth 0 i1) (nth 0 i2)))
+        (setq rlt t))
+      )
+    rlt))
 
 ;;;###autoload
 (defun evilmi-sdk-get-tag (match-tags howtos)
@@ -142,8 +171,7 @@ is-function-exit-point could be t or nil
                    (line-end-position)))
         keyword
         found
-        where-to-jump-in-theory
-        )
+        where-to-jump-in-theory)
 
     (while (not found)
       (forward-line (if (= orig-tag-type 2) -1 1))
@@ -155,81 +183,85 @@ is-function-exit-point could be t or nil
 
       (when keyword
         (setq cur-tag-info (evilmi-sdk-get-tag-info keyword match-tags))
-        (setq cur-tag-type (nth 1 cur-tag-info))
+        (when (evilmi--double-check-tags cur-tag-info orig-tag-info)
 
-        ;; key algorithm
-        (cond
-         ;; handle open tag
-         ;; open (0) -> mid (1)  found when level is one else ignore
-         ((and (= orig-tag-type 0) (= cur-tag-type 1))
-          (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
-            (back-to-indentation)
-            (setq where-to-jump-in-theory (1- (line-beginning-position)))
-            (setq found t)
+          (setq cur-tag-type (nth 1 cur-tag-info))
+
+          ;; key algorithm
+          (cond
+           ;; handle open tag
+           ;; open (0) -> mid (1)  found when level is one else ignore
+           ((and (= orig-tag-type 0) (= cur-tag-type 1))
+            (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
+              (back-to-indentation)
+              (setq where-to-jump-in-theory (1- (line-beginning-position)))
+              (setq found t)
+              )
             )
-          )
-         ;; open (0) -> closed (2) found when level is zero, level--
-         ((and (= orig-tag-type 0) (= cur-tag-type 2))
-          (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
-            (goto-char (line-end-position))
-            (setq where-to-jump-in-theory (line-end-position))
-            (setq found t)
+
+           ;; open (0) -> closed (2) found when level is zero, level--
+           ((and (= orig-tag-type 0) (= cur-tag-type 2))
+
+            (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
+              (goto-char (line-end-position))
+              (setq where-to-jump-in-theory (line-end-position))
+              (setq found t)
+              )
+            (setq level (1- level))
+            )
+           ;; open (0) -> open (0) level++
+           ((and (= orig-tag-type 0) (= cur-tag-type 0))
+            (setq level (1+ level))
             )
-          (setq level (1- level))
-          )
-         ;; open (0) -> open (0) level++
-         ((and (= orig-tag-type 0) (= cur-tag-type 0))
-          (setq level (1+ level))
-          )
 
-         ;; now handle mid tag
-         ;; mid (1) -> mid (1) found if:
-         ;;   1. level is one
-         ;;   2. the open tag and middle tag are in the same row in 
evilmi-mylang-match-tags
-         ;; else: just ignore
-         ;; level is one means we are not in some embedded loop/conditional 
statements
-         ((and (= orig-tag-type 1) (= cur-tag-type 1))
-
-          (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
-            (back-to-indentation)
-            (setq where-to-jump-in-theory (1- (line-beginning-position)))
-            (setq found t)
+           ;; now handle mid tag
+           ;; mid (1) -> mid (1) found if:
+           ;;   1. level is one
+           ;;   2. the open tag and middle tag are in the same row in 
evilmi-mylang-match-tags
+           ;; else: just ignore
+           ;; level is one means we are not in some embedded loop/conditional 
statements
+           ((and (= orig-tag-type 1) (= cur-tag-type 1))
+
+            (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
+              (back-to-indentation)
+              (setq where-to-jump-in-theory (1- (line-beginning-position)))
+              (setq found t)
+              )
             )
-          )
-         ;; mid (1) -> closed (2) found when level is zero, level --
-         ((and (= orig-tag-type 1) (= cur-tag-type 2))
-          (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
-            (goto-char (line-end-position))
-            (setq where-to-jump-in-theory (line-end-position))
-            (setq found t)
+           ;; mid (1) -> closed (2) found when level is zero, level --
+           ((and (= orig-tag-type 1) (= cur-tag-type 2))
+            (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
+              (goto-char (line-end-position))
+              (setq where-to-jump-in-theory (line-end-position))
+              (setq found t)
+              )
+            (setq level (1- level))
+            )
+           ;; mid (1) -> open (0) level++
+           ((and (= orig-tag-type 1) (= cur-tag-type 0))
+            (setq level (1+ level))
             )
-          (setq level (1- level))
-          )
-         ;; mid (1) -> open (0) level++
-         ((and (= orig-tag-type 1) (= cur-tag-type 0))
-          (setq level (1+ level))
-          )
 
-         ;; now handle closed tag
-         ;; closed (2) -> mid (1) ignore,impossible
-         ((and (= orig-tag-type 2) (= cur-tag-type 1))
-          )
-         ;; closed (2) -> closed (2) level++
-         ((and (= orig-tag-type 2) (= cur-tag-type 2))
-          (setq level (1+ level))
-          )
-         ;; closed (2) -> open (0) found when level is zero, level--
-         ((and (= orig-tag-type 2) (= cur-tag-type 0))
-          (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
-            (setq where-to-jump-in-theory (line-beginning-position))
-            (back-to-indentation)
-            (setq found t)
+           ;; now handle closed tag
+           ;; closed (2) -> mid (1) ignore,impossible
+           ((and (= orig-tag-type 2) (= cur-tag-type 1))
+            )
+           ;; closed (2) -> closed (2) level++
+           ((and (= orig-tag-type 2) (= cur-tag-type 2))
+            (setq level (1+ level))
             )
-          (setq level (1- level))
+           ;; closed (2) -> open (0) found when level is zero, level--
+           ((and (= orig-tag-type 2) (= cur-tag-type 0))
+            (when (evilmi-sdk-tags-is-matched level orig-tag-info cur-tag-info 
match-tags)
+              (setq where-to-jump-in-theory (line-beginning-position))
+              (back-to-indentation)
+              (setq found t)
+              )
+            (setq level (1- level))
+            )
+           (t (message "why here?"))
+           )
           )
-         (t (message "why here?"))
-         )
-
         )
 
       ;; we will stop at end or beginning of buffer anyway
diff --git a/evil-matchit-sh.el b/evil-matchit-sh.el
index de142a5ce7..71277fb55c 100644
--- a/evil-matchit-sh.el
+++ b/evil-matchit-sh.el
@@ -35,15 +35,9 @@
 (defvar evilmi-sh-match-tags
   '((("if") ("elif" "else") ("fi"))
     ("case" (";;") ("esac"))
-    ("function" ("exit") ("\}") t)
+    ("function" ("exit") ("\}") "FN_EXIT")
     (("for" "do" "while" "until") () ("done"))
-    )
-  "The table we look up match tags. This is a three column table.
-The first column contains the open tag(s).
-The second column contains the middle tag(s).
-The third column contains the closed tags(s).
-"
-  )
+    ))
 
 (defvar evilmi-sh-extract-keyword-howtos
   '(("^[ \t]*\\([a-z]+\\)\\( .*\\| *\\)$" 1)
diff --git a/evil-matchit-simple.el b/evil-matchit-simple.el
index c0536833c7..1a123a4790 100644
--- a/evil-matchit-simple.el
+++ b/evil-matchit-simple.el
@@ -44,9 +44,7 @@
           )
         )
       )
-    rlt
-    )
-  )
+    rlt))
 
 ;;;###autoload
 (defun evilmi-simple-get-tag ()
@@ -70,9 +68,7 @@
           )
       (setq rlt (list (point)))
       )
-    rlt
-    )
-  )
+    rlt))
 
 ;;;###autoload
 (defun evilmi-simple-jump (rlt NUM)
diff --git a/evil-matchit-sh.el b/evil-matchit-template.el
similarity index 56%
copy from evil-matchit-sh.el
copy to evil-matchit-template.el
index de142a5ce7..88dd969a9b 100644
--- a/evil-matchit-sh.el
+++ b/evil-matchit-template.el
@@ -1,4 +1,4 @@
-;;; evil-matchit-sh.el ---sh (bash/zsh) plugin of evil-matchit
+;;; evil-matchit-template.el --- web template plugin of evil-matchit
 
 ;; Copyright (C) 2014  Chen Bin <chenbin.sh@gmail.com>
 
@@ -31,34 +31,26 @@
 ;; All you need to do is just define the match-tags for SDK algorithm to 
lookup.
 (require 'evil-matchit-sdk)
 
-;; ruby/bash/lua/vimrc
-(defvar evilmi-sh-match-tags
-  '((("if") ("elif" "else") ("fi"))
-    ("case" (";;") ("esac"))
-    ("function" ("exit") ("\}") t)
-    (("for" "do" "while" "until") () ("done"))
-    )
-  "The table we look up match tags. This is a three column table.
-The first column contains the open tag(s).
-The second column contains the middle tag(s).
-The third column contains the closed tags(s).
-"
-  )
+(defvar evilmi-template-extract-keyword-howtos
+  '(("^[ \t]*<\\?php +\\([a-z]+\\).*$" 1)
+    ))
 
-(defvar evilmi-sh-extract-keyword-howtos
-  '(("^[ \t]*\\([a-z]+\\)\\( .*\\| *\\)$" 1)
-    ("^.*\\(;;\\) *$" 1)
-    ("^\\(\} *\\)" 1)
+(defvar evilmi-template-match-tags
+  '(("if" ("elseif" "else") "endif" "MONOGAMY")
+    ("foreach" () "endforeach" "MONOGAMY")
+    ("for" () "endfor" "MONOGAMY")
+    ("while" () "endwhile" "MONOGAMY")
     ))
 
 ;;;###autoload
-(defun evilmi-sh-get-tag ()
-  (evilmi-sdk-get-tag evilmi-sh-match-tags evilmi-sh-extract-keyword-howtos)
-  )
+(defun evilmi-template-get-tag ()
+  (let (rlt)
+    (setq rlt (evilmi-sdk-get-tag evilmi-template-match-tags 
evilmi-template-extract-keyword-howtos))
+    rlt))
 
 ;;;###autoload
-(defun evilmi-sh-jump (rlt NUM)
-  (evilmi-sdk-jump rlt NUM evilmi-sh-match-tags 
evilmi-sh-extract-keyword-howtos)
+(defun evilmi-template-jump (rlt NUM)
+  (evilmi-sdk-jump rlt NUM evilmi-template-match-tags 
evilmi-template-extract-keyword-howtos)
   )
 
-(provide 'evil-matchit-sh)
+(provide 'evil-matchit-template)
diff --git a/evil-matchit.el b/evil-matchit.el
index 280c97badd..946b9b85d5 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.3
+;; Version: 1.4.0
 ;; Keywords: matchit vim evil
 ;; Package-Requires: ((evil "1.0.7"))
 ;;
@@ -97,10 +97,13 @@
         '(js-mode js2-mode js3-mode javascript-mode))
 
   ;; Html
+  (autoload 'evilmi-template-get-tag "evil-matchit-template" nil)
+  (autoload 'evilmi-template-jump "evil-matchit-template" nil)
   (autoload 'evilmi-html-get-tag "evil-matchit-html" nil)
   (autoload 'evilmi-html-jump "evil-matchit-html" nil)
   (mapc (lambda (mode)
-          (plist-put evilmi-plugins mode '((evilmi-simple-get-tag 
evilmi-simple-jump)
+          (plist-put evilmi-plugins mode '((evilmi-template-get-tag 
evilmi-template-jump)
+                                           (evilmi-simple-get-tag 
evilmi-simple-jump)
                                            (evilmi-html-get-tag 
evilmi-html-jump)))
           )
         '(web-mode html-mode nxml-mode nxhtml-mode sgml-mode message-mode))
@@ -185,7 +188,7 @@
    ))
 
 ;;;###autoload
-(defun evilmi-version() (interactive) (message "1.3.3"))
+(defun evilmi-version() (interactive) (message "1.4.0"))
 
 ;;;###autoload
 (define-minor-mode evil-matchit-mode



reply via email to

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