[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 82c80786e5 240/244: jump between merge confli
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 82c80786e5 240/244: jump between merge conflict markers |
Date: |
Thu, 6 Jan 2022 02:59:06 -0500 (EST) |
branch: elpa/evil-matchit
commit 82c80786e596da61acb5cf506ce3225950b0e433
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
jump between merge conflict markers
---
evil-matchit-prog.el | 50 +++++++++++++++++++++++++++++++++++++++++++++
evil-matchit-sdk.el | 3 +++
evil-matchit.el | 8 ++++++++
tests/conflict.js | 20 ++++++++++++++++++
tests/evil-matchit-tests.el | 15 ++++++++++++++
5 files changed, 96 insertions(+)
diff --git a/evil-matchit-prog.el b/evil-matchit-prog.el
new file mode 100644
index 0000000000..5a558faaa9
--- /dev/null
+++ b/evil-matchit-prog.el
@@ -0,0 +1,50 @@
+;;; evil-matchit-prog.el --- all programming languages plugin of evil-matchit
+
+;; Copyright (C) 2021 Chen Bin <chenbin DOT sh AT gmail DOT com>
+
+;; Author: Chen Bin <chenbin DOT sh AT gmail DOT com>
+
+;; This file is not part of GNU Emacs.
+
+;;; License:
+
+;; This file is part of evil-matchit
+;;
+;; evil-matchit is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as published
+;; by the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; evil-matchit is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+;;; Code:
+
+(require 'evil-matchit-sdk)
+
+(defvar evilmi-prog-extract-keyword-howtos
+ '(("^\\(<<<<<<<\\|=======\\|>>>>>>>\\)" 1)))
+
+(defvar evilmi-prog-match-tags
+ '((("<<<<<<<") ("=======") (">>>>>>>"))))
+
+;;;###autoload
+(defun evilmi-prog-get-tag ()
+ "Get tag at point."
+ (evilmi-sdk-get-tag evilmi-prog-match-tags
evilmi-prog-extract-keyword-howtos))
+
+;;;###autoload
+(defun evilmi-prog-jump (info num)
+ "Use INFO to jump NUM times."
+ (evilmi-sdk-jump info num evilmi-prog-match-tags
evilmi-prog-extract-keyword-howtos))
+
+(provide 'evil-matchit-prog)
+;;; evil-matchit-prog.el ends here
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index 2c020ddd88..fad4e2795b 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -468,6 +468,9 @@ after calling this function."
(= (line-beginning-position) (point-min)))
(setq found t)))
+ (when evilmi-debug
+ (message "evilmi-sdk-jump was called. ideal-dest=%s" ideal-dest))
+
ideal-dest))
diff --git a/evil-matchit.el b/evil-matchit.el
index ee53be43ad..ac8bbc43a1 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -81,6 +81,10 @@ Some people prefer using \"m\" instead.")
(unless num (setq num 1))
+ (when (derived-mode-p 'prog-mode)
+ (setq jump-rules
+ (append (plist-get evilmi-plugins 'prog-mode) jump-rules)))
+
(when jump-rules
(dolist (rule jump-rules)
;; execute evilmi-xxxx-get-tag
@@ -140,6 +144,10 @@ Some people prefer using \"m\" instead.")
(defun evilmi-init-plugins ()
"Load plugins."
(interactive)
+
+ ;; rules for `prog-mode'
+ (evilmi-load-plugin-rules '(prog-mode) '(prog))
+
;; simple matching for languages containing brackets
(evilmi-load-plugin-rules '(java-mode perl-mode cperl-mode go-mode)
'(simple))
diff --git a/tests/conflict.js b/tests/conflict.js
new file mode 100644
index 0000000000..f90420389d
--- /dev/null
+++ b/tests/conflict.js
@@ -0,0 +1,20 @@
+function hello() {
+ console.log('hello world');
+}
+
+<<<<<<< 97a4bebea... debug
+const test1 = [
+];
+
+const test2 = {
+};
+=======
+
+const test3 = hello(
+);
+>>>>>>> 97a4bebea... debug
+
+const test4 = hello(
+);
+
+// bye
\ No newline at end of file
diff --git a/tests/evil-matchit-tests.el b/tests/evil-matchit-tests.el
index a16abd6365..ff80d64768 100644
--- a/tests/evil-matchit-tests.el
+++ b/tests/evil-matchit-tests.el
@@ -554,5 +554,20 @@
(should (eq major-mode 'org-mode))))
+(ert-deftest evilmi-test-merge-conflict ()
+ (with-temp-buffer
+ (evilmi-test-read-file "conflict.js")
+ (js-mode)
+
+ (goto-char (point-min))
+ (re-search-forward "^<<<<<<")
+ (evilmi-jump-items)
+ (should (string-match "^======" (evilmi-sdk-curline)))
+ (evilmi-jump-items)
+ (should (string-match "^>>>>>>" (evilmi-sdk-curline)))
+ (evilmi-jump-items)
+ (should (string-match "^<<<<<<" (evilmi-sdk-curline)))
+
+ (should (eq major-mode 'js-mode))))
(ert-run-tests-batch-and-exit)
;;; evil-matchit-tests.el ends here
- [nongnu] elpa/evil-matchit d779aedaf1 195/244: clean code, (continued)
- [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
- [nongnu] elpa/evil-matchit 6390e9e06c 216/244: Silence byte-compiler, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ae8fddea39 207/244: clean code, tdd for markdown, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0fd65c463b 226/244: clean code&doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ceec6a63b0 236/244: better algorithm to match bracket/brace in javascript, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8c4f516265 238/244: Support matlab-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 82c80786e5 240/244: jump between merge conflict markers,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit 5c43939d01 212/244: Merge pull request #126 from neojski/more-ocaml-tests, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit cdb9b90381 229/244: extra json support, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d005e0465e 223/244: Merge pull request #130 from nbfalcon/bugfix/evilmi-sdk-simple-jump-whitespace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ce90eae4bd 243/244: typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit a0c5bd1fe8 230/244: support quote and export section in org file, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9cdaddd55d 228/244: Merge pull request #132 from aaronjensen/require-evil-macros, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8b71b42603 041/244: better support for sh and c/c++ v1.2.8, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4846518b59 109/244: support rjsx-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0b0e6d61a6 119/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8a10046f25 145/244: fix python issue, ELPA Syncer, 2022/01/06