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

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

[elpa] 14/16: Fix easy-kill-org-up-element


From: Leo Liu
Subject: [elpa] 14/16: Fix easy-kill-org-up-element
Date: Tue, 22 Apr 2014 00:33:40 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit 20ed0d595e5893e2c57a634a3137ef87b1714f17
Author: Leo Liu <address@hidden>
Date:   Mon Apr 21 22:22:52 2014 +0800

    Fix easy-kill-org-up-element
---
 easy-kill.el |   14 +++++++++-----
 test.el      |    5 +++++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/easy-kill.el b/easy-kill.el
index c55f482..5db6823 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -645,7 +645,7 @@ inspected."
 (defun easy-kill-thing-forward-defun (&optional n)
   (pcase (or n 1)
     ((pred cl-minusp) (beginning-of-defun (- n)))
-    (_ (end-of-defun n))))
+    (n (end-of-defun n))))
 
 ;;; Handler for `sexp' and `list'.
 
@@ -753,7 +753,7 @@ inspected."
 (defun easy-kill-thing-forward-list:org (&optional n)
   (pcase (or n 1)
     (`0 nil)
-    (_ (dotimes (_ (abs n))
+    (n (dotimes (_ (abs n))
          (condition-case nil
              (if (cl-minusp n)
                  (org-backward-element)
@@ -766,9 +766,13 @@ inspected."
   ;; Make `org-up-element' more like `up-list'.
   (pcase (or n 1)
     (`0 nil)
-    (_ (ignore-errors (dotimes (_ (abs n)) (org-up-element)))
-       (goto-char (funcall (if (cl-minusp n) #'car #'cdr)
-                           (easy-kill-bounds-of-thing-at-point 'list))))))
+    (n (ignore-errors
+         (dotimes (_ (abs n))
+           (pcase (list (point) (easy-kill-bounds-of-thing-at-point 'list))
+             (`(,_beg (,_beg . ,_)) (org-up-element))
+             (`(,_ (,beg . ,_))     (goto-char beg)))))
+       (when (cl-plusp n)
+         (goto-char (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 11aa533..3c021d3 100644
--- a/test.el
+++ b/test.el
@@ -280,6 +280,11 @@ This is an example of org document.
       (easy-kill-thing 'sexp)
       (easy-kill-expand)
       (should (string= "#+title: This is a title\n" (easy-kill-candidate)))
+      (search-forward "Fruits")
+      (call-interactively 'easy-kill)
+      (easy-kill-thing 'sexp)
+      (easy-kill-expand)
+      (should (string-prefix-p "*** Fruits" (easy-kill-candidate)))
       (search-forward "Ferrari")
       (call-interactively 'easy-kill)
       (easy-kill-thing 'list)



reply via email to

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