add x and X commands
not originally planned, but would be nice to have a counterpart to i/I
This commit is contained in:
parent
9685d31af6
commit
14ad178349
|
@ -40,5 +40,7 @@ implementation status of planned features:
|
|||
- [x] s - ce-command-reg-replace
|
||||
- [ ] t - ce-command-copy
|
||||
- [x] w - ce-command-write
|
||||
- [x] x - ce-command-chop
|
||||
- [x] X - ce-command-chop-beg
|
||||
- [x] 0 - ce-command-number
|
||||
|
||||
|
|
22
ce.cl
22
ce.cl
|
@ -30,6 +30,8 @@
|
|||
(#\s . ce-command-reg-replace)
|
||||
(#\t . ce-command-copy)
|
||||
(#\w . ce-command-write)
|
||||
(#\x . ce-command-chop)
|
||||
(#\X . ce-command-chop-beg)
|
||||
(#\0 . ce-command-number)
|
||||
(#\1 . ce-command-number)
|
||||
(#\2 . ce-command-number)
|
||||
|
@ -431,6 +433,26 @@ specific command. the recognized commands are as follows:
|
|||
:if-does-not-exist :create)
|
||||
(format out "~{~a~%~}" buffer))))
|
||||
|
||||
(defmacro ce-build-chop (fin)
|
||||
"helper for chop and chop-beg"
|
||||
`(progn
|
||||
(ce-reset-input)
|
||||
(let ((inp (parse-integer (string-or (read-line) "1"))))
|
||||
(ce-apply-region (lambda (x)
|
||||
(let ((llen (length x)))
|
||||
(if (< llen inp)
|
||||
x ,fin)))))))
|
||||
|
||||
(defun ce-command-chop (&optional c)
|
||||
"chop off argument characters from end of each line in region"
|
||||
(declare (ignore c))
|
||||
(ce-build-chop (subseq x 0 (- llen inp))))
|
||||
|
||||
(defun ce-command-chop-beg (&optional c)
|
||||
"chop off argument characters from start of each line in region"
|
||||
(declare (ignore c))
|
||||
(ce-build-chop (subseq x inp)))
|
||||
|
||||
(defun ce-command-number (c)
|
||||
"input a number"
|
||||
(if (or (= 0 newpoint) (= 2 newpoint))
|
||||
|
|
Loading…
Reference in New Issue