[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 24/77: Improve list expand/shrink support in smie-based modes
From: |
Leo Liu |
Subject: |
[elpa] 24/77: Improve list expand/shrink support in smie-based modes |
Date: |
Sat, 05 Apr 2014 04:08:15 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 26288e78efc586fc6ff4dcf4d348d906f7f2c0fe
Author: Leo Liu <address@hidden>
Date: Wed Oct 9 11:49:12 2013 +0800
Improve list expand/shrink support in smie-based modes
such as octave, ruby, css etc.
---
easy-kill.el | 40 +++++++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/easy-kill.el b/easy-kill.el
index 82baa79..6d37b7f 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -295,20 +295,35 @@ inspected."
(easy-kill-adjust-candidate 'url url)
(return url)))))))
+(defun easy-kill-backward-up ()
+ (condition-case nil
+ (up-list -1)
+ (scan-error (let ((ppss (syntax-ppss)))
+ (and (nth 3 ppss) (goto-char (nth 8 ppss)))))))
+
+(defun easy-kill-backward-down (point &optional bound)
+ (condition-case nil
+ (progn
+ (easy-kill-backward-up)
+ (if (or (not bound)
+ (and (> (point) bound) (/= point (point))))
+ (easy-kill-backward-down (point) bound)
+ point))
+ (scan-error point)))
+
(defun easy-kill-bounds-of-list (n)
(save-excursion
(pcase n
- (`+ (goto-char (overlay-start easy-kill-candidate))
- (ignore-errors
- (up-list -1)
- (cons (point) (progn (forward-sexp) (point)))))
- (`- (let ((depth (car (parse-partial-sexp
- (overlay-start easy-kill-candidate) (point)))))
- (if (> depth 1)
- (ignore-errors
- (goto-char (scan-lists (point) -1 (1- depth)))
- (cons (point) (progn (forward-sexp 1) (point))))
- (bounds-of-thing-at-point 'sexp))))
+ (`+ (let ((start (overlay-start easy-kill-candidate)))
+ (goto-char start)
+ (easy-kill-backward-up)
+ (when (/= start (point))
+ (cons (point) (progn (forward-sexp) (point))))))
+ (`- (let ((pt (point)))
+ (goto-char (easy-kill-backward-down
+ (point) (overlay-start easy-kill-candidate)))
+ (when (/= pt (point))
+ (cons (point) (progn (forward-sexp 1) (point))))))
(_ (error "Unsupported argument `%s'" n)))))
(defun easy-kill-on-list (n)
@@ -319,8 +334,7 @@ inspected."
(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-on-list n)
(easy-kill-thing 'sexp n nil t)))
(provide 'easy-kill)
- [elpa] 16/77: Make function easy-kill-candidate always return string, (continued)
- [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, 2014/04/05
- [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 <=
- [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
- [elpa] 28/77: [remap kill-ring-save] should be a better key binding for this feature., Leo Liu, 2014/04/05
- [elpa] 35/77: Doc fix and release v0.8.0, Leo Liu, 2014/04/05
- [elpa] 36/77: New variable easy-kill-base-map for customising key bindings, Leo Liu, 2014/04/05
- [elpa] 33/77: Support append kill for append-next-kill and easy-kill, Leo Liu, 2014/04/05
- [elpa] 34/77: Better support for defining commands that exit easy-kill, Leo Liu, 2014/04/05