[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit a0c5bd1fe8 230/244: support quote and export
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit a0c5bd1fe8 230/244: support quote and export section in org file |
Date: |
Thu, 6 Jan 2022 02:59:04 -0500 (EST) |
branch: elpa/evil-matchit
commit a0c5bd1fe89119b94ffb0a266d2969434e7ec4c1
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
support quote and export section in org file
---
evil-matchit-org.el | 51 ++++++++++++++++++++++++++-------------------
evil-matchit.el | 4 ++--
pkg.sh | 2 +-
tests/evil-matchit-tests.el | 20 ++++++++++++++++++
tests/hello.org | 23 ++++++++++++++++++++
5 files changed, 76 insertions(+), 24 deletions(-)
diff --git a/evil-matchit-org.el b/evil-matchit-org.el
index ed1435adc6..8a3cb5597e 100644
--- a/evil-matchit-org.el
+++ b/evil-matchit-org.el
@@ -1,6 +1,6 @@
;;; evil-matchit-org.el --- org-mode plugin of evil-matchit
-;; Copyright (C) 2014-2020 Chen Bin <chenbin DOT sh AT gmail DOT com>
+;; Copyright (C) 2014-2021 Chen Bin <chenbin DOT sh AT gmail DOT com>
;; Author: Chen Bin <chenbin DOT sh AT gmail DOT com>
@@ -24,6 +24,10 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
;; OPTIONAL, you don't need SDK to write a plugin for evil-matchit
@@ -35,49 +39,53 @@
(defvar evilmi-org-extract-keyword-howtos
'(("^[ \t]*#\\+\\([a-zA-Z_]+\\).*$" 1)
("^[ \t]*\\:\\([a-zA-Z_]+\\)\\:$" 1))
- "The list of HOWTO on extracting keyword from current line.
-Each howto is actually a pair. The first element of pair is the regular
-expression to match the current line. The second is the index of sub-matches
-to extract the keyword which starts from one. The sub-match is the match
defined
-between '\\(' and '\\)' in regular expression.")
+ "How to extract keyword from current line. Each howto is a pair.
+First item of pair is regex to match current line.
+Second is index of sub-match to extract keyword.
+Sub-match is the match defined between '\\(' and '\\)' in regular expression.")
(defvar evilmi-org-match-tags
- '((("begin_src") () ( "end_src") "MONOGAMY")
- (("begin_example") () ( "end_example") "MONOGAMY")
- (("begin_html") () ( "end_html") "MONOGAMY")
- (("results") () ( "end") "MONOGAMY")))
+ '((("begin_src") () ("end_src") "MONOGAMY")
+ (("begin_example") () ("end_example") "MONOGAMY")
+ (("begin_html") () ("end_html") "MONOGAMY")
+ (("begin_quote") () ("end_quote") "MONOGAMY")
+ (("begin_export") () ("end_export") "MONOGAMY")
+ (("results") () ("end") "MONOGAMY"))
+ "Match tags in org file.")
(defun evilmi--element-property (property element)
"Extract the value from the PROPERTY of an ELEMENT."
(unless (stringp element)
- ;; we don't use org-element-property because it's
+ ;; `org-element-property' is not used because it's
;; available only in 24.4+
(plist-get (nth 1 element) property)))
(defun evilmi--get-embedded-language-major-mode ()
- ;; org-element-at-point is available only at org7+
+ "Get major of embedded snippet."
(let* ((lang (evilmi--element-property :language (org-element-at-point))))
(when lang
- (if (string= lang "elisp")
- 'emacs-lisp-mode
- (intern (concat lang "-mode"))))))
+ (cond
+ ((string= lang "elisp")
+ 'emacs-lisp-mode)
+ (t
+ (intern (concat lang "-mode")))))))
;;;###autoload
(defun evilmi-org-get-tag ()
"Get current tag in org file."
(let* ((rlt (evilmi-sdk-get-tag evilmi-org-match-tags
evilmi-org-extract-keyword-howtos)))
- (unless rlt
- ;; evilmi-org-jump knows what -1 means
- (setq rlt '(-1)))
+ ;; evilmi-org-jump knows what -1 means
+ (unless rlt (setq rlt '(-1)))
rlt))
(defvar evilmi-plugins)
;;;###autoload
-(defun evilmi-org-jump (rlt num)
+(defun evilmi-org-jump (info num)
+ "Jump to the matching tag using INFO and NUM."
(cond
- ((< (car rlt) 0)
+ ((< (car info) 0)
(let* (ideal-dest
jumped
info
@@ -94,9 +102,10 @@ between '\\(' and '\\)' in regular expression.")
(setq jumped t)))
plugin))))
(t
- (evilmi-sdk-jump rlt
+ (evilmi-sdk-jump info
num
evilmi-org-match-tags
evilmi-org-extract-keyword-howtos))))
(provide 'evil-matchit-org)
+;;; evil-matchit-org.el ends here
diff --git a/evil-matchit.el b/evil-matchit.el
index 05f792e059..d9950ae18d 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -4,7 +4,7 @@
;; Author: Chen Bin <chenbin DOT sh AT gmail DOT com>
;; URL: http://github.com/redguardtoo/evil-matchit
-;; Version: 2.3.10
+;; Version: 2.3.11
;; Keywords: matchit vim evil
;; Package-Requires: ((evil "1.2.0") (emacs "25.1"))
;;
@@ -315,7 +315,7 @@ If IS-INNER is t, the region is inner text object."
(defun evilmi-version()
"Print version."
(interactive)
- (message "2.3.10"))
+ (message "2.3.11"))
(defvar evil-matchit-mode-map (make-sparse-keymap)
"Keymap used by the minor mode.")
diff --git a/pkg.sh b/pkg.sh
index ee1de47900..52a0618867 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
#!/bin/bash
name=evil-matchit
-version=2.3.10
+version=2.3.11
pkg=$name-$version
mkdir $pkg
cp README.org $pkg
diff --git a/tests/evil-matchit-tests.el b/tests/evil-matchit-tests.el
index 200113982e..f1e9a8f56f 100644
--- a/tests/evil-matchit-tests.el
+++ b/tests/evil-matchit-tests.el
@@ -483,5 +483,25 @@
(evilmi-sdk-simple-jump)
(should (= (char-after) ?{))))
+(ert-deftest evilmi-test-org ()
+ (with-temp-buffer
+ (evilmi-test-read-file "hello.org")
+ (org-mode)
+ (font-lock-ensure)
+
+ (goto-char (point-min))
+ (search-forward "#+begin_src")
+ (evilmi-jump-items)
+ (should (string= "#+end_src" (evilmi-sdk-curline)))
+ (evilmi-jump-items)
+ (should (string= "#+begin_src javascript" (evilmi-sdk-curline)))
+
+ (search-forward "#+begin_quote")
+ (evilmi-jump-items)
+ (should (string= "#+end_quote" (evilmi-sdk-curline)))
+ (evilmi-jump-items)
+ (should (string= "#+begin_quote" (evilmi-sdk-curline)))
+
+ (should (eq major-mode 'org-mode))))
(ert-run-tests-batch-and-exit)
;;; evil-matchit-tests.el ends here
diff --git a/tests/hello.org b/tests/hello.org
new file mode 100644
index 0000000000..e069511a56
--- /dev/null
+++ b/tests/hello.org
@@ -0,0 +1,23 @@
+#+OPTIONS: ^:{} toc:nil H:3
+* myproject (v0.0.1)
+One liner to describe this program.
+* Why
+- feature1
+- feature2
+* Install
+Install it through [[http://melpa.org]].
+* Setup
+#+begin_src javascript
+console.log('hello world);
+while(true) {
+ console('bye');
+}
+#+end_src
+
+some random text
+#+begin_quote
+console.log('hello world);
+while(true) {
+ console('bye');
+}
+#+end_quote
\ No newline at end of file
- [nongnu] elpa/evil-matchit 6390e9e06c 216/244: Silence byte-compiler, (continued)
- [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, 2022/01/06
- [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 <=
- [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
- [nongnu] elpa/evil-matchit 0d62d497d1 143/244: Fix typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4435f3ada5 128/244: evil-matchit-org: add :results: :end: drawer, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit a91ea21c4a 141/244: Fix typo in readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit fb5807c096 129/244: Merge pull request #82 from et2010/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4f3928db11 157/244: let evil-repeat ignore evilmi jump, ELPA Syncer, 2022/01/06