home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34src.zip
/
me3
/
mutt
/
builtin
/
indent.mut
< prev
next >
Wrap
Text File
|
1995-01-14
|
2KB
|
50 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 cursor.
;; Removes white space from blank lines.
;; When doing a negative shift, text won't be shifted left of the left
;; margin.
;; C Durland Public Domain
(include wspace.mut)
(include runblock.mut)
(defun
indent-line (int shift-count) HIDDEN
{
(int col)
(skip-whitespace)(col (current-column)) ; count blanks
(arg-prefix 0)(cut-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
})
}
indent-rigidly
{
(int col shift-count)
(if (== 0 ;; if no shifting then don't do anything
(shift-count ;; calculate the amount to shift
(if (arg-flag) ;; by looking at the point
{
(arg-flag FALSE 1) ;; reset arg count
(col (current-column))
(beginning-of-line)(skip-whitespace)
(- col (current-column))
}
;; by asking
(convert-to NUMBER (ask "indent region by n spaces. n = "))
)))
(done))
(run-pgm-on-block (floc indent-line) shift-count)
}
)