diff --git a/README.md b/README.md index 4de25ec..6bfbf34 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ implementation status of planned features: - [x] n - ce-command-num-print - [x] p - ce-command-print - [x] s - ce-command-reg-replace -- [ ] t - ce-command-copy +- [x] t - ce-command-copy - [x] w - ce-command-write - [x] x - ce-command-chop - [x] X - ce-command-chop-beg diff --git a/ce.cl b/ce.cl index e0dfc23..73a5f67 100644 --- a/ce.cl +++ b/ce.cl @@ -421,6 +421,20 @@ specific command. the recognized commands are as follows: (ce-push-line i res) (return)))))))) +(defun ce-command-copy (&optional c) + "copy the region to argument line" + (declare (ignore c)) + (ce-reset-input) + (let ((mlen (list-length buffer))) + (let ((inp (1+ (ce-mod (parse-integer (read-line)) mlen))) + (in (ce-mod inpoint mlen)) + (out (1+ (ce-mod outpoint mlen)))) + (let ((copy (subseq buffer in out)) + (diff (1- (- out in)))) + (ce-push-lines inp copy) + (setq inpoint inp) + (setq outpoint (+ inp diff)))))) + ; TODO: needs error handling (defun ce-command-write (&optional c) "write a file to disk"