leoliu pushed a commit to branch master in repository elpa. commit 4535720193d2ab921245940cd4b128c77c06c19e Author: Leo Liu <sdl....@gmail.com> Date: Tue Oct 8 15:16:36 2013 +0800
Add lispy treatment for +/- on list and sexp --- easy-kill.el | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index c81eab0..b33f43c 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -273,5 +273,35 @@ inspected." (easy-kill-adjust-candidate 'url url) (return url))))))) +(defun easy-kill-bounds-of-list (n) + (save-excursion + (pcase n + (`+ (goto-char (overlay-start easy-kill-candidate)) + (with-demoted-errors (up-list -1)) + (with-demoted-errors + (cons (point) (progn (forward-sexp) (point))))) + (`- (let ((bound (or (cdr (bounds-of-thing-at-point 'sexp)) (point)))) + (goto-char (overlay-start easy-kill-candidate)) + (with-demoted-errors + (down-list 1) + (while (< (point) bound) (forward-sexp 1))) + (when (>= (point) bound) + (let ((end (point))) + (with-demoted-errors + (cons (progn (forward-sexp -1) (point)) end)))))) + (_ (error "Unsupported argument `%s'" n))))) + +(defun easy-kill-on-list (n) + (if (memq n '(+ -)) + (let ((bounds (easy-kill-bounds-of-list n))) + (easy-kill-adjust-candidate 'list (car bounds) (cdr bounds))) + (easy-kill-thing 'list n nil t))) + +(defun easy-kill-on-sexp (n) + (if (memq n '(+ -)) + (let ((bounds (easy-kill-bounds-of-list n))) + (easy-kill-adjust-candidate 'sexp (car bounds) (cdr bounds))) + (easy-kill-thing 'sexp n nil t))) + (provide 'easy-kill) ;;; easy-kill.el ends here