[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit c5b87b4de5 174/244: Merge pull request #108 f
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit c5b87b4de5 174/244: Merge pull request #108 from neojski/better-parens-handling |
Date: |
Thu, 6 Jan 2022 02:58:59 -0500 (EST) |
branch: elpa/evil-matchit
commit c5b87b4de540cc42ebaee1451f23116e529231cb
Merge: 43be86d8c4 e941c695f3
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #108 from neojski/better-parens-handling
Ocaml: add normal parentheses support
---
evil-matchit-ocaml.el | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/evil-matchit-ocaml.el b/evil-matchit-ocaml.el
index e0858a70b6..9239bf2a84 100644
--- a/evil-matchit-ocaml.el
+++ b/evil-matchit-ocaml.el
@@ -36,23 +36,29 @@
(("match" "try") ("with"))
(("while" "for") ("done"))
(("let") ("in"))
+ (("(") (")"))
+ (("[") ("]"))
+ (("{") ("}"))
())
"Ocaml keywords.")
(defvar evilmi-ocaml-all-keywords
(apply 'append (apply 'append evilmi-ocaml-keywords)))
+;; Please note this regex is a bit funny: we don't need to check for word
+;; boundaries because later on we check evilmi-ocaml-in-keyword-p
(defvar evilmi-ocaml-keywords-regex
- (format "\\<\\(%s\\)\\>" (mapconcat 'identity evilmi-ocaml-all-keywords
"\\|"))
+ (format "\\(%s\\)" (mapconcat 'regexp-quote 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)
"\\|")))
+ (format "\\(%s\\)" (mapconcat 'regexp-quote (apply 'append tag-info) "\\|")))
(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
font-lock-keyword-face)))
;; jumps to next keyword. Returs nil if there's no next word
@@ -81,10 +87,11 @@ such keyword is available."
(defun evilmi-ocaml-end-word ()
(save-excursion
- (search-forward-regexp "\\>")
+ (search-forward-regexp evilmi-ocaml-keywords-regex)
(point)))
(defun evilmi-ocaml-get-word ()
+ "Get keyword assuming we're at the begging of it"
(buffer-substring-no-properties (point) (evilmi-ocaml-end-word)))
(defun evilmi-ocaml-is-keyword (l keyword)
@@ -109,34 +116,29 @@ such keyword is available."
(if (= level 0) (point))))
(defun evilmi-ocaml-goto-word-beginning ()
- (let ((bounds (bounds-of-thing-at-point 'word))
- (word (thing-at-point 'word))
- (line-end (line-end-position)))
- (if bounds (goto-char (car bounds)))
- (let ((next-keyword
- (save-excursion
- (if (cl-find word evilmi-ocaml-all-keywords :test 'equal)
- (point)
- (evilmi-ocaml-next-keyword 0)
- (if (< (point) line-end) (point))))))
- (if next-keyword (goto-char next-keyword)))))
+ (let ((candidate
+ (save-excursion
+ (evilmi-ocaml-next-keyword 1)
+ (evilmi-ocaml-next-keyword 0)
+ (point))))
+ (if (< candidate (line-end-position)) (goto-char candidate))))
;;;###autoload
(defun evilmi-ocaml-get-tag ()
"Return information of current tag: (list position-of-word word)."
(save-excursion
(evilmi-ocaml-goto-word-beginning)
- (list (car (bounds-of-thing-at-point 'word))
- (evilmi-ocaml-get-word))))
+ (list (point) (evilmi-ocaml-get-word))))
;;;###autoload
(defun evilmi-ocaml-jump (rlt num)
(let* ((keyword (cadr rlt))
(tag-info (evilmi-ocaml-get-tag-info keyword))
(direction (if (member keyword (car tag-info)) 0 1)))
- (let ((new-point (save-excursion
- (evilmi-ocaml-goto-word-beginning)
- (evilmi-ocaml-go tag-info 1 direction))))
- (if new-point (goto-char new-point)))))
+ (if tag-info
+ (let ((new-point (save-excursion
+ (evilmi-ocaml-goto-word-beginning)
+ (evilmi-ocaml-go tag-info 1 direction))))
+ (if new-point (goto-char new-point))))))
(provide 'evil-matchit-ocaml)
- [nongnu] elpa/evil-matchit 437f67689c 203/244: fix f90-mode bug, add fortran unit test, (continued)
- [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
- [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 <=
- [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, 2022/01/06