[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 8b71b42603 041/244: better support for sh and
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 8b71b42603 041/244: better support for sh and c/c++ v1.2.8 |
Date: |
Thu, 6 Jan 2022 02:58:48 -0500 (EST) |
branch: elpa/evil-matchit
commit 8b71b42603bc7a5d5f61d9076110e499348bcc74
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
better support for sh and c/c++ v1.2.8
- support "case" in sh-mode
- support "function" and "exit" in sh-mode
- support "switch" in c/c++
---
README.org | 2 +-
evil-matchit-c.el | 5 ++-
evil-matchit-pkg.el | 2 +-
evil-matchit-script.el | 1 +
evil-matchit-sdk.el | 52 +++++++++++++++++++---------
evil-matchit-script.el => evil-matchit-sh.el | 29 +++++++++-------
evil-matchit.el | 15 +++++---
pkg.sh | 2 +-
8 files changed, 68 insertions(+), 40 deletions(-)
diff --git a/README.org b/README.org
index f60d499e6c..15c3022d83 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (version 1.2.7)
+* evil-matchit (version 1.2.8)
Vim [[http://www.vim.org/scripts/script.php?script_id=39][matchit.vim]] by
Benji Fisher ported into Emacs.
diff --git a/evil-matchit-c.el b/evil-matchit-c.el
index 66db35ddc5..386f599bcb 100644
--- a/evil-matchit-c.el
+++ b/evil-matchit-c.el
@@ -30,7 +30,7 @@
;; 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).
@@ -40,8 +40,7 @@ The third column contains the closed tags(s).
(defvar evilmi-c-extract-keyword-howtos
'(("^[ \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
diff --git a/evil-matchit-pkg.el b/evil-matchit-pkg.el
index 1e98e06c5d..144e6893f1 100644
--- a/evil-matchit-pkg.el
+++ b/evil-matchit-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-matchit" "1.2.7"
+(define-package "evil-matchit" "1.2.8"
"Vim matchit ported into Emacs (requires EVIL)")
diff --git a/evil-matchit-script.el b/evil-matchit-script.el
index 5e279261b5..62eca551ae 100644
--- a/evil-matchit-script.el
+++ b/evil-matchit-script.el
@@ -43,6 +43,7 @@
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
"
)
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index eb3d8d7d4f..73b1aaacd1 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -11,6 +11,14 @@ between '\\(' and '\\)' in regular expression.
)
+(defun evilmi-sdk-tags-match (level orig-tag-info cur-tag-info)
+ (let (rlt)
+ (when (nth 2 cur-tag-info) ;; handle function exit point
+ (setq level 1)
+ )
+ (setq rlt (and (= 1 level) (= (nth 0 orig-tag-info) (nth 0 cur-tag-info))))
+ ))
+
;;;###autoload
(defun evilmi-sdk-member (KEYWORD LIST)
"check if KEYWORD exist in LIST"
@@ -32,9 +40,12 @@ between '\\(' and '\\)' in regular expression.
;;;###autoload
(defun evilmi-sdk-get-tag-info (tag match-tags)
- "return (row column)"
+ "return (row column is-function-exit-point),
+the row and column marked position in evilmi-mylang-match-tags
+is-function-exit-point could be t or nil
+"
(let (rlt elems elem tag-type
- found i j)
+ found i j)
(setq i 0)
(while (and (< i (length match-tags)) (not found))
@@ -56,10 +67,13 @@ between '\\(' and '\\)' in regular expression.
)
(if (not found) (setq i (1+ i)))
)
- (if found (setq rlt (list i j)))
+ (when found
+ (if (nth 3 (nth i match-tags))
+ (setq rlt (list i j t))
+ (setq rlt (list i j))
+ ))
rlt
- )
- )
+ ))
(defun evilmi--sdk-extract-keyword (cur-line match-tags howtos)
"extract keyword from cur-line. keyword should be defined in match-tags"
@@ -69,7 +83,6 @@ between '\\(' and '\\)' in regular expression.
(setq howto (nth i howtos))
(when (string-match (nth 0 howto) cur-line)
(setq keyword (match-string (nth 1 howto) cur-line))
-
;; keep search keyword by using next howto (regex and match-string
index)
(if (not (evilmi-sdk-member keyword match-tags)) (setq keyword nil))
)
@@ -107,7 +120,6 @@ between '\\(' and '\\)' in regular expression.
)
)
-
;;;###autoload
(defun evilmi-sdk-jump (rlt NUM match-tags howtos)
(let ((orig-tag-type (nth 1 (nth 1 rlt)))
@@ -131,8 +143,10 @@ between '\\(' and '\\)' in regular expression.
)
(setq keyword (evilmi--sdk-extract-keyword cur-line match-tags howtos))
+ ;; (message "keyword=%s cur-line=%s" keyword cur-line)
(when keyword
+
(setq cur-tag-info (evilmi-sdk-get-tag-info keyword match-tags))
(setq cur-tag-type (nth 1 cur-tag-info))
@@ -141,7 +155,7 @@ between '\\(' and '\\)' in regular expression.
;; handle open tag
;; open (0) -> mid (1) found when level is one else ignore
((and (= orig-tag-type 0) (= cur-tag-type 1))
- (when (= 1 level)
+ (when (evilmi-sdk-tags-match level orig-tag-info cur-tag-info)
(back-to-indentation)
(setq where-to-jump-in-theory (1- (line-beginning-position)))
(setq found t)
@@ -149,13 +163,12 @@ between '\\(' and '\\)' in regular expression.
)
;; open (0) -> closed (2) found when level is zero, level--
((and (= orig-tag-type 0) (= cur-tag-type 2))
- (setq level (1- level))
-
- (when (= 0 level)
+ (when (evilmi-sdk-tags-match level orig-tag-info cur-tag-info)
(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))
@@ -163,9 +176,14 @@ between '\\(' and '\\)' in regular expression.
)
;; now handle mid tag
- ;; mid (1) -> mid (1) found when level is zero else ignore
+ ;; 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 (= 1 level)
+
+ (when (evilmi-sdk-tags-match level orig-tag-info cur-tag-info)
(back-to-indentation)
(setq where-to-jump-in-theory (1- (line-beginning-position)))
(setq found t)
@@ -173,12 +191,12 @@ between '\\(' and '\\)' in regular expression.
)
;; mid (1) -> closed (2) found when level is zero, level --
((and (= orig-tag-type 1) (= cur-tag-type 2))
- (setq level (1- level))
- (when (= 0 level)
+ (when (evilmi-sdk-tags-match level orig-tag-info cur-tag-info)
(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))
@@ -195,12 +213,12 @@ between '\\(' and '\\)' in regular expression.
)
;; closed (2) -> open (0) found when level is zero, level--
((and (= orig-tag-type 2) (= cur-tag-type 0))
- (setq level (1- level))
- (when (= 0 level)
+ (when (evilmi-sdk-tags-match level orig-tag-info cur-tag-info)
(setq where-to-jump-in-theory (line-beginning-position))
(back-to-indentation)
(setq found t)
)
+ (setq level (1- level))
)
(t (message "why here?"))
)
diff --git a/evil-matchit-script.el b/evil-matchit-sh.el
similarity index 68%
copy from evil-matchit-script.el
copy to evil-matchit-sh.el
index 5e279261b5..de142a5ce7 100644
--- a/evil-matchit-script.el
+++ b/evil-matchit-sh.el
@@ -1,4 +1,4 @@
-;;; evil-matchit-script.el ---script (ruby/lua) plugin of evil-matchit
+;;; evil-matchit-sh.el ---sh (bash/zsh) plugin of evil-matchit
;; Copyright (C) 2014 Chen Bin <chenbin.sh@gmail.com>
@@ -32,12 +32,11 @@
(require 'evil-matchit-sdk)
;; 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"))
- ("repeat" () "until")
+(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).
@@ -46,14 +45,20 @@ The third column contains the closed tags(s).
"
)
+(defvar evilmi-sh-extract-keyword-howtos
+ '(("^[ \t]*\\([a-z]+\\)\\( .*\\| *\\)$" 1)
+ ("^.*\\(;;\\) *$" 1)
+ ("^\\(\} *\\)" 1)
+ ))
+
;;;###autoload
-(defun evilmi-script-get-tag ()
- (evilmi-sdk-get-tag evilmi-script-match-tags
evilmi-sdk-extract-keyword-howtos)
+(defun evilmi-sh-get-tag ()
+ (evilmi-sdk-get-tag evilmi-sh-match-tags evilmi-sh-extract-keyword-howtos)
)
;;;###autoload
-(defun evilmi-script-jump (rlt NUM)
- (evilmi-sdk-jump rlt NUM evilmi-script-match-tags
evilmi-sdk-extract-keyword-howtos)
+(defun evilmi-sh-jump (rlt NUM)
+ (evilmi-sdk-jump rlt NUM evilmi-sh-match-tags
evilmi-sh-extract-keyword-howtos)
)
-(provide 'evil-matchit-script)
+(provide 'evil-matchit-sh)
diff --git a/evil-matchit.el b/evil-matchit.el
index 176975a58d..851d30910d 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.2.7
+;; Version: 1.2.8
;; Keywords: matchit vim evil
;; Package-Requires: ((evil "1.0.7"))
;;
@@ -120,8 +120,8 @@
(autoload 'evilmi-c-get-tag "evil-matchit-c" nil)
(autoload 'evilmi-c-jump "evil-matchit-c" nil)
(mapc (lambda (mode)
- (plist-put evilmi-plugins mode '((evilmi-simple-get-tag
evilmi-simple-jump)
- (evilmi-c-get-tag evilmi-c-jump)))
+ (plist-put evilmi-plugins mode '((evilmi-c-get-tag evilmi-c-jump)
+ (evilmi-simple-get-tag
evilmi-simple-jump)))
)
'(c-mode c++-mode))
@@ -130,14 +130,19 @@
(autoload 'evilmi-cmake-jump "evil-matchit-cmake" nil)
(plist-put evilmi-plugins 'cmake-mode '((evilmi-cmake-get-tag
evilmi-cmake-jump)))
- ;; Bash/Lua/Ruby ... any normal script languages
+ ;; sh-mode
+ (autoload 'evilmi-sh-get-tag "evil-matchit-sh" nil)
+ (autoload 'evilmi-sh-jump "evil-matchit-sh" nil)
+ (plist-put evilmi-plugins 'sh-mode '((evilmi-sh-get-tag evilmi-sh-jump)))
+
+ ;; Lua/Ruby ... any normal script languages
(autoload 'evilmi-script-get-tag "evil-matchit-script" nil)
(autoload 'evilmi-script-jump "evil-matchit-script" nil)
(mapc (lambda (mode)
(plist-put evilmi-plugins mode '((evilmi-simple-get-tag
evilmi-simple-jump)
(evilmi-script-get-tag
evilmi-script-jump)))
)
- '(lua-mode sh-mode ruby-mode vimrc-mode))
+ '(lua-mode ruby-mode vimrc-mode))
)
;;;###autoload
diff --git a/pkg.sh b/pkg.sh
index eb6710736c..21c7430c7e 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-pkg=evil-matchit-1.2.7
+pkg=evil-matchit-1.2.8
mkdir $pkg
cp README.org $pkg
cp *.el $pkg
- [nongnu] elpa/evil-matchit 0fd65c463b 226/244: clean code&doc, (continued)
- [nongnu] elpa/evil-matchit 0fd65c463b 226/244: clean code&doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ceec6a63b0 236/244: better algorithm to match bracket/brace in javascript, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8c4f516265 238/244: Support matlab-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 82c80786e5 240/244: jump between merge conflict markers, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 5c43939d01 212/244: Merge pull request #126 from neojski/more-ocaml-tests, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit cdb9b90381 229/244: extra json support, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d005e0465e 223/244: Merge pull request #130 from nbfalcon/bugfix/evilmi-sdk-simple-jump-whitespace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ce90eae4bd 243/244: typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit a0c5bd1fe8 230/244: support quote and export section in org file, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9cdaddd55d 228/244: Merge pull request #132 from aaronjensen/require-evil-macros, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8b71b42603 041/244: better support for sh and c/c++ v1.2.8,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit 4846518b59 109/244: support rjsx-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0b0e6d61a6 119/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8a10046f25 145/244: fix python issue, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0d62d497d1 143/244: Fix typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4435f3ada5 128/244: evil-matchit-org: add :results: :end: drawer, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit a91ea21c4a 141/244: Fix typo in readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit fb5807c096 129/244: Merge pull request #82 from et2010/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4f3928db11 157/244: let evil-repeat ignore evilmi jump, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 43be86d8c4 171/244: support css-in-js styled components, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 2fc961d94b 122/244: fixed css-mode minor issue, ELPA Syncer, 2022/01/06