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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 13/16: Some tests and bug fixes for org


From: Leo Liu
Subject: [elpa] 13/16: Some tests and bug fixes for org
Date: Tue, 22 Apr 2014 00:33:40 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit 302cbb25ffbbdbf2b13bd04f0314390ff10f4116
Author: Leo Liu <address@hidden>
Date:   Mon Apr 21 17:37:05 2014 +0800

    Some tests and bug fixes for org
---
 easy-kill.el |    4 ++--
 test.el      |   45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/easy-kill.el b/easy-kill.el
index 4b9970c..c55f482 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -767,8 +767,8 @@ inspected."
   (pcase (or n 1)
     (`0 nil)
     (_ (ignore-errors (dotimes (_ (abs n)) (org-up-element)))
-       (when (cl-plusp n)
-         (goto-char (cdr (easy-kill-bounds-of-thing-at-point 'list)))))))
+       (goto-char (funcall (if (cl-minusp n) #'car #'cdr)
+                           (easy-kill-bounds-of-thing-at-point 'list))))))
 
 (defun easy-kill-on-list:org (n)
   (pcase n
diff --git a/test.el b/test.el
index 2c82268..11aa533 100644
--- a/test.el
+++ b/test.el
@@ -253,6 +253,51 @@
       (should (string= "<author>Gambardella, Matthew</author>"
                        (easy-kill-candidate))))))
 
+(ert-deftest test-org-mode ()
+  (let ((org "#+title: This is a title
+#+author: Leo Liu
+
+This is an example of org document.
+
+* Life
+  One two three ....
+*** Fruits
+    1. apple
+    2. orange
+    3. mango
+
+* Sports cars
+  + Lamborghini
+  + Ferrari
+  + Porsche
+"))
+    (with-temp-buffer
+      (org-mode)
+      (insert org)
+      (goto-char (point-min))
+      (search-forward "This is")
+      (call-interactively 'easy-kill)
+      (easy-kill-thing 'sexp)
+      (easy-kill-expand)
+      (should (string= "#+title: This is a title\n" (easy-kill-candidate)))
+      (search-forward "Ferrari")
+      (call-interactively 'easy-kill)
+      (easy-kill-thing 'list)
+      (should (string= "Ferrari\n" (easy-kill-candidate)))
+      (easy-kill-expand)
+      (should (string= "  + Ferrari\n" (easy-kill-candidate)))
+      ;; org quirks
+      (search-backward "Lamborghini")
+      (call-interactively 'easy-kill)
+      (easy-kill-thing 'list)
+      ;; You get the whole plainlist here; see `org-element-at-point'.
+      (easy-kill-expand)
+      (should (string= "  + Lamborghini\n  + Ferrari\n  + Porsche\n"
+                       (easy-kill-candidate)))
+      (easy-kill-expand)
+      (should (string= "* Sports cars\n  + Lamborghini\n  + Ferrari\n  + 
Porsche\n"
+                       (easy-kill-candidate))))))
+
 (ert-deftest test-elisp-mode ()
   (let ((el "(defun set-hard-newline-properties (from to)
            (let ((sticky (get-text-property from 'rear-nonsticky)))



reply via email to

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