[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 38df050735 103/244: clean code
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 38df050735 103/244: clean code |
Date: |
Thu, 6 Jan 2022 02:58:53 -0500 (EST) |
branch: elpa/evil-matchit
commit 38df050735e881db392d4ae01a7ab8bc22ce526e
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
clean code
---
evil-matchit-diff.el | 13 +++++--------
evil-matchit-javascript.el | 21 ++++++---------------
evil-matchit-python.el | 44 +++++++++++++-------------------------------
evil-matchit-sdk.el | 44 ++++++++++++++++++--------------------------
evil-matchit-simple.el | 21 +++++++++------------
5 files changed, 51 insertions(+), 92 deletions(-)
diff --git a/evil-matchit-diff.el b/evil-matchit-diff.el
index e654d307ba..d0c978bce6 100644
--- a/evil-matchit-diff.el
+++ b/evil-matchit-diff.el
@@ -26,20 +26,17 @@
;;; Code:
-(defun evilmi--cur-line ()
- (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+(require 'evil-matchit-sdk)
(defun evilmi-diff-guess-final-pos ()
(let* ((final-pos (point)))
(save-excursion
(let* (tmp-line)
(forward-line -1)
- (setq tmp-line (evilmi--cur-line))
+ (setq tmp-line (evilmi-sdk-curline))
(if (string-match-p "^index [0-9a-z]+\\.+[0-9a-z]+ [0-9]+$" tmp-line)
(forward-line -1))
- (setq tmp-line (evilmi--cur-line))
+ (setq tmp-line (evilmi-sdk-curline))
(if (string-match-p "^diff [^ ]" tmp-line)
(forward-line -1))
(setq final-pos (line-end-position))))
@@ -48,7 +45,7 @@
;;;###autoload
(defun evilmi-diff-get-tag ()
;; do nothing
- (let* ((cur-line (evilmi--cur-line))
+ (let* ((cur-line (evilmi-sdk-curline))
(final-pos (point)))
(if (string-match-p "^--- " cur-line)
(save-excursion
@@ -57,7 +54,7 @@
;;;###autoload
(defun evilmi-diff-jump (rlt NUM)
- (let* ((cur-line (evilmi--cur-line))
+ (let* ((cur-line (evilmi-sdk-curline))
(final-pos (point)))
(cond
((string-match-p "^\\+\\+\\+ " cur-line)
diff --git a/evil-matchit-javascript.el b/evil-matchit-javascript.el
index 020915d449..4569d2c3d6 100644
--- a/evil-matchit-javascript.el
+++ b/evil-matchit-javascript.el
@@ -26,9 +26,9 @@
;;; Code:
+(require 'evil-matchit-sdk)
(require 'evil-matchit)
-;; TODO, fn.then().({}, find the second (
(defun evilmi--javascript-find-open-brace (cur-line)
(let (rlt)
;; javascript code line "(function(...) { ..."
@@ -38,13 +38,9 @@
(setq rlt 1)
(save-excursion
(forward-line)
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position) (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
(if (string-match "^[ \t]*{ *$" cur-line)
- (setq rlt 2)
- )
- )
- )
+ (setq rlt 2))))
rlt))
;;;###autoload
@@ -52,8 +48,7 @@
(let (p
forward-line-num
rlt
- (cur-line (buffer-substring-no-properties
- (line-beginning-position) (line-end-position)))
+ (cur-line (evilmi-sdk-curline))
)
;; only handle open tag
(if (not (memq (following-char) (string-to-list "{[(}}])")))
@@ -76,17 +71,13 @@
(when rlt
(evilmi--simple-jump)
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
;; hack for javascript
(if (or (string-match "^[ \t]*}\)\(.*\)\; *$" cur-line)
(string-match "^[ \t]*}\(.*\))\; *$" cur-line)
(string-match "^[ \t]*}\])\; *$" cur-line))
(line-end-position)
- (1+ (point))
- )
- )
+ (1+ (point))))
))
(provide 'evil-matchit-javascript)
diff --git a/evil-matchit-python.el b/evil-matchit-python.el
index 22375b0770..0bad0e570f 100644
--- a/evil-matchit-python.el
+++ b/evil-matchit-python.el
@@ -26,6 +26,7 @@
;;; Code:
+(require 'evil-matchit-sdk)
(require 'evil-matchit)
;; @return number of indent
@@ -53,9 +54,7 @@
keyword
where-to-go
regexp
- (cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position))))
+ (cur-line (evilmi-sdk-curline)))
;; extract keyword from current line
(if (string-match "^[ \t]*\\([a-z]+\\) *.*:\s*\\(#.*\\)?$" cur-line)
@@ -73,27 +72,20 @@
(save-excursion
(while (not out-of-loop)
(forward-line -1)
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
(when (and (= cur-indent (evilmi--python-calculate-indent cur-line))
- (string-match regexp cur-line)
- )
+ (string-match regexp cur-line))
(setq where-to-go (line-beginning-position))
- (setq out-of-loop t)
- )
+ (setq out-of-loop t))
;; if it's first line, we need get out of loop
(if (= (point-min) (line-beginning-position))
- (setq out-of-loop t)
- )
- )
- )
+ (setq out-of-loop t))
+ ))
(when where-to-go
(goto-char where-to-go)
- (skip-chars-forward " \t"))
- )
+ (skip-chars-forward " \t")))
))
(defun evilmi--python-move-to-next-open-tag (keyword cur-indent)
@@ -116,9 +108,7 @@
(save-excursion
(while (not out-of-loop)
(forward-line)
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
(when (= cur-indent (evilmi--python-calculate-indent cur-line))
(if (and regexp (string-match regexp cur-line))
@@ -142,9 +132,7 @@
(defun evilmi-python-get-tag ()
(let (rlt
(regexp "^[ \t]*\\([a-z]+\\) *.*:\s*\\(#.*\\)?$")
- (cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (cur-line (evilmi-sdk-curline))
cur-indent
tag-type
keyword
@@ -176,9 +164,7 @@
(let ((p (nth 0 rlt))
(tag-type (nth 1 rlt))
(keyword (nth 2 rlt))
- (cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (cur-line (evilmi-sdk-curline))
cur-indent
dendent
rlt)
@@ -195,9 +181,7 @@
(while (not dendent)
(forward-line -1)
;; first line
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
(if evilmi-debug (message "cur-line=%s" cur-line))
@@ -215,9 +199,7 @@
;; jump to closed tag
(while (not dendent)
(forward-line)
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
;; just skip empty line
(if (not (string-match "^[ \t]*$" cur-line))
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index e3c8229e88..2335a76013 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -6,8 +6,7 @@
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.
-")
+between '\\(' and '\\)' in regular expression.")
;; slower but I don't care
;; @see http://ergoemacs.org/emacs/modernization_elisp_lib_problem.html
@@ -42,6 +41,12 @@ between '\\(' and '\\)' in regular expression.
)))
rlt))
+;;;###autoload
+(defun evilmi-sdk-curline ()
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position)))
+
;;;###autoload
(defun evilmi-sdk-member (KEYWORD LIST)
"check if KEYWORD exist in LIST"
@@ -85,8 +90,8 @@ is-function-exit-point could be 'FN_EXIT' or other status"
(setq elem (nth j elems))
(setq found (and (or (stringp elem) (listp elem))
(evilmi-sdk-member KEYWORD elem)))
- (if (not found) (setq j (1+ j)))
- )
+ (if (not found)
+ (setq j (1+ j))))
(if (not found) (setq i (1+ i))))
(when found
;; function exit point maybe?
@@ -98,8 +103,7 @@ is-function-exit-point could be 'FN_EXIT' or other status"
KEYWORD))
(setq rlt (list i j nil KEYWORD))
))
- rlt
- ))
+ rlt))
(defun evilmi--sdk-extract-keyword (cur-line match-tags howtos)
"extract keyword from cur-line. keyword should be defined in match-tags"
@@ -117,8 +121,7 @@ is-function-exit-point could be 'FN_EXIT' or other status"
;; keep search keyword by using next howto (regex and match-string
index)
(if (not (evilmi-sdk-member keyword match-tags)) (setq keyword nil))
)
- (setq i (1+ i))
- )
+ (setq i (1+ i)))
keyword))
(defun evilmi--is-monogamy (tag-info)
@@ -130,8 +133,7 @@ is-function-exit-point could be 'FN_EXIT' or other status"
;; 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))
- )
+ (setq rlt t)))
rlt))
;;;###autoload
@@ -139,9 +141,7 @@ is-function-exit-point could be 'FN_EXIT' or other status"
"return '(start-point tag-info)"
(let (rlt
keyword
- (cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (cur-line (evilmi-sdk-curline))
tag-info)
(when (setq keyword (evilmi--sdk-extract-keyword cur-line match-tags
howtos))
@@ -155,8 +155,7 @@ is-function-exit-point could be 'FN_EXIT' or other status"
(line-end-position)
(line-beginning-position))
tag-info))
- )
- )
+ ))
rlt))
;;;###autoload
@@ -166,18 +165,14 @@ is-function-exit-point could be 'FN_EXIT' or other status"
cur-tag-type
cur-tag-info
(level 1)
- (cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (cur-line (evilmi-sdk-curline))
keyword
found
where-to-jump-in-theory)
(while (not found)
(forward-line (if (= orig-tag-type 2) -1 1))
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
(setq keyword (evilmi--sdk-extract-keyword cur-line match-tags howtos))
@@ -269,10 +264,7 @@ is-function-exit-point could be 'FN_EXIT' or other status"
(= (line-beginning-position) (point-min))
)
(setq found t)
- )
- )
- where-to-jump-in-theory
- )
- )
+ ))
+ where-to-jump-in-theory))
(provide 'evil-matchit-sdk)
diff --git a/evil-matchit-simple.el b/evil-matchit-simple.el
index e686927ada..dc422b8208 100644
--- a/evil-matchit-simple.el
+++ b/evil-matchit-simple.el
@@ -27,6 +27,7 @@
;;; Code:
+(require 'evil-matchit-sdk)
(require 'evil-matchit)
(defun evilmi--simple-find-open-brace (cur-line)
@@ -38,8 +39,7 @@
(setq rlt 1)
(save-excursion
(forward-line)
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position) (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
(if (string-match "^[ \t]*{ *$" cur-line)
(setq rlt 2))
))
@@ -47,13 +47,12 @@
;;;###autoload
(defun evilmi-simple-get-tag ()
- (let (p
- tmp
- ch
- forward-line-num
- rlt
- (cur-line (buffer-substring-no-properties
- (line-beginning-position) (line-end-position))))
+ (let* (p
+ tmp
+ ch
+ forward-line-num
+ rlt
+ (cur-line (evilmi-sdk-curline)))
;; Only handle open tag
(setq tmp (evilmi--get-char-under-cursor))
@@ -85,9 +84,7 @@
(if evilmi-debug (message "evilmi-simple-jump called"))
(evilmi--simple-jump)
- (setq cur-line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (setq cur-line (evilmi-sdk-curline))
;; hack for javascript
(if (string-match "^[ \t]*})(.*)\; *$" cur-line)
(line-end-position)
- [nongnu] elpa/evil-matchit 04e1d796b9 042/244: support "# ifdef" in c, (continued)
- [nongnu] elpa/evil-matchit 04e1d796b9 042/244: support "# ifdef" in c, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 937a407596 058/244: more tolerant algorithm in c/c++ v1.4.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9158dc87cc 062/244: case sensitive code is cleaned because Emacs will handle it, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 1c1a218d34 067/244: sql, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 1017e2e6ec 069/244: README.org: update MELPA URL, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 3f08492ec4 072/244: FIXED: #43 no jump at the first line in html v1.5.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit bfe8afe2a1 070/244: Merge pull request #40 from xuchunyang/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 257d4ab10c 071/244: #41 workaround web-mode v11 issue, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit c4be28092f 087/244: perfect support for visual-line state v2.1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4780ef4e4a 104/244: scan-sexps buggy in latex-mode, fallback to Evil API, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 38df050735 103/244: clean code,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit 0941f38bfe 118/244: Add ocaml plugin to evil-matchit.el, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4fdcda9fec 056/244: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 2f8449cfec 057/244: support Laravel Blade Templating, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4fe67764e2 059/244: extra commands to delete/select items v1.4.3, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d2e7b21038 061/244: remove duplicated code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4efd9e0fac 064/244: use % in evil-visual-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 965efc080a 065/244: updated pkg.sh, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit acb89199d0 074/244: Fix matching chaining off end blocks, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 296c31f93d 073/244: Fix matching multiple arguments and varibles with underscores in do/end blocks., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9a1b6ac1f9 076/244: can jump between brackets in visual-state #42, ELPA Syncer, 2022/01/06