home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
editor
/
me_cd.arc
/
INDENT.MUT
< prev
next >
Wrap
Lisp/Scheme
|
1988-10-05
|
1KB
|
47 lines
;; indent.mut : Shift a block left or right
;; A block is all the lines of text between the dot and mark inclusive.
;; With no arg: asks for the amount to shift the region. Positive
;; for right shift, negative for left shift.
;; With arg (ie ^U): shifts the region by the difference between
;; the dot and the first nonblank character on that line.
;; eg use this to shift the top line of the region over to the dot.
;; Removes white space from blank lines.
;; C Durland
(include me.h)
(include wspace.mut)
(defun indent
{
(int shift-count col)
(byte type)(int left-edge width height)(INT size)
(region-stats (loc type))
(if (arg-flag)
{
(col (current-column))
(beginning-of-line)(skip-whitespace)
(shift-count (- col (current-column)))
}
(shift-count (atoi (ask "indent region by n spaces. n = ")))
)
(if (== shift-count 0)(done))
(if (== type MARK-ABOVE-DOT)(exchange-dot-and-mark)) ; move to top of region
(beginning-of-line)
(while (!= 0 height)
{
(skip-whitespace)(col (current-column)) ; count blanks
(arg-prefix 0)(kill-line) ; move text to left margin
(end-of-line)
(if (!= 1 (current-column)) ; indent if line not blank
{
(beginning-of-line)
(to-col (+ col shift-count)) ; indent text n more columns
})
(forward-line 1) ; move to the next line
(-= height 1)
})
})