[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 4101ee2432 130/244: handle 'switch' in C prop
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 4101ee2432 130/244: handle 'switch' in C properly |
Date: |
Thu, 6 Jan 2022 02:58:56 -0500 (EST) |
branch: elpa/evil-matchit
commit 4101ee2432988bce0d3eb3a93e0c1d2b9e2a6ec5
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
handle 'switch' in C properly
---
README.org | 2 +-
evil-matchit-c.el | 21 ++++++++++++++++++++-
evil-matchit-sdk.el | 49 +++++++++++++++++++++----------------------------
evil-matchit.el | 4 ++--
pkg.sh | 2 +-
5 files changed, 45 insertions(+), 33 deletions(-)
diff --git a/README.org b/README.org
index 2f2b07a802..5add38bbdc 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (v2.2.3)
+* evil-matchit (v2.2.4)
[[http://melpa.org/#/evil-matchit][file:http://melpa.org/packages/evil-matchit-badge.svg]]
[[http://stable.melpa.org/#/evil-matchit][file:http://stable.melpa.org/packages/evil-matchit-badge.svg]]
diff --git a/evil-matchit-c.el b/evil-matchit-c.el
index 442a60aa8f..eb27ecc9f0 100644
--- a/evil-matchit-c.el
+++ b/evil-matchit-c.el
@@ -44,6 +44,25 @@
;;;###autoload
(defun evilmi-c-jump (rlt NUM)
- (evilmi-sdk-jump rlt NUM evilmi-c-match-tags
evilmi-c-extract-keyword-howtos))
+ (let* ((old-pos (point))
+ (pos (evilmi-sdk-jump rlt NUM evilmi-c-match-tags
evilmi-c-extract-keyword-howtos))
+ (orig-tag (and rlt (nth 3 (cadr rlt)))))
+
+ ;; Place cursor over last case of 'switch' statement and press %:
+ ;; Should go back to beginning of switch:
+ ;; switch(c) {
+ ;; case 'a':
+ ;; break;
+ ;; case 'b':
+ ;; break;
+ ;; }
+ (when (and (string= orig-tag "case")
+ ;; failed to find matching tag
+ (not pos))
+ (goto-char old-pos)
+ ;; Goto outer bracket
+ (c-beginning-of-defun)
+ (setq pos (beginning-of-line)))
+ pos))
(provide 'evil-matchit-c)
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index 2655f96c90..ce7e6fdd06 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -163,6 +163,9 @@ is-function-exit-point could be unknown status"
;;;###autoload
(defun evilmi-sdk-jump (rlt num match-tags howtos)
+ "Use RLT, NUM, MATCH-TAGS and HOWTOS to jump.
+Return nil if no matching tag found. Please note (point) is changed
+after calling this function."
(let* ((orig-tag-type (nth 1 (nth 1 rlt)))
(orig-tag-info (nth 1 rlt))
cur-tag-type
@@ -172,7 +175,7 @@ is-function-exit-point could be unknown status"
keyword
found
where-to-jump-in-theory)
- (if evilmi-debug (message "evilmi-sdk-jump called => %s" rlt))
+ (if evilmi-debug (message "evilmi-sdk-jump called => rlt=%s (piont)=%s"
rlt (point)))
(while (not found)
(forward-line (if (= orig-tag-type 2) -1 1))
@@ -183,7 +186,6 @@ is-function-exit-point could be unknown status"
(when keyword
(setq cur-tag-info (evilmi-sdk-get-tag-info keyword match-tags))
(when (evilmi--same-type cur-tag-info orig-tag-info)
-
(setq cur-tag-type (nth 1 cur-tag-info))
;; key algorithm
@@ -198,7 +200,6 @@ is-function-exit-point could be unknown status"
;; 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))
@@ -220,51 +221,43 @@ is-function-exit-point could be unknown status"
(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 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))
- )
+ (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)))
;; now handle closed tag
;; closed (2) -> mid (1) ignore,impossible
- ((and (= orig-tag-type 2) (= cur-tag-type 1))
- )
+ ((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?"))
- )
- )
- )
+ (setq found t))
+ (setq level (1- level)))
+
+ (t (message "why here?")))))
;; we will stop at end or beginning of buffer anyway
(if (or (= (line-end-position) (point-max))
- (= (line-beginning-position) (point-min))
- )
- (setq found t)
- ))
+ (= (line-beginning-position) (point-min)))
+ (setq found t)))
+
where-to-jump-in-theory))
(defun evilmi-count-matches (regexp str)
diff --git a/evil-matchit.el b/evil-matchit.el
index 7ac63afca1..6c7c3ff485 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: 2.2.3
+;; Version: 2.2.4
;; Keywords: matchit vim evil
;; Package-Requires: ((evil "1.0.7"))
;;
@@ -492,7 +492,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
;;;###autoload
(defun evilmi-version()
(interactive)
- (message "2.2.3"))
+ (message "2.2.4"))
;;;###autoload
(define-minor-mode evil-matchit-mode
diff --git a/pkg.sh b/pkg.sh
index 60f17e0b96..0962b0fd3d 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
#!/bin/bash
name=evil-matchit
-version=2.2.3
+version=2.2.4
pkg=$name-$version
mkdir $pkg
cp README.org $pkg
- [nongnu] elpa/evil-matchit c2d3798650 054/244: support template lik PHP, better algorithm v1.4.0, (continued)
- [nongnu] elpa/evil-matchit c2d3798650 054/244: support template lik PHP, better algorithm v1.4.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 67eec20d48 086/244: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit f981f722df 088/244: avoid hang in python-mode, v2.1.1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0b35f26191 091/244: javascript could use evilmi-simple-*, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 6346825fd8 099/244: less picky about latex tags, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 080639aed3 100/244: clean code and doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit b01763bf76 107/244: initialize evilmi-plugins only once v2.1.5, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 1d55eba1d3 112/244: fix bug on verilog if statement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 01ade592db 114/244: enhance js matching algorithm, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 277623d8be 116/244: support css/less/scss, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4101ee2432 130/244: handle 'switch' in C properly,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit 69299108fd 120/244: Add sig/end matching for ocaml, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 50bb882419 132/244: support elixir, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit e15ad8406b 155/244: Merge pull request #95 from linchen2chris/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit a8a8625fc2 144/244: Merge pull request #90 from Khady/patch-2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 11f57d8f52 142/244: Merge pull request #89 from Khady/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit f471bc97bd 137/244: tsx needs jsx support as well, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0d463ab3da 172/244: Ocaml: add normal parentheses support, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 5cea6fde1c 162/244: clean code and wording, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit fb04ffae4b 176/244: Treat source blocks labelled as "elisp"., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit b00671fb9e 186/244: Mark evilmi-jump-items as a jump motion, ELPA Syncer, 2022/01/06