From xemacs-m  Tue Jan 28 15:41:48 1997
Received: from atreides.mindspring.com (atreides.mindspring.com [204.180.142.236])
          by xemacs.org (8.8.4/8.8.4) with SMTP
	  id PAA27333 for <xemacs-beta@xemacs.org>; Tue, 28 Jan 1997 15:41:48 -0600 (CST)
Received: (qmail 17812 invoked by uid 52477); 28 Jan 1997 21:41:38 -0000
Sender: sj@atreides.mindspring.com
To: XEmacs beta <xemacs-beta@xemacs.org>
Subject: Re: (global-set-key "\C-m" 'newline-and-indent)
References: <kig20b62l6j.fsf@jagor.srce.hr> 	<m2lo9d21o4.fsf@altair.xemacs.org> 	<m2hgk1ivcd.fsf@proletcult.slip.ifi.uio.no> 	<m2raj5zo1w.fsf@altair.xemacs.org> 	<m2n2tty6io.fsf@proletcult.slip.ifi.uio.no> 	<rvraj5siyl.fsf@sdnp5.ucsd.edu> <199701281938.OAA07255@anthem.CNRI.Reston.Va.US>
Mime-Version: 1.0 (generated by tm-edit 7.100)
Content-Type: text/plain; charset=US-ASCII
From: Sudish Joseph <sudish@mindspring.com>
Date: 28 Jan 1997 16:41:38 -0500
In-Reply-To: "Barry A. Warsaw"'s message of Tue, 28 Jan 1997 14:38:46 -0500
Message-ID: <yvialo9dlbot.fsf@atreides.mindspring.com>
Lines: 41
X-Mailer: Red Gnus v0.82/XEmacs 20.0

Barry A Warsaw writes:
> Funny.  I bind RET to newline-and-indent in all language modes!  It's
> always worked well for me.

Ditto here.  I've also got the following, inspired by your cc-mode and
by cperl-mode--it takes things just that little bit further.

(defun sj/elisp-electric-close-paren ()
  "Insert close parenthesis, go to the next line and indent."
  (interactive)
  (and (memq (preceding-char) '(?\  ?\t ?\n))
       (sj/elisp-electric-delete))
  (insert ?\))
  (newline-and-indent))

It's not that bad, honest--successive close-parens DTRT.  Well,
almost, it does need the smarts to not insert a newline inside a
string.  Try it, watch your life change for the better. :>

Here's the rest of it.

(defun sj/elisp-electric-delete (&optional arg)
    "Deletes all preceding whitespace.
If however an ARG is supplied,  or point is inside a literal then
a normal delete is carried out"
    (interactive "P")
    (if arg
	;; do nothing special
	(backward-delete-char-untabify (prefix-numeric-value arg))
      (let ((here (point)))
	(skip-chars-backward " \t\n")
	(if (/= (point) here)
	    (delete-region (point) here)
	  (backward-delete-char-untabify 1)))))

(define-key shared-lisp-mode-map "\C-m" 'newline-and-indent)
(define-key shared-lisp-mode-map "\C-j" 'eval-print-last-sexp)
(define-key shared-lisp-mode-map "\177" 'sj/elisp-electric-delete)
(define-key shared-lisp-mode-map ")"    'sj/elisp-electric-close-paren)

-Sudish

