[net.emacs] Centering text

rosenblg@acf4.UUCP (12/11/84)

does anyone know of an easy way/macro to center text in a file?

thanks!

			{ihnp4!cmcl2!}acf4!rosenblg

andrew@orca.UUCP (Andrew Klossner) (12/13/84)

[]

	"does anyone know of an easy way/macro to center text in a
	file?"

If you're using Gosling/Unipress emacs, you can use the enclosed MLISP
function.  To use, bind it to a key, then, with the cursor on the
desired line, hit that key.  It will be centered between the left and
right margins.  If you have not set a right margin, it uses 72.

	"{ihnp4!cmcl2!}acf4!rosenblg"

The mail forwarder at ihnp4 says that "acf4" is a "bad system name".
In fact, ihnp4 has been bouncing a lot of my mail lately.

  -- Andrew Klossner   (decvax!tektronix!orca!andrew)       [UUCP]
                       (orca!andrew.tektronix@csnet-relay)  [ARPA]

------------------------------ cut here ------------------------------
(defun (center-line current-mark end-mark spaces
	(setq current-mark (dot))
	(beginning-of-line)
	(while (= ' ' (following-char))
		(delete-next-character)
		)
	(end-of-line)
	(setq end-mark (dot))
	(beginning-of-line)
	(setq spaces
		(/ (-
			(if (= right-margin 10000) 72 right-margin)
			(- end-mark (dot))
		   ) 2)
		)
	(while (> spaces 0)
		(insert-character ' ')
		(setq spaces (- spaces 1))
		)
	(goto-character current-mark)
	(novalue)
	))