[comp.emacs] Indent/set left margin in Micro-Emacs

cjoslyn@bingvaxu.cc.binghamton.edu (Cliff Joslyn) (07/28/89)

I use MicroEMACS 3.8i (yes, I know it's old) on an AT, and am
considering writing an 'indent' or 'set left margin' macro, basically
rebinding 'fill-word' to look at some 'left margin' variable.  But I
thought I'd ask first if someone has one.

Thanks.

O---------------------------------------------------------------------->
| Cliff Joslyn, Cybernetician at Large
| Systems Science, SUNY Binghamton, cjoslyn@bingvaxu.cc.binghamton.edu
V All the world is biscuit shaped. . .


-- 
O---------------------------------------------------------------------->
| Cliff Joslyn, Cybernetician at Large
| Systems Science, SUNY Binghamton, cjoslyn@bingvaxu.cc.binghamton.edu
V All the world is biscuit shaped. . .

davidsen@sungod.crd.ge.com (William Davidsen) (07/29/89)

In article <2339@bingvaxu.cc.binghamton.edu> cjoslyn@bingvaxu.cc.binghamton.edu (Cliff Joslyn) writes:
| 
| I use MicroEMACS 3.8i (yes, I know it's old) on an AT, and am
| considering writing an 'indent' or 'set left margin' macro, basically
| rebinding 'fill-word' to look at some 'left margin' variable.  But I
| thought I'd ask first if someone has one.

  This is a true pain in the ass to do with 3.8{anything} and you should
go for 3.9i or later to get the fast searches (about 20:1 faster).
Here's how I do it for 3.9p (with the patches applied which I posted to
the net). You are free to translate if you really like 3.8i

----------------------------------------------------------------
;; left margin set
set %margin @"New margin: "
narrow-to-region
beginning-of-file

; delete any leading blanks
!while "TRUE"
	; see if this is a zero length line
	end-of-line
	!if &not &equal $curcol 0
		; delete any leading whitespace
		beginning-of-line
		!while &or &equal $curchar &asc " " &equal $curchar &asc "~t"
			delete-next-character
		!endwhile
	
		; indent the line
		%margin insert-string " "
	!endif

	; next line, please
	!force next-line
	!if $status
	!else
		!break
	!endif
!endwhile

; open up again
widen-from-region
write-message "Done"
----------------------------------------------------------------
You caught me in macro-writing mode, I just did a one-key "convert
scribe input to nroff input" package last weekend. Hope this gives you
an idea.
	bill davidsen		(davidsen@crdos1.crd.GE.COM)
  {uunet | philabs}!crdgw1!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me