[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 8123eef094 146/244: Merge pull request #88 fr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 8123eef094 146/244: Merge pull request #88 from Khady/master |
Date: |
Thu, 6 Jan 2022 02:58:57 -0500 (EST) |
branch: elpa/evil-matchit
commit 8123eef0948a2b93d81e377504fb8d6987bffb2f
Merge: 8a10046f25 3f49ee9d17
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #88 from Khady/master
improve ocaml
---
evil-matchit-ocaml.el | 61 ++++++++++++++++++++++++++++++++-------------------
1 file changed, 39 insertions(+), 22 deletions(-)
diff --git a/evil-matchit-ocaml.el b/evil-matchit-ocaml.el
index 8626d17247..e04dab6817 100644
--- a/evil-matchit-ocaml.el
+++ b/evil-matchit-ocaml.el
@@ -26,6 +26,8 @@
;;; Code:
+(require 'evil-matchit-sdk)
+
(defvar evilmi-ocaml-keywords
'((("struct" "begin" "sig" "object") ("end"))
(("if") ("then"))
@@ -43,17 +45,38 @@
(format "\\<\\(%s\\)\\>" (mapconcat 'identity evilmi-ocaml-all-keywords
"\\|"))
"Regexp to find next/previous keyword.")
+(defun evilmi-ocaml-row-regex (tag-info)
+ "Build regexp to find next/previous keyword in a row."
+ (format "\\<\\(%s\\)\\>" (mapconcat 'identity (apply 'append tag-info)
"\\|")))
+
+(defun evilmi-ocaml-valid-position-p ()
+ "Check if point is not in comment, string or doc"
+ (not (or (evilmi-in-comment-p (point))
+ (evilmi-in-string-or-doc-p (point)))))
+
;; jumps to next keyword. Returs nil if there's no next word
-(defun evilmi-ocaml-next-keyword (direction)
+(defun evilmi-ocaml-next-possible-keyword (direction keywords-regex)
(if (= direction 0)
(let ((new-point (save-excursion
- (forward-char)
- (if (search-forward-regexp evilmi-ocaml-keywords-regex nil t)
- (search-backward-regexp evilmi-ocaml-keywords-regex)
- nil)
- )))
+ (forward-char)
+ (if (search-forward-regexp keywords-regex nil t)
+ (search-backward-regexp keywords-regex)
+ nil)
+ )))
(if new-point (goto-char new-point)))
- (search-backward-regexp evilmi-ocaml-keywords-regex nil t)))
+ (search-backward-regexp keywords-regex nil t)))
+
+(defun evilmi-ocaml-next-keyword (direction &optional keywords-regex)
+ "Jump to next keyword in a valid position. Return nil if no
+such keyword is available."
+ (let ((keywords-regex (or keywords-regex evilmi-ocaml-keywords-regex))
+ (found-keyword-p nil)
+ (keyword-exist-p t))
+ (while (and (not found-keyword-p) keyword-exist-p)
+ (setq keyword-exist-p (evilmi-ocaml-next-possible-keyword direction
keywords-regex))
+ (if (and keyword-exist-p (evilmi-ocaml-valid-position-p))
+ (setq found-keyword-p t)))
+ found-keyword-p))
(defun evilmi-ocaml-end-word ()
(save-excursion
@@ -74,21 +97,15 @@
;; 0 - forward
;; 1 - backward
(defun evilmi-ocaml-go (tag-info level direction)
- (if (= level 0)
- (point)
- (if (evilmi-ocaml-next-keyword direction)
- (progn
- (setq keyword (evilmi-ocaml-get-word))
-
- (if (evilmi-ocaml-is-keyword tag-info keyword)
- ;; interesting tag
- (if (member keyword (nth direction tag-info))
- (evilmi-ocaml-go tag-info (+ level 1) direction)
- (evilmi-ocaml-go tag-info (- level 1) direction))
-
- ;; other tag
- (evilmi-ocaml-go tag-info level direction)))
- nil)))
+ (let ((stop-p nil)
+ (keywords-regex (evilmi-ocaml-row-regex tag-info)))
+ (while (and (not stop-p) (/= level 0))
+ (if (evilmi-ocaml-next-keyword direction keywords-regex)
+ (if (member (evilmi-ocaml-get-word) (nth direction tag-info))
+ (setq level (1+ level))
+ (setq level (1- level)))
+ (setq stop-p t)))
+ (if (= level 0) (point))))
(defun evilmi-ocaml-goto-word-beginning ()
(let ((bounds (bounds-of-thing-at-point 'word))
- [nongnu] elpa/evil-matchit c5b87b4de5 174/244: Merge pull request #108 from neojski/better-parens-handling, (continued)
- [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, 2022/01/06
- [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 <=
- [nongnu] elpa/evil-matchit 3f49ee9d17 140/244: improve ocaml, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8d6bd9187d 154/244: [chen] update doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 2143844e2b 170/244: support js2-jsx-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit e941c695f3 173/244: Add [ and { as well., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit c04f8f480c 164/244: Match Ruby's begin also when it's not on the beginning of the line, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d779aedaf1 195/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit dead63c7d0 194/244: add unit test, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 80dc731ab7 237/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0be04f960f 049/244: use text objects v1.3.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 62cef4f91a 077/244: replace evil-jump-items v2.0, ELPA Syncer, 2022/01/06