summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorexpez <expez@expez.com>2013-12-29 14:13:48 +0100
committerexpez <expez@expez.com>2013-12-29 14:13:48 +0100
commitf331d1c9f21c4ebc6aa1833f965a90c4640fe504 (patch)
tree7e84681c4d90f50f206a7dc573d8c84aa8ebd8be
parente74eddea6e6b1a3a6ecde2e5be191fd7d54d017f (diff)
fix bugs
-rw-r--r--evil-paredit.el55
1 files changed, 36 insertions, 19 deletions
diff --git a/evil-paredit.el b/evil-paredit.el
index deb01ff..22a3ea1 100644
--- a/evil-paredit.el
+++ b/evil-paredit.el
@@ -59,13 +59,19 @@
:motion evil-line
:move-point nil
(interactive "<R><x>")
- (let ((paren-count (count-matches "(" (line-beginning-position)
- (line-end-position)))
- (last-balanced-paren (evil-paredit-position-of
- "\)"
- (line-beginning-position)
- (line-end-position))))
- (evil-paredit-yank beg last-balanced-paren type register)))
+ (let* ((paren-count (count-matches "(" (line-beginning-position)
+ (line-end-position)))
+ (closing-parens (count-matches ")" (point)
+ (line-end-position)))
+ (last-balanced-paren (evil-paredit-position-of
+ "\)"
+ (point)
+ (line-end-position)
+ paren-count))
+ (end (or end (if (= closing-parens 0)
+ (line-end-position)
+ last-balanced-paren))))
+ (evil-paredit-yank beg end type register)))
(evil-define-operator evil-paredit-delete
(beg end type register yank-handler)
@@ -89,15 +95,20 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
(interactive "<R><x>")
;; act linewise in Visual state
(let* ((beg (or beg (point)))
- (end (or end beg))
;; NOTE the following count will be off when it encounters
;; parens in strings.
- (paren-count (count-matches "(" (line-beginning-position)
+ (paren-count (count-matches "(" (point)
(line-end-position)))
+ (closing-parens (count-matches ")" (point)
+ (line-end-position)))
(last-balanced-paren (evil-paredit-position-of
"\)"
- (line-beginning-position)
- (line-end-position))))
+ (point)
+ (line-end-position)
+ paren-count))
+ (end (or end (if (= closing-parens 0)
+ (line-end-position)
+ last-balanced-paren))))
(when (evil-visual-state-p)
(unless (memq type '(line block))
(let ((range (evil-expand beg end 'line)))
@@ -117,7 +128,7 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
((eq type 'line)
(evil-paredit-delete beg end type register yank-handler))
(t
- (evil-paredit-delete beg last-balanced-paren
+ (evil-paredit-delete beg end
type register yank-handler)))))
(defun evil-paredit-position-of (regexp start stop &optional nth)
@@ -154,13 +165,19 @@ of the block."
"Change to end of line respecting parenthesis."
:motion evil-end-of-line
(interactive "<R><x><y>")
- (let ((paren-count (count-matches "(" (line-beginning-position)
- (line-end-position)))
- (last-balanced-paren (evil-paredit-position-of
- "\)"
- (line-beginning-position)
- (line-end-position))))
- (evil-paredit-change beg last-balanced-paren type register yank-handler)))
+ (let* ((paren-count (count-matches "(" (point)
+ (line-end-position)))
+ (closing-parens (count-matches ")" (point)
+ (line-end-position)))
+ (last-balanced-paren (evil-paredit-position-of
+ "\)"
+ (point)
+ (line-end-position)
+ paren-count))
+ (end (if (= closing-parens 0)
+ (line-end-position)
+ last-balanced-paren)))
+ (evil-paredit-change (point) end type register yank-handler)))
(evil-define-key 'normal evil-paredit-mode-map
(kbd "d") 'evil-paredit-delete