[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 0d463ab3da 172/244: Ocaml: add normal parenth
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 0d463ab3da 172/244: Ocaml: add normal parentheses support |
Date: |
Thu, 6 Jan 2022 02:58:59 -0500 (EST) |
branch: elpa/evil-matchit
commit 0d463ab3dab15a32755f7d0423408e96d6bf6353
Author: Tomasz KoĆodziejski <tkolodziejski@gmail.com>
Commit: Tomasz KoĆodziejski <tkolodziejski@gmail.com>
Ocaml: add normal parentheses support
To do this, I had to stop using things like
```
thing-at-point 'word
```
---
evil-matchit-ocaml.el | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/evil-matchit-ocaml.el b/evil-matchit-ocaml.el
index e0858a70b6..65819bf6ee 100644
--- a/evil-matchit-ocaml.el
+++ b/evil-matchit-ocaml.el
@@ -36,23 +36,27 @@
(("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 '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)
"\\|")))
+ (format "\\(%s\\)" (mapconcat 'identity (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 +85,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 +114,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 1d55eba1d3 112/244: fix bug on verilog if statement, (continued)
- [nongnu] elpa/evil-matchit 1d55eba1d3 112/244: fix bug on verilog if statement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 01ade592db 114/244: enhance js matching algorithm, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 277623d8be 116/244: support css/less/scss, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4101ee2432 130/244: handle 'switch' in C properly, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 69299108fd 120/244: Add sig/end matching for ocaml, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 50bb882419 132/244: support elixir, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit e15ad8406b 155/244: Merge pull request #95 from linchen2chris/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit a8a8625fc2 144/244: Merge pull request #90 from Khady/patch-2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 11f57d8f52 142/244: Merge pull request #89 from Khady/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit f471bc97bd 137/244: tsx needs jsx support as well, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0d463ab3da 172/244: Ocaml: add normal parentheses support,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit 5cea6fde1c 162/244: clean code and wording, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit fb04ffae4b 176/244: Treat source blocks labelled as "elisp"., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit b00671fb9e 186/244: Mark evilmi-jump-items as a jump motion, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ea1e867129 181/244: support more ruby syntax, thanks to @kriansa, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9ef1325305 200/244: wording, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 86daa28dbd 201/244: doc, minor regex issue, tdd for lua, ELPA Syncer, 2022/01/06
- [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