Skip to content

Commit

Permalink
">" will delete some whitespace
Browse files Browse the repository at this point in the history
* lispy.el (lispy--slurp-forward): Improve.

* lispy-test.el (lispy-slurp): Add test.

Fixes #52.
  • Loading branch information
abo-abo committed Feb 21, 2015
1 parent 8c80bc5 commit 0fdd958
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lispy-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,9 @@ Insert KEY if there's no command."
(should (string= (lispy-with "(progn\n foo-bar-baz-flip-|flop~)" (lispy-slurp 5))
"(progn\n |foo-bar-baz-flip-flop~)"))
(should (string= (lispy-with "(progn\n |foo-bar~-baz-flip-flop)" (lispy-slurp 1))
"(progn\n |foo-bar~-baz-flip-flop)")))
"(progn\n |foo-bar~-baz-flip-flop)"))
(should (string= (lispy-with "()| foo" (lispy-slurp 1))
"(foo)|")))

(ert-deftest lispy-barf ()
(should (string= (lispy-with "((a) (b) (c))|" "<")
Expand Down
8 changes: 4 additions & 4 deletions lispy.el
Original file line number Diff line number Diff line change
Expand Up @@ -4341,13 +4341,13 @@ For example, a `setq' statement is amended with variable name that it uses."
;;* Utilities: slurping and barfing
(defun lispy--slurp-forward ()
"Grow current sexp forward by one sexp."
(unless (or (looking-back "[()])")
(looking-at "$"))
(just-one-space)
(backward-char 1))
(let ((pt (point))
(char (char-before))
(beg (save-excursion (backward-list) (point))))
(skip-chars-forward " \t")
(delete-region pt (point))
(unless (or (looking-back "()") (eolp))
(insert " "))
(when (ignore-errors
(forward-sexp) t)
(delete-region (1- pt) pt)
Expand Down

0 comments on commit 0fdd958

Please sign in to comment.