[comp.emacs] auto-fill-indent-right-margin

yedidya@bimacs.BITNET (Yedidya Israel) (09/05/89)

Is there a .el file that enter emacs into a (minor) mode that makes
auto indentation on both margins, i.e. pad line with some spaces here
and there in order to make a right margin.

--
| Israel Yedidya, Math & CS Department, Bar-Ilan U, Ramat-Gan, ISRAEL. |
+----------------------------------------------------------------------+
| Bitnet:   yedidya@bimacs                                             |
| Internet: yedidya@bimacs.biu.ac.il                                   |
| Arpa:     yedidya%bimacs.bitnet@cunyvm.cuny.edu                      |
| Uucp:     ...!uunet!mcvax!humus!bimacs!yedidya                       |
| Csnet:    yedidya%bimacs.bitnet%cunyvm.cuny.edu@csnet-relay          |
\----------------------------------------------------------------------/
 \--- If someone proves there is no God, I'll stop being religious ---/
  --------------------------------------------------------------------

rab@cbnews.ATT.COM (robert.a.biedenharn) (09/06/89)

In article <1054@bimacs.BITNET> yedidya@bimacs.BITNET (Yedidya Israel) writes:
>Is there a .el file that enter emacs into a (minor) mode that makes
>auto indentation on both margins, i.e. pad line with some spaces here
>and there in order to make a right margin.

Actually, Auto-Fill mode does what you want.  C-x .  (I think, no emacs on
the news machine!)  sets the variable  fill-prefix  to be the stuff between
the beginning of the line and the point.  Auto fills will put this on the newly
create line before the wrapped text.  (And fill-paragraph works, too.)

Rob          ..!att!cbsck!rab

spencer@eecs.umich.edu (Spencer W. Thomas) (09/06/89)

There  is  a  function "justify-current-line".  You   can  use this to
change  your auto-fill-hook as  shown   below.  I haven't tested  this
extensively, but I did  use it while I  was  typing this reply, so you
can  see the   effect.  You also  can supply   a   prefix argument  to
fill-paragraph to get justification that way.

(defun do-auto-justify ()
  (do-auto-fill)
  (save-excursion
    (previous-line 1)
    (justify-current-line)))
(setq auto-fill-hook 'do-auto-justify)

--
=Spencer (spencer@eecs.umich.edu)

jka@hpfcso.HP.COM (Jay Adams) (09/07/89)

This is a little thing I tossed off once.  It is essentially Spencer's
idea w/ bells and whistles.

- Jay


(defvar auto-justify-mode '()
  "Non nil if auto justifying is turned on.")

(or (assoc 'auto-justify-mode minor-mode-alist)
    (setq minor-mode-alist
	  (cons '(auto-justify-mode " Justify")
		minor-mode-alist)))
	   
(defun auto-justify-mode ()
  (interactive)
  "Toggle an auto fill mode that lines up right margins."
  (if (eq auto-fill-hook 'do-auto-fill-justify)
	(setq auto-fill-hook 'do-auto-fill
	      auto-justify-mode nil)
    (setq auto-fill-hook 'do-auto-fill-justify
	  auto-justify-mode t)))

(defun do-auto-fill-justify ()
  "Same as do-auto-fill \'cept fixes right margin on current line."
  (do-auto-fill)
  (save-excursion
    (previous-line 1)
    (justify-current-line)))