[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 5cea6fde1c 162/244: clean code and wording
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 5cea6fde1c 162/244: clean code and wording |
Date: |
Thu, 6 Jan 2022 02:58:58 -0500 (EST) |
branch: elpa/evil-matchit
commit 5cea6fde1c20a1937ca7a4cadd94292d013a4a30
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
clean code and wording
---
evil-matchit.el | 71 +++++++++++++++++++++++++--------------------------------
1 file changed, 31 insertions(+), 40 deletions(-)
diff --git a/evil-matchit.el b/evil-matchit.el
index e31328129f..3f0c8e4073 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -47,13 +47,13 @@
"The Matrix to of algorithms.")
(defvar evilmi-may-jump-by-percentage t
- "Simulate `evil-jump-item' behaviour.
+ "Simulate `evil-jump-item'.
For example, `50%' jumps to 50 percentage of buffer.
If nil, `50%' jumps 50 times.")
(defvar evilmi-always-simple-jump nil
"`major-mode' like `python-mode' use optimized algorithm by default.
-Set this flag into `t' to always use simple jump.")
+If it's t, use simple jump.")
(defvar evilmi-forward-chars (string-to-list "[{("))
(defvar evilmi-backward-chars (string-to-list "]})"))
@@ -61,6 +61,7 @@ Set this flag into `t' to always use simple jump.")
(defvar evilmi-debug nil)
(defun evilmi--char-is-simple (ch)
+ "Special handling of character CH for `python-mode'."
(let* (rlt)
(cond
((and (not evilmi-always-simple-jump)
@@ -72,7 +73,7 @@ Set this flag into `t' to always use simple jump.")
;; if true:
;; a = "hello world"
;;
- ;; If current cursor is at end of line , rlt should be nil!
+ ;; If current cursor is at end of line, rlt should be nil!
;; or else, matching algorithm can't work in above python sample
(setq rlt nil))
(t
@@ -83,12 +84,13 @@ Set this flag into `t' to always use simple jump.")
rlt))
(defun evilmi--get-char-at-position (pos)
+ "Get character at POS."
(let* ((ch (char-after pos)))
(if evilmi-debug (message "evilmi--get-char-at-position called. Return:
%s" (string ch)))
ch))
(defun evilmi--get-char-under-cursor ()
- "Return: (character position)"
+ "Return: (character position)."
(let* ((ch (following-char))
(p (point)))
(if evilmi-debug (message "evilmi--get-char-under-cursor called. Return:
(%d %s)" ch p))
@@ -102,16 +104,13 @@ If font-face-under-cursor is NOT nil, the quoted string
is being processed."
(ch (car tmp))
(p (cadr tmp))
ff
- rlt)
+ (rlt t))
(cond
- ((memq ch evilmi-forward-chars)
- (setq rlt t))
((memq ch evilmi-backward-chars)
(setq rlt nil))
((memq ch evilmi-quote-chars)
(setq rlt (eq (setq ff (get-text-property p 'face))
- (get-text-property (+ 1 p) 'face))))
- (t (setq rlt t)))
+ (get-text-property (+ 1 p) 'face)))))
(if evilmi-debug (message "evilmi--is-jump-forward return (%s %s %s)" rlt
ff (string ch)))
(list rlt ff ch)))
@@ -145,16 +144,15 @@ If IS-FORWARD is t, jump forward; or else jump backward."
(setq start-pos (point))
(while (and (not (= start-pos limit))
(> lvl 0))
- (setq start-pos (+ start-pos arg))
- (goto-char start-pos)
- (if (evilmi-in-comment-p start-pos)
- (cond
- ((= (following-char) b)
- (setq lvl (1+ lvl)))
- ((= (following-char) e)
- (setq lvl (1- lvl))))))
- (if (= lvl 0)
- (setq rlt (+ start-pos (if is-forward 1 0))))))
+ (goto-char (setq start-pos (+ start-pos arg)))
+ (when (evilmi-in-comment-p start-pos)
+ (cond
+ ((= (following-char) b)
+ (setq lvl (1+ lvl)))
+ ((= (following-char) e)
+ (setq lvl (1- lvl))))))
+ (when (= lvl 0)
+ (setq rlt (+ start-pos (if is-forward 1 0))))))
(t
;; not comment
;; search but ignore comments
@@ -164,29 +162,22 @@ If IS-FORWARD is t, jump forward; or else jump backward."
(if evilmi-debug (message "evilmi--scan-sexps called => rlt=%s lvl=%s" rlt
lvl))
rlt))
-(defun evilmi--adjust-quote-jumpto (is-forward pos)
- (let* ((rlt (if is-forward pos (+ 1 pos))))
- (if evilmi-debug (message "evilmi--adjust-quote-jumpto called. Return: %s"
rlt))
- rlt))
-
-(defun evilmi--above-the-other-quote-char (ch pos ff delta)
- (and (= ch (evilmi--get-char-at-position (- pos delta)))
- (not (eq ff (get-text-property pos 'face)))))
-
(defun evilmi--find-the-other-quote-char (ff is-forward ch)
- "The end character under cursor has different font-face from ff"
+ "The end character under cursor has different font-face from FF."
(let* (rlt
- (got nil)
+ got
(delta (if is-forward 1 -1))
(pos (+ delta (point)))
(end (if is-forward (point-max) (point-min))))
(while (not got)
- (if (or (= pos end)
- (evilmi--above-the-other-quote-char ch pos ff delta))
- (progn
- (setq rlt (evilmi--adjust-quote-jumpto is-forward pos))
- (setq got t))
- (setq pos (+ delta pos))))
+ (cond
+ ((or (= pos end)
+ (and (= ch (evilmi--get-char-at-position (- pos delta)))
+ (not (eq ff (get-text-property pos 'face)))))
+ (setq rlt (if is-forward pos (+ 1 pos)))
+ (setq got t))
+ (t
+ (setq pos (+ delta pos)))))
(if evilmi-debug (message "evilmi--find-the-other-quote-char called
Return: %s" rlt))
rlt))
@@ -214,7 +205,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
(evil-backward-char)))
(defun evilmi--simple-jump ()
- "Alternative for evil-jump-item."
+ "Alternative for `evil-jump-item'."
(interactive)
(if evilmi-debug (message "evilmi--simple-jump called (point)=%d" (point)))
(let* ((tmp (evilmi--is-jump-forward))
@@ -238,7 +229,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
(if plugin
(mapc
(lambda (elem)
- ;; excute evilmi-xxxx-get-tag
+ ;; execute evilmi-xxxx-get-tag
(setq rlt (funcall (nth 0 elem)))
(when (and rlt (not jumped))
;; before jump, we may need some operation
@@ -282,7 +273,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
(defun evilmi-init-plugins ()
"Load plugins."
(interactive)
- ;; simple matching for languages containing "{(["
+ ;; simple matching for languages containing brackets
(evilmi-load-plugin-rules '(java-mode perl-mode cperl-mode go-mode)
'(simple))
@@ -463,7 +454,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
(if (fboundp 'evilmi-customize-keybinding)
;; use user's own key bindings
(evilmi-customize-keybinding)
- ;; else use default key bindgs
+ ;; else use default key bindings
(evil-define-key 'normal evil-matchit-mode-map "%" 'evilmi-jump-items)
(evil-define-key 'visual evil-matchit-mode-map "%" 'evilmi-jump-items))
- [nongnu] elpa/evil-matchit 01ade592db 114/244: enhance js matching algorithm, (continued)
- [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, 2022/01/06
- [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 <=
- [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
- [nongnu] elpa/evil-matchit ea1e867129 181/244: support more ruby syntax, thanks to @kriansa, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9ef1325305 200/244: wording, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 86daa28dbd 201/244: doc, minor regex issue, tdd for lua, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 437f67689c 203/244: fix f90-mode bug, add fortran unit test, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8c8c94bea8 231/244: fixed ci, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 96a1aba323 210/244: Add ocaml tests, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9cd0ddaacb 233/244: can jump between quotes in plain text, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 539192328e 215/244: fixed minor bug #127, ELPA Syncer, 2022/01/06