[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 5e92e374e6 179/244: better algorithm to match
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 5e92e374e6 179/244: better algorithm to match keyword |
Date: |
Thu, 6 Jan 2022 02:58:59 -0500 (EST) |
branch: elpa/evil-matchit
commit 5e92e374e6b46176d46323b884c25c44063331da
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
better algorithm to match keyword
---
README.org | 5 +---
evil-matchit-ocaml.el | 9 ++++---
evil-matchit-org.el | 75 ++++++++++++++++++++++++---------------------------
evil-matchit-sdk.el | 37 +++++++++++--------------
evil-matchit.el | 16 +++++++++--
pkg.sh | 2 +-
6 files changed, 72 insertions(+), 72 deletions(-)
diff --git a/README.org b/README.org
index 5dd87c97c2..540dc53162 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (v2.3.3)
+* evil-matchit (v2.3.4)
[[http://melpa.org/#/evil-matchit][file:http://melpa.org/packages/evil-matchit-badge.svg]]
[[http://stable.melpa.org/#/evil-matchit][file:http://stable.melpa.org/packages/evil-matchit-badge.svg]]
@@ -235,8 +235,5 @@ Step 3, add below code to =~/.emacs.=,
#+END_SRC
** APIs
- evilmi-load-plugin-rules
-- evilmi-current-font-among-fonts-p
-- evilmi-in-comment-p
-- evilmi-in-string-or-doc-p
* Contact me
Report bugs at [[https://github.com/redguardtoo/evil-matchit]].
diff --git a/evil-matchit-ocaml.el b/evil-matchit-ocaml.el
index 3c1801fbbb..56630594a1 100644
--- a/evil-matchit-ocaml.el
+++ b/evil-matchit-ocaml.el
@@ -57,10 +57,11 @@
(defun evilmi-ocaml-in-keyword-p (pos)
"Check character at POS is keyword by comparing font face."
- (evilmi-current-font-among-fonts-p pos '(tuareg-font-lock-governing-face
- tuareg-font-lock-operator-face ;;
for parentheses
- tuareg-font-double-colon-face ;;
for double semicolon
- font-lock-keyword-face)))
+ (evilmi-among-fonts-p pos
+ '(tuareg-font-lock-governing-face
+ tuareg-font-lock-operator-face ; for parentheses
+ tuareg-font-double-colon-face ; for double
semicolon
+ font-lock-keyword-face)))
;; jumps to next keyword. Returs nil if there's no next word
(defun evilmi-ocaml-next-possible-keyword (direction keywords-regex)
diff --git a/evil-matchit-org.el b/evil-matchit-org.el
index 0372e64dd5..38253d05ec 100644
--- a/evil-matchit-org.el
+++ b/evil-matchit-org.el
@@ -34,22 +34,19 @@
(defvar evilmi-org-extract-keyword-howtos
'(("^[ \t]*#\\+\\([a-zA-Z_]+\\).*$" 1)
- ("^[ \t]*\\:\\([a-zA-Z_]+\\)\\:$" 1)
- )
+ ("^[ \t]*\\:\\([a-zA-Z_]+\\)\\:$" 1))
"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
-between '\\(' and '\\)' in regular expression.
-"
- )
+between '\\(' and '\\)' in regular expression.")
+
;; ruby/bash/lua/vimrc
(defvar evilmi-org-match-tags
'((("begin_src") () ( "end_src") "MONOGAMY")
(("begin_example") () ( "end_example") "MONOGAMY")
(("begin_html") () ( "end_html") "MONOGAMY")
- (("results") () ( "end") "MONOGAMY")
- ))
+ (("results") () ( "end") "MONOGAMY")))
(defun evilmi--element-property (property element)
"Extract the value from the PROPERTY of an ELEMENT."
@@ -60,7 +57,7 @@ between '\\(' and '\\)' in regular expression.
(defun evilmi--get-embedded-language-major-mode ()
;; org-element-at-point is available only at org7+
- (let ((lang (evilmi--element-property :language (org-element-at-point))))
+ (let* ((lang (evilmi--element-property :language (org-element-at-point))))
(when lang
(if (string= lang "elisp")
'emacs-lisp-mode
@@ -68,39 +65,37 @@ between '\\(' and '\\)' in regular expression.
;;;###autoload
(defun evilmi-org-get-tag ()
- (let (rlt)
- (setq rlt (evilmi-sdk-get-tag evilmi-org-match-tags
evilmi-org-extract-keyword-howtos))
- (if (not rlt)
- (setq rlt '(-1)) ;; evilmi-org-jump knows what -1 means
- )
- rlt
- ))
+ "Get current tag in org file."
+ (let* ((rlt (evilmi-sdk-get-tag evilmi-org-match-tags
+ evilmi-org-extract-keyword-howtos)))
+ (unless rlt
+ ;; evilmi-org-jump knows what -1 means
+ (setq rlt '(-1)))
+ rlt))
;;;###autoload
-(defun evilmi-org-jump (rlt NUM)
- (if (< (car rlt) 0)
- (let (where-to-jump-in-theory
- jumped
- plugin
- info
- (lang-f (evilmi--get-embedded-language-major-mode)))
- (when lang-f
- (setq plugin (plist-get evilmi-plugins lang-f))
- (when plugin
- (mapc
- (lambda (elem)
- (setq info (funcall (nth 0 elem)))
- (when (and info (not jumped))
- ;; before jump, we may need some operation
- (setq where-to-jump-in-theory (funcall (nth 1 elem) info
NUM))
- ;; jump only once if the jump is successful
- (setq jumped t)
- ))
- plugin
- ))
- )
- )
- (evilmi-sdk-jump rlt NUM evilmi-org-match-tags
evilmi-org-extract-keyword-howtos)
- ))
+(defun evilmi-org-jump (rlt num)
+ (cond
+ ((< (car rlt) 0)
+ (let* (where-to-jump-in-theory
+ jumped
+ info
+ (lang-f (evilmi--get-embedded-language-major-mode))
+ (plugin (and lang-f (plist-get evilmi-plugins lang-f))))
+ (when plugin
+ (mapc
+ (lambda (elem)
+ (setq info (funcall (nth 0 elem)))
+ (when (and info (not jumped))
+ ;; before jump, we may need some operation
+ (setq where-to-jump-in-theory (funcall (nth 1 elem) info num))
+ ;; jump only once if the jump is successful
+ (setq jumped t)))
+ plugin))))
+ (t
+ (evilmi-sdk-jump rlt
+ num
+ evilmi-org-match-tags
+ evilmi-org-extract-keyword-howtos))))
(provide 'evil-matchit-org)
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index 135ff8ee75..a3ca76a2c6 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -1,6 +1,12 @@
(defvar evilmi-debug nil
"Debug flag.")
+(defvar evilmi-ignored-fonts
+ '(font-lock-string-face
+ font-lock-doc-face
+ font-lock-comment-face)
+ "Text with ingored fonts has no string keyword.")
+
(defvar evilmi-sdk-extract-keyword-howtos
'(("^[ \t]*\\([a-z]+\!?\\)\\( .*\\| *\\)$" 1)
("^.* \\(do\\) |[a-z0-9A-Z,|]+|$" 1))
@@ -126,6 +132,15 @@ is-function-exit-point could be unknown 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)))
+
+ (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))
(defun evilmi--is-monogamy (tag-info)
@@ -265,7 +280,7 @@ after calling this function."
;;;###autoload
-(defun evilmi-current-font-among-fonts-p (pos fonts)
+(defun evilmi-among-fonts-p (pos fonts)
"If current font at POS is among FONTS."
(let* ((fontfaces (get-text-property pos 'face)))
(when (not (listp fontfaces))
@@ -300,26 +315,6 @@ after calling this function."
(setq rlt line)))))
rlt))
-;;;###autoload
-(defun evilmi-in-comment-p (pos)
- "Check character at POS is comment by comparing font face."
- (cond
- ;; @see https://github.com/redguardtoo/evil-matchit/issues/92
- ((eq major-mode 'tuareg-mode)
- (evilmi-current-font-among-fonts-p pos '(font-lock-comment-face
- font-lock-comment-delimiter-face
- font-lock-doc-face)))
- (t
- (evilmi-current-font-among-fonts-p pos '(font-lock-comment-face
-
font-lock-comment-delimiter-face)))))
-
-
-;;;###autoload
-(defun evilmi-in-string-or-doc-p (pos)
- "Check character at POS is string or document by comparing font face."
- (evilmi-current-font-among-fonts-p pos '(font-lock-string-face
- font-lock-doc-face)))
-
;;;###autoload
(defun evilmi-evenp (num)
(= (% num 2) 0))
diff --git a/evil-matchit.el b/evil-matchit.el
index 2841bac7ed..ad07b59bd0 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -4,7 +4,7 @@
;; Author: Chen Bin <chenbin.sh@gmail.com>
;; URL: http://github.com/redguardtoo/evil-matchit
-;; Version: 2.3.3
+;; Version: 2.3.4
;; Keywords: matchit vim evil
;; Package-Requires: ((evil "1.2.0") (emacs "24.4"))
;;
@@ -127,6 +127,18 @@ If font-face-under-cursor is NOT nil, the quoted string is
being processed."
(if evilmi-debug (message "evilmi--is-jump-forward return (%s %s %s)" rlt
ff (string ch)))
(list rlt ff ch)))
+(defun evilmi-in-comment-p (pos)
+ "Check character at POS is comment by comparing font face."
+ (cond
+ ;; @see https://github.com/redguardtoo/evil-matchit/issues/92
+ ((eq major-mode 'tuareg-mode)
+ (evilmi-among-fonts-p pos '(font-lock-comment-face
+ font-lock-comment-delimiter-face
+ font-lock-doc-face)))
+ (t
+ (evilmi-among-fonts-p pos '(font-lock-comment-face
+
font-lock-comment-delimiter-face)))))
+
(defun evilmi--scan-sexps (is-forward)
"Get the position of matching tag.
If IS-FORWARD is t, jump forward; or else jump backward."
@@ -455,7 +467,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
;;;###autoload
(defun evilmi-version()
(interactive)
- (message "2.3.3"))
+ (message "2.3.4"))
;;;###autoload
(define-minor-mode evil-matchit-mode
diff --git a/pkg.sh b/pkg.sh
index 26de8a61d8..1eb61b94d7 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
#!/bin/bash
name=evil-matchit
-version=2.3.3
+version=2.3.4
pkg=$name-$version
mkdir $pkg
cp README.org $pkg
- [nongnu] elpa/evil-matchit 8c8c94bea8 231/244: fixed ci, (continued)
- [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
- [nongnu] elpa/evil-matchit 23a0576255 213/244: fixed: can not jump tag from prompt line in shell-mode sometimes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d701acb054 158/244: Merge pull request #96 from JJPandari/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit cc3654b00d 133/244: only keep fn-end and do-else-end pairs, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 7bee6fad80 167/244: Merge pull request #106 from porras/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit abe43359bf 160/244: Merge pull request #98 from nitros12/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit c5b87b4de5 174/244: Merge pull request #108 from neojski/better-parens-handling, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 5e92e374e6 179/244: better algorithm to match keyword,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit 449da5ca10 082/244: fixed typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 18a3e6ab47 096/244: Merge pull request #64 from hlissner/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 58e735c5ea 097/244: org-element-property exist in 24.4+ only, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit de6ce21e1e 106/244: jump in comment, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 3873a93653 081/244: support enh-ruby-mode, more tips v2.0.1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 2f423258e1 152/244: support mhtml-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4a24de3862 126/244: Add copyright preamble, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 73bef5fb56 134/244: Merge pull request #84 from dsdshcym/83-elixir-support, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8123eef094 146/244: Merge pull request #88 from Khady/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 3f49ee9d17 140/244: improve ocaml, ELPA Syncer, 2022/01/06