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

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

[nongnu] elpa/evil-matchit df642d953d 139/244: add a few APIs


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit df642d953d 139/244: add a few APIs
Date: Thu, 6 Jan 2022 02:58:56 -0500 (EST)

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

    add a few APIs
---
 README.org          |  6 +++++-
 evil-matchit-sdk.el | 25 +++++++++++++++++++++++++
 evil-matchit.el     | 21 +++++----------------
 pkg.sh              |  2 +-
 4 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/README.org b/README.org
index 1fcc604402..e84d747c2b 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (v2.2.6)
+* evil-matchit (v2.2.7)
 
 
[[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]]
 
@@ -163,6 +163,10 @@ You can turn on =evilmi-always-simple-jump= to match 
brackets at first.
 Thus you disable our *advanced algorithm* which I highly recommend.
 
 Some people may prefer simpler algorithm in =python-mode.
+** APIs you can use
+- evilmi-current-font-among-fonts-p
+- evilmi-in-comment-p
+- evilmi-in-string-or-doc-p
 * Developer guide
 ** Write Emacs Lisp to support new language
 Simple. You only need define two functions and tell evil-matchit in which 
major-mode they should be used.
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index ce7e6fdd06..9ba651ddeb 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -260,6 +260,31 @@ after calling this function."
 
     where-to-jump-in-theory))
 
+
+;;;###autoload
+(defun evilmi-current-font-among-fonts-p (pos fonts)
+  "If current font at POS is among FONTS."
+  (let* ((fontfaces (get-text-property pos 'face)))
+    (when (not (listp fontfaces))
+      (setf fontfaces (list fontfaces)))
+    (delq nil
+          (mapcar (lambda (f)
+                    (member f fonts))
+                  fontfaces))))
+
+;;;###autoload
+(defun evilmi-in-comment-p (pos)
+  "Check character at POS is comment by comparing font face."
+  (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 docuemnt by comparing font face."
+  (evilmi-current-font-among-fonts-p pos '(font-lock-string-face
+                                           font-lock-doc-face)))
+
 (defun evilmi-count-matches (regexp str)
   (let* ((count 0)
          (start 0))
diff --git a/evil-matchit.el b/evil-matchit.el
index 3b8f9f91bd..f61526dd6b 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.2.6
+;; Version: 2.2.7
 ;; Keywords: matchit vim evil
 ;; Package-Requires: ((evil "1.0.7"))
 ;;
@@ -43,6 +43,7 @@
 ;;; Code:
 
 (require 'evil)
+(require 'evil-matchit-sdk)
 
 (defvar evilmi-plugins '(emacs-lisp-mode
                          ((evilmi-simple-get-tag evilmi-simple-jump)))
@@ -118,18 +119,6 @@ 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 the code at POS is comment by comparing font face."
-  (let* ((fontfaces (get-text-property pos 'face)))
-    (when (not (listp fontfaces))
-      (setf fontfaces (list fontfaces)))
-    (delq nil
-          (mapcar #'(lambda (f)
-                      ;; learn this trick from flyspell
-                      (or (eq f 'font-lock-comment-face)
-                          (eq f 'font-lock-comment-delimiter-face)))
-                  fontfaces))))
-
 (defun evilmi--scan-sexps (is-forward)
   "Get the position of matching tag.
 If IS-FORWARD is t, jump forward; or else jump backward."
@@ -151,7 +140,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
              ((= b 93) 91)))
          (rlt start-pos))
     (cond
-     ((evilmi--in-comment-p (point))
+     ((evilmi-in-comment-p (point))
       ;; Matching tag in comment.
       ;; Use own algorithm instead of `scan-sexps'
       ;; because `scan-sexps' not work in some major-mode
@@ -161,7 +150,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
                     (> lvl 0))
           (setq start-pos (+ start-pos arg))
           (goto-char start-pos)
-          (if (evilmi--in-comment-p start-pos)
+          (if (evilmi-in-comment-p start-pos)
               (cond
                ((= (following-char) b)
                 (setq lvl (1+ lvl)))
@@ -501,7 +490,7 @@ If IS-FORWARD is t, jump forward; or else jump backward."
 ;;;###autoload
 (defun evilmi-version()
   (interactive)
-  (message "2.2.6"))
+  (message "2.2.7"))
 
 ;;;###autoload
 (define-minor-mode evil-matchit-mode
diff --git a/pkg.sh b/pkg.sh
index b33e06ad72..a366632053 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 name=evil-matchit
-version=2.2.6
+version=2.2.7
 pkg=$name-$version
 mkdir $pkg
 cp README.org $pkg



reply via email to

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