ce-command-join: implement
This commit is contained in:
parent
4f6e6d6d82
commit
7be5e59711
@ -36,7 +36,7 @@ implementation status of planned features:
|
||||
- [x] h - ce-command-help
|
||||
- [x] i - ce-command-insert
|
||||
- [x] I - ce-command-insert-beg
|
||||
- [ ] j - ce-command-join
|
||||
- [x] j - ce-command-join
|
||||
- [x] m - ce-command-copy (move)
|
||||
- [x] n - ce-command-num-print
|
||||
- [x] p - ce-command-print
|
||||
|
14
ce.cl
14
ce.cl
@ -84,9 +84,13 @@
|
||||
|
||||
(defun ce-apply-region (fun)
|
||||
"apply fun to each line of region"
|
||||
(ce-pipe-region (lambda (x) (mapcar fun x))))
|
||||
|
||||
(defun ce-pipe-region (fun)
|
||||
"pipe region through function"
|
||||
(let ((mlen (list-length buffer)))
|
||||
(let ((in (ce-mod inpoint mlen)) (out (1+ (ce-mod outpoint mlen))))
|
||||
(let ((new (mapcar fun (subseq buffer in out))))
|
||||
(let ((new (funcall fun (subseq buffer in out))))
|
||||
(ce-replace-lines in out new)))))
|
||||
|
||||
(defun ce-push-line (index line)
|
||||
@ -376,6 +380,14 @@ specific command. the recognized commands are as follows:
|
||||
(declare (ignore c))
|
||||
(ce-build-insert inp x))
|
||||
|
||||
(defun ce-command-join (&optional c)
|
||||
"join lines together, replacing newlines with spaces"
|
||||
(declare (ignore c))
|
||||
(ce-reset-input)
|
||||
(read-line)
|
||||
(ce-pipe-region
|
||||
(lambda (x) (list (format nil "~{~a~^ ~}" x)))))
|
||||
|
||||
(defun ce-command-num-print (&optional c)
|
||||
"print a region with line numbers"
|
||||
(declare (ignore c))
|
||||
|
Loading…
Reference in New Issue
Block a user