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

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

[nongnu] elpa/evil-matchit bc31e7d594 199/244: clean code


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit bc31e7d594 199/244: clean code
Date: Thu, 6 Jan 2022 02:59:01 -0500 (EST)

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

    clean code
---
 evil-matchit-markdown.el    |  2 +-
 evil-matchit-sdk.el         | 17 +++++------------
 tests/evil-matchit-tests.el |  1 -
 3 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/evil-matchit-markdown.el b/evil-matchit-markdown.el
index 41c34cfa7c..550e0d4bb9 100644
--- a/evil-matchit-markdown.el
+++ b/evil-matchit-markdown.el
@@ -42,7 +42,7 @@ Return (list start-position tag)."
         (let* ((str (match-string 1 cur-line))
                (prefix (buffer-substring-no-properties (point-min)
                                                        
(line-beginning-position)))
-               (forward-direction (evilmi-evenp (evilmi-count-matches str 
prefix))))
+               (forward-direction (eq (% (evilmi-sdk-count-matches str prefix) 
2) 0)))
           (setq rlt (list (if forward-direction (line-beginning-position)
                             (line-end-position))
                           forward-direction
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index cf898366c0..0f96387ba1 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -1,4 +1,5 @@
 (require 'evil nil t)
+(require 'subr-x)
 
 (defvar evilmi-debug nil
   "Debug flag.")
@@ -274,7 +275,6 @@ Rule is looked up in HOWTOS."
       (setq howto (nth i howtos))
       (when (string-match (nth 0 howto) cur-line)
         ;; keyword should be trimmed because FORTRAN use "else if"
-        (unless (featurep 'subr-x) (require 'subr-x))
         (setq keyword (string-trim (match-string (nth 1 howto) cur-line)))
         ;; keep search keyword by using next howto (regex and match-string 
index)
         (unless (evilmi-sdk-member keyword match-tags) (setq keyword nil)))
@@ -289,7 +289,7 @@ Rule is looked up in HOWTOS."
   (and (nth 2 tag-info) (string= (nth 2 tag-info) "MONOGAMY")))
 
 (defun evilmi-sdk-exactly-same-type-p (crt orig)
-  (= (nth 0 crt) (nth 0 orig)))
+  (eq (nth 0 crt) (nth 0 orig)))
 
 (defun evilmi-sdk-same-type (crt orig)
   (when (and crt orig)
@@ -425,9 +425,6 @@ after calling this function."
                     (member f fonts))
                   fontfaces))))
 
-(defun evilmi-empty-line-p (line)
-  (string-match "^[ \t]*$" line))
-
 (defun evilmi-next-non-empty-line ()
   "Return next non-empty line content or nil."
   (let* ((b (line-beginning-position))
@@ -441,7 +438,7 @@ after calling this function."
       (while (and continue (> (point) e))
         (setq line (evilmi-sdk-curline))
         (cond
-         ((evilmi-empty-line-p line)
+         ((string-blank-p line)
           (setq b (line-beginning-position))
           (setq e (line-end-position))
           (forward-line))
@@ -450,14 +447,10 @@ after calling this function."
           (setq rlt line)))))
     rlt))
 
-;;;###autoload
-(defun evilmi-evenp (num)
-  (= (% num 2) 0))
-
-(defun evilmi-count-matches (regexp str)
+(defun evilmi-sdk-count-matches (regexp str)
+  "Count matches of regexp in STR."
   (let* ((count 0)
          (start 0))
-    (unless start (setq start 0))
     (while (string-match regexp str start)
       (setq count (1+ count))
       (setq start (match-end 0)))
diff --git a/tests/evil-matchit-tests.el b/tests/evil-matchit-tests.el
index 697f09a67b..bddc0eebb7 100644
--- a/tests/evil-matchit-tests.el
+++ b/tests/evil-matchit-tests.el
@@ -173,7 +173,6 @@
                                         ; jump back
     (evilmi-jump-items)
     (should (eq (following-char) ?{))
-    (message "(point)=%s" (point))
     (should (string-match "switch(c)" (evilmi-sdk-curline) ))
 
     (should (eq major-mode 'c-mode))))



reply via email to

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