emacs-elpa-diffs
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]