Skip to content

Commit 7756a8f

Browse files
committed
Make "O" work for vectors
* lispy.el (lispy--oneline): Update. * lispy-test.el (lispy-oneline): Add test.
1 parent 0ba8c22 commit 7756a8f

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

Diff for: lispy-test.el

+3-1
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,9 @@ Insert KEY if there's no command."
904904
(should (string= (lispy-with "(defun abc (x)\n \"def.\"\n (+ x\n x\n x))|" "O")
905905
"(defun abc (x) \"def.\" (+ x x x))|"))
906906
(should (string= (lispy-with "|(defun foo ()\n ;; comment\n (bar)\n (baz))" "O")
907-
";; comment\n|(defun foo () (bar) (baz))")))
907+
";; comment\n|(defun foo () (bar) (baz))"))
908+
(should (string= (lispy-with "[1\n 2\n 3\n 4\n 5]|" "O")
909+
"[1 2 3 4 5]|")))
908910

909911
(ert-deftest lispy-multiline ()
910912
(should (string= (lispy-with "|(defun abc (x) \"def.\" (+ x x x) (foo) (bar))"

Diff for: lispy.el

+22-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
;; Author: Oleh Krehel <[email protected]>
66
;; URL: https://github.com/abo-abo/lispy
7-
;; Version: 0.23.0
7+
;; Version: 0.26.0
88
;; Keywords: lisp
99

1010
;; This file is not part of GNU Emacs
@@ -2456,25 +2456,27 @@ When the sexp is top-level, insert an additional newline."
24562456
"Remove newlines from EXPR.
24572457
When IGNORE-COMMENTS is not nil, don't remove comments.
24582458
Instead keep them, with a newline after each comment."
2459-
(lispy-mapcan-tree
2460-
(lambda (x y)
2461-
(cond ((equal x '(ly-raw newline))
2462-
y)
2463-
((lispy--raw-comment-p x)
2464-
(if (null ignore-comments)
2465-
(progn
2466-
(push x lispy--oneline-comments)
2467-
y)
2468-
(if (equal (car y) '(ly-raw newline))
2469-
(cons x y)
2470-
`(,x (ly-raw newline) ,@y))))
2471-
((and (lispy--raw-string-p x)
2472-
(null ignore-comments))
2473-
(cons `(ly-raw string ,(replace-regexp-in-string "\n" "\\\\n" (caddr x)))
2474-
y))
2475-
(t
2476-
(cons x y))))
2477-
expr))
2459+
(if (vectorp expr)
2460+
(apply #'vector (lispy--oneline (mapcar #'identity expr)))
2461+
(lispy-mapcan-tree
2462+
(lambda (x y)
2463+
(cond ((equal x '(ly-raw newline))
2464+
y)
2465+
((lispy--raw-comment-p x)
2466+
(if (null ignore-comments)
2467+
(progn
2468+
(push x lispy--oneline-comments)
2469+
y)
2470+
(if (equal (car y) '(ly-raw newline))
2471+
(cons x y)
2472+
`(,x (ly-raw newline) ,@y))))
2473+
((and (lispy--raw-string-p x)
2474+
(null ignore-comments))
2475+
(cons `(ly-raw string ,(replace-regexp-in-string "\n" "\\\\n" (caddr x)))
2476+
y))
2477+
(t
2478+
(cons x y))))
2479+
expr)))
24782480

24792481
(defun lispy-oneline ()
24802482
"Squeeze current sexp into one line.

0 commit comments

Comments
 (0)