[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 19/77: Add lispy treatment for +/- on list and sexp
From: |
Leo Liu |
Subject: |
[elpa] 19/77: Add lispy treatment for +/- on list and sexp |
Date: |
Sat, 05 Apr 2014 04:08:14 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 4535720193d2ab921245940cd4b128c77c06c19e
Author: Leo Liu <address@hidden>
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
- [elpa] 04/77: Use overlay for storing kill candidate and change +/-, (continued)
- [elpa] 04/77: Use overlay for storing kill candidate and change +/-, Leo Liu, 2014/04/05
- [elpa] 11/77: Minor tweaks to easy-kill-on-url, Leo Liu, 2014/04/05
- [elpa] 12/77: Tweak the definition of thing `region', Leo Liu, 2014/04/05
- [elpa] 13/77: New command easy-kill-region to kill current selection, Leo Liu, 2014/04/05
- [elpa] 10/77: New function easy-kill-adjust-candidate and doc fix, Leo Liu, 2014/04/05
- [elpa] 16/77: Make function easy-kill-candidate always return string, Leo Liu, 2014/04/05
- [elpa] 17/77: Fix error: (args-out-of-range 1009 1035), Leo Liu, 2014/04/05
- [elpa] 15/77: Some string and comment fixes, Leo Liu, 2014/04/05
- [elpa] 23/77: Use parse-partial-sexp in easy-kill-bounds-of-list, Leo Liu, 2014/04/05
- [elpa] 20/77: Replace `enlarge' with `expand' in strings and comments, Leo Liu, 2014/04/05
- [elpa] 19/77: Add lispy treatment for +/- on list and sexp,
Leo Liu <=
- [elpa] 14/77: Doc fix and release v0.7.0, Leo Liu, 2014/04/05
- [elpa] 22/77: Handle the case when overlay has already been destroyed, Leo Liu, 2014/04/05
- [elpa] 25/77: Fix thinko in easy-kill-backward-down, Leo Liu, 2014/04/05
- [elpa] 21/77: New command easy-kill-mark-region, Leo Liu, 2014/04/05
- [elpa] 24/77: Improve list expand/shrink support in smie-based modes, Leo Liu, 2014/04/05
- [elpa] 18/77: Consolidate all kill features in easy-kill-thing, Leo Liu, 2014/04/05
- [elpa] 26/77: Fix #2: just call kill-ring-save when region is active, Leo Liu, 2014/04/05
- [elpa] 27/77: Declare dependency on emacs 24, Leo Liu, 2014/04/05
- [elpa] 29/77: Merge pull request #4 from purcell/patch-1, Leo Liu, 2014/04/05
- [elpa] 31/77: Simplify the interactive form of easy-kill-thing, Leo Liu, 2014/04/05