[comp.emacs] indenting in emacs

guardian@wpi.wpi.edu (Robert W Langer) (02/27/89)

Is there a way to have emacs indent each line the same as the last
instead of going back to the margin each time return is hit.  This is
used in some programming editors, and I was wondering if there was a
way to do it in emacs, hopefully as a mode.

Thanks.

kjones@talos.UUCP (Kyle Jones) (02/28/89)

Robert W Langer writes:
>Is there a way to have emacs indent each line the same as the last
>instead of going back to the margin each time return is hit.  This is
>used in some programming editors, and I was wondering if there was a
>way to do it in emacs, hopefully as a mode.

[ Let's not forget that this is a forum for discussion of all types of Emacs
  editors.  Most nontrivial questions have different answers depending
  on the Emacs used.  Please be specific as to which Emacs you use. ]

I'll answer w.r.t GNU Emacs.

Use Indented Text mode and bind RET to newline-and-indent.

`M-x indented-text-mode' gets you into Indented Text mode and you can
put the following in your .emacs file to make the binding apply only
to Indented Text mode.

(define-key indented-text-mode-map "\r" 'newline-and-indent)

derrell@retix.retix.retix.com (Derrell Lipman) (03/03/89)

In article <1045@wpi.wpi.edu> guardian@wpi.wpi.edu (Robert W Langer) writes:

> Is there a way to have emacs indent each line the same as the last
> instead of going back to the margin each time return is hit.  This is
> used in some programming editors, and I was wondering if there was a
> way to do it in emacs, hopefully as a mode.
> 

here is a function which sets the fill prefix to a bunch of blanks.
if you indent to column 23, and then execute this function, the fill
prefix will be set to 23 blanks and pressing return will automagically
indent to column 23 (in text mode).  resetting the indentation is
accomplished by executing this command from the left-most column.

i have bound this command to "C-Q ."
i use C-Q for my local functions, and this function is very similar to
"C-X ." (set-fill-prefix).

(defun set-fill-prefix-all-blanks ()
  (interactive)
  (setq fill-prefix (make-string (current-column) 32)))

--


--derrell    (derrell@retix)

------------------------------------------------------------------------------
"The process of living is the process of reacting to stress."