[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit e44de538b9 196/244: clean code & doc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit e44de538b9 196/244: clean code & doc |
Date: |
Thu, 6 Jan 2022 02:59:01 -0500 (EST) |
branch: elpa/evil-matchit
commit e44de538b95a86e9f14b67b54fefc22db1c76a52
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
clean code & doc
---
README.org | 4 ++--
evil-matchit-sdk.el | 44 +++++++++++++++++++++++---------------------
evil-matchit.el | 16 +++++++++++-----
3 files changed, 36 insertions(+), 28 deletions(-)
diff --git a/README.org b/README.org
index b66d0b4d5c..9b9878fef4 100644
--- a/README.org
+++ b/README.org
@@ -106,7 +106,7 @@ Open evil-matchit-ruby.el whole structure is like,
(provide 'evil-matchit-ruby)
#+end_src
-So you setup in ~/.emacs is as below:
+So you configuration in =~/.emacs= is as below:
#+begin_src elisp
(with-eval-after-load "evil-matchit-ruby"
(push '("^[ \t]*\\([a-z]+\\)\\( .*\\| *\\)$" 1)
evilmi-ruby-extract-keyword-howtos)
@@ -114,7 +114,7 @@ So you setup in ~/.emacs is as below:
#+end_src
** Re-define keybinding
-All you need to do is to define function evilmi-customize-keybinding before
turning on evil-match-mode:
+All you need to do is to define function =evilmi-customize-keybinding= before
turning on =evil-matchit-mode=:
The shortcut =%= is defined in =evilmi-shortcut=. It's the name of text object
and shortcut of =evilmi-jump-items=. Some people prefer set it
to "m".
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index 467639ae76..cf898366c0 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -20,16 +20,16 @@
"The list of HOWTO on extracting keyword from current line.
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
+to extract the keyword which starts from one. The sub-match is the match
defined
between '\\(' and '\\)' in regular expression.")
-(defmacro evilmi-sdk-keyword (info)
+(defun evilmi-sdk-keyword (info)
"Get keyword from INFO."
- `(nth 3 ,info))
+ (nth 3 info))
-(defmacro evilmi-sdk-get-char (position)
+(defun evilmi-sdk-get-char (position)
"Get character at POSITION."
- `(char-after ,position))
+ (char-after position))
(defun evilmi-sdk-jump-forward-p ()
"Return: (forward-direction font-face-under-cursor character-under-cursor).
@@ -161,8 +161,8 @@ If IS-FORWARD is t, jump forward; or else jump backward."
(goto-char (evilmi-sdk-jumpto-where ff jump-forward ch))
(evilmi-sdk-tweak-selected-region ff jump-forward)))
-(defmacro evilmi-sdk-strictly-type-p (crt orig)
- `(or (evilmi-sdk-monogamy-p ,crt) (evilmi-sdk-monogamy-p ,orig)))
+(defun evilmi-sdk-strictly-type-p (crt orig)
+ (or (evilmi-sdk-monogamy-p crt) (evilmi-sdk-monogamy-p orig)))
(defun evilmi-sdk-tags-matched-p (level orig-tag-info cur-tag-info match-tags)
(let* (rlt
@@ -191,8 +191,9 @@ If IS-FORWARD is t, jump forward; or else jump backward."
rlt))
;;;###autoload
-(defmacro evilmi-sdk-curline ()
- `(buffer-substring-no-properties (line-beginning-position)
(line-end-position)))
+(defun evilmi-sdk-curline ()
+ (buffer-substring-no-properties (line-beginning-position)
+ (line-end-position)))
;;;###autoload
(defun evilmi-sdk-member (keyword keyword-list)
@@ -273,6 +274,7 @@ 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)))
@@ -283,18 +285,18 @@ Rule is looked up in HOWTOS."
(line-beginning-position)
(line-end-position)))))
-(defmacro evilmi-sdk-monogamy-p (tag-info)
- `(and (nth 2 ,tag-info) (string= (nth 2 ,tag-info) "MONOGAMY")))
+(defun evilmi-sdk-monogamy-p (tag-info)
+ (and (nth 2 tag-info) (string= (nth 2 tag-info) "MONOGAMY")))
-(defmacro evilmi-sdk-exactly-same-type-p (crt orig)
- `(= (nth 0 ,crt) (nth 0 ,orig)))
+(defun evilmi-sdk-exactly-same-type-p (crt orig)
+ (= (nth 0 crt) (nth 0 orig)))
-(defmacro evilmi-sdk-same-type (crt orig)
- `(when (and ,crt ,orig)
- ;; crt and orig should be at same row if either of them is monogamy
- (if (evilmi-sdk-strictly-type-p ,crt ,orig)
- (evilmi-sdk-exactly-same-type-p ,crt ,orig)
- t)))
+(defun evilmi-sdk-same-type (crt orig)
+ (when (and crt orig)
+ ;; crt and orig should be at same row if either of them is monogamy
+ (if (evilmi-sdk-strictly-type-p crt orig)
+ (evilmi-sdk-exactly-same-type-p crt orig)
+ t)))
;;;###autoload
(defun evilmi-sdk-get-tag (match-tags howtos)
@@ -449,8 +451,8 @@ after calling this function."
rlt))
;;;###autoload
-(defmacro evilmi-evenp (num)
- `(= (% ,num 2) 0))
+(defun evilmi-evenp (num)
+ (= (% num 2) 0))
(defun evilmi-count-matches (regexp str)
(let* ((count 0)
diff --git a/evil-matchit.el b/evil-matchit.el
index 7c11153dc9..cef81591e9 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -103,8 +103,9 @@ Some people prefer using \"m\" instead.")
(if evilmi-debug (message "evilmi--operate-on-item called. Return: %s"
ideal-dest))
ideal-dest))
-(defun evilmi--push-mark (rlt)
- (push-mark (nth 0 rlt) t t))
+(defun evilmi--push-mark (position)
+ "Pus POSITION as marker."
+ (push-mark (nth 0 position) t t))
(defun evilmi--convert-rules (rules)
"Convert RULES to function pairs list."
@@ -210,6 +211,8 @@ Some people prefer using \"m\" instead.")
(defun evilmi--region-to-select-or-delete (num &optional is-inner)
+ "Get NUM region(s) to select or delete.
+If IS-INNER is t, the region is inner text object."
(let* (ideal-dest b e)
(save-excursion
(setq ideal-dest (evilmi--operate-on-item num #'evilmi--push-mark))
@@ -271,7 +274,7 @@ Some people prefer using \"m\" instead.")
;;;###autoload
(defun evilmi-jump-to-percentage (num)
- "Like Vim %."
+ "Like Vim %, NUM is the percentage of location."
(interactive "P")
(let* (dst)
(when (and num (> num 0))
@@ -306,6 +309,9 @@ Some people prefer using \"m\" instead.")
(interactive)
(message "2.3.5"))
+(defvar evil-matchit-mode-map (make-sparse-keymap)
+ "Keymap used by the minor mode.")
+
;;;###autoload
(define-minor-mode evil-matchit-mode
"Buffer-local minor mode to emulate matchit.vim."
@@ -324,12 +330,12 @@ Some people prefer using \"m\" instead.")
;;;###autoload
(defun turn-on-evil-matchit-mode ()
- "Enable `evil-matchit-mode' in the current buffer."
+ "Enable the minor mode in the current buffer."
(evil-matchit-mode 1))
;;;###autoload
(defun turn-off-evil-matchit-mode ()
- "Disable `evil-matchit-mode' in the current buffer."
+ "Disable the minor mode in the current buffer."
(evil-matchit-mode -1))
;;;###autoload
- [nongnu] elpa/evil-matchit 8b80b3df94 098/244: correct inner text-object in python-mode v2.1.2, (continued)
- [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, 2022/01/06
- [nongnu] elpa/evil-matchit e44de538b9 196/244: clean code & doc,
ELPA Syncer <=
- [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
- [nongnu] elpa/evil-matchit d92883b8c3 007/244: use evil API in html file some times, ELPA Syncer, 2022/01/06