[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 2ea15db747 185/244: improve ruby matching alg
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 2ea15db747 185/244: improve ruby matching algorithm (fixed item 1 of #114) |
Date: |
Thu, 6 Jan 2022 02:59:00 -0500 (EST) |
branch: elpa/evil-matchit
commit 2ea15db747faf184c1f676b62372d28d3e2a74c8
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
improve ruby matching algorithm (fixed item 1 of #114)
---
evil-matchit-sdk.el | 52 +++++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index f81de4c9b8..34ecd2698d 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -106,9 +106,8 @@ is-function-exit-point could be unknown status"
(setq item (nth j items))
(setq found (and (or (stringp item) (listp item))
(evilmi-sdk-member keyword item)))
- (if (not found)
- (setq j (1+ j))))
- (if (not found) (setq i (1+ i))))
+ (unless found (setq j (1+ j))))
+ (unless found (setq i (1+ i))))
(when found
;; function exit point maybe?
(if (nth 3 (nth i match-tags))
@@ -120,6 +119,17 @@ is-function-exit-point could be unknown status"
(if evilmi-debug (message "evilmi-sdk-get-tag-info called => %s %s. rlt=%s"
keyword match-tags rlt))
rlt))
+(defun evilmi--sdk-check-keyword (keyword begin end)
+ "KEYWORD has valid keyword font space between BEGIN and END."
+ (let* (rlt)
+ (save-excursion
+ (goto-char begin)
+ (while (search-forward keyword end t)
+ (when (not (evilmi-among-fonts-p (point)
+ evilmi-ignored-fonts))
+ (setq rlt keyword))))
+ rlt))
+
(defun evilmi--sdk-extract-keyword (cur-line match-tags howtos)
"Extract keyword from CUR-LINE. Keyword is defined in MATCH-TAGS."
(let* (keyword howto (i 0))
@@ -127,22 +137,16 @@ is-function-exit-point could be unknown status"
(setq howto (nth i howtos))
(when (string-match (nth 0 howto) cur-line)
;; keyword should be trimmed because FORTRAN use "else if"
- (setq keyword (evilmi-sdk-trim-string (match-string (nth 1 howto)
cur-line) ))
- ;; (message "keyword=%s" keyword)
-
+ (setq keyword (evilmi-sdk-trim-string (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)))
+ (unless (evilmi-sdk-member keyword match-tags) (setq keyword nil)))
(setq i (1+ i)))
- (when keyword
- ;; ignore text with specific font
- (save-excursion
- (goto-char (line-beginning-position))
- (when (and (search-forward keyword (line-end-position) t)
- (evilmi-among-fonts-p (point)
- evilmi-ignored-fonts))
- (setq keyword nil))))
- keyword))
+ (and keyword
+ (evilmi--sdk-check-keyword keyword
+ (line-beginning-position)
+ (line-end-position)))))
(defun evilmi--is-monogamy (tag-info)
(and (nth 2 tag-info) (string= (nth 2 tag-info) "MONOGAMY")))
@@ -165,20 +169,18 @@ is-function-exit-point could be unknown status"
;;;###autoload
(defun evilmi-sdk-get-tag (match-tags howtos)
"Return '(start-point ((row column is-function-exit-point keyword))."
- (let* (rlt
- (cur-line (evilmi-sdk-curline))
+ (let* ((cur-line (evilmi-sdk-curline))
(keyword (evilmi--sdk-extract-keyword cur-line match-tags howtos))
(tag-info (if keyword (evilmi-sdk-get-tag-info keyword match-tags))))
;; since we mixed ruby and lua mode here
;; maybe we should be strict at the keyword
- (if tag-info
- ;; 0 - open tag; 1 - middle tag; 2 - close tag;
- (setq rlt (list (if (= 2 (nth 1 tag-info))
- (line-end-position)
- (line-beginning-position))
- tag-info)))
- rlt))
+ (and tag-info
+ ;; 0 - open tag; 1 - middle tag; 2 - close tag;
+ (list (if (= 2 (nth 1 tag-info))
+ (line-end-position)
+ (line-beginning-position))
+ tag-info))))
;;;###autoload
(defun evilmi-sdk-jump (rlt num match-tags howtos)
- [nongnu] elpa/evil-matchit 14e23187df 093/244: Put the melpa badges on the same line, (continued)
- [nongnu] elpa/evil-matchit 14e23187df 093/244: Put the melpa badges on the same line, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8b80b3df94 098/244: correct inner text-object in python-mode v2.1.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 1a5c4454a7 111/244: support verilog, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ceb13ad1b3 131/244: use more generic when processing C, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit df642d953d 139/244: add a few APIs, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 5ff747a1ef 125/244: When jumping find the first matching keyword in the current line, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 18cf34bc62 150/244: Update evil-matchit-verilog.el, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit f87f03bbf4 169/244: add generic rule to jump between brackets, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 00ab601346 161/244: support "define_method(method) do |*args|", ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 77c4a0a1d9 175/244: Ocaml: double semicolon matches let., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 2ea15db747 185/244: improve ruby matching algorithm (fixed item 1 of #114),
ELPA Syncer <=
- [nongnu] elpa/evil-matchit e44de538b9 196/244: clean code & doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 574d3c4e45 209/244: emacs 24.4 does not have font-lock-ensure, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 2337748d26 214/244: autoload evilmi-prompt-line-p, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 43a626541d 025/244: support script language, v1.1.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 7ff2b954c0 015/244: user can customize key binding, v0.0.6, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0dea7ddb67 009/244: better match single character tag, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit fbe22f1171 008/244: single file package does not need *-pkg.el, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9df39e73f7 011/244: Merge pull request #7 from purcell/patch-2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 3c98cf064f 018/244: new framework v1.0.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 3e3652a162 012/244: marmalade need *-pkg.el, ELPA Syncer, 2022/01/06