From xemacs-m  Wed Jun  4 11:36:31 1997
Received: from mercury.Sun.COM (mercury.Sun.COM [192.9.25.1])
	by xemacs.org (8.8.5/8.8.5) with SMTP id LAA16222
	for <xemacs-beta@xemacs.org>; Wed, 4 Jun 1997 11:36:29 -0500 (CDT)
Received: from Corp.Sun.COM ([129.145.35.78]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id JAA24173; Wed, 4 Jun 1997 09:54:26 -0700
Received: from legba.Corp.Sun.COM by Corp.Sun.COM (SMI-8.6/SMI-5.3)
	id JAA16433; Wed, 4 Jun 1997 09:36:50 -0700
Received: by legba.Corp.Sun.COM (SMI-8.6/SMI-SVR4)
	id JAA13583; Wed, 4 Jun 1997 09:36:48 -0700
To: xemacs-beta@xemacs.org
Cc: cc-mode-help@python.org
Subject: cc-mode delete behavior [PATCH]
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: multipart/mixed;
 boundary="Multipart_Wed_Jun__4_09:36:48_1997-1"
Content-Transfer-Encoding: 7bit
From: Gary.Foster@Corp.Sun.COM (Gary D. Foster)
Date: 04 Jun 1997 09:36:48 -0700
Message-ID: <bcipvu2pbof.fsf@corp.Sun.COM>
Lines: 91
X-Mailer: Gnus v5.4.55/XEmacs 20.3(beta3)

--Multipart_Wed_Jun__4_09:36:48_1997-1
Content-Type: text/plain; charset=US-ASCII

Ok, I put a patch together to make cc-mode honor the desired delete
behavior (either forwards or backwards).  It works in both normal and
'hungry' mode and seems to work well in tty mode as well.  I also
removed the hook and rebound DEL to the c-electric-delete function via
define-keys so I can hopefully dispel all remaining doubts that this
is a "hook solution".  It's not.  This should prove that. ;)

It was pretty simple to get it to check the desired delete direction,
and it should work normally in nearly all cases (checks with
boundp/fboundp, etc).  This patch should be applied against the
version of cc-mode.el in the b3 release, since it 'undoes' the stuff I 
did to cc-mode before.

Beat it up, knock it down, and try and steal it's lunch money please.

-- Gary F.

--Multipart_Wed_Jun__4_09:36:48_1997-1
Content-Type: text/plain; name="cc-mode.patch"; charset=US-ASCII

--- lisp/modes/cc-mode.el.orig	Wed Jun  4 09:18:55 1997
+++ lisp/modes/cc-mode.el	Wed Jun  4 09:27:31 1997
@@ -481,7 +481,9 @@
 This hook gets called after a line is indented by the mode."
   :type 'hook
   :group 'cc-indent)
-(defcustom c-delete-function 'backward-delete-char-untabify
+(defcustom c-delete-function (if (fboundp 'backspace-or-delete)
+				 'backspace-or-delete
+			       'backward-delete-char-untabify)
   "*Function called by `c-electric-delete' when deleting characters."
   :type 'function
   :group 'cc-mode)
@@ -1035,8 +1037,7 @@
   (define-key c-mode-map "\C-c\C-p"  'c-backward-conditional)
   (define-key c-mode-map "\C-c\C-u"  'c-up-conditional)
   (define-key c-mode-map "\t"        'c-indent-command)
-;; GDF - don't rebind the DEL key
-;;  (define-key c-mode-map "\177"      'c-electric-delete)
+  (define-key c-mode-map "\177"      'c-electric-delete)
   ;; these are new keybindings, with no counterpart to BOCM
   (define-key c-mode-map ","         'c-electric-semi&comma)
   (define-key c-mode-map "*"         'c-electric-star)
@@ -1428,8 +1429,6 @@
 \\{c-mode-map}"
   (interactive)
   (kill-all-local-variables)
-  (make-local-hook 'backspace-or-delete-hook)
-  (add-hook 'backspace-or-delete-hook 'c-electric-delete nil t)
   (set-syntax-table c-mode-syntax-table)
   (setq major-mode 'c-mode
 	mode-name "C"
@@ -1941,23 +1940,25 @@
 
 ;; COMMANDS
 (defun c-electric-delete (arg)
-  "Deletes preceding character or whitespace.
+  "Deletes preceding or following character or whitespace.
 If `c-hungry-delete-key' is non-nil, as evidenced by the \"/h\" or
-\"/ah\" string on the mode line, then all preceding whitespace is
-consumed.  If however an ARG is supplied, or `c-hungry-delete-key' is
-nil, or point is inside a literal then the function in the variable
-`c-delete-function' is called."
+\"/ah\" string on the mode line, then all preceding or following
+whitespace is consumed.  If however an ARG is supplied, or
+`c-hungry-delete-key' is nil, or point is inside a literal then the
+function in the variable `c-delete-function' is called."
   (interactive "P")
   (if (or (not c-hungry-delete-key)
 	  arg
 	  (c-in-literal))
       (funcall c-delete-function (prefix-numeric-value arg))
     (let ((here (point)))
-      (skip-chars-backward " \t\n")
+      (if (and (boundp 'delete-erases-forward)
+	       delete-erases-forward)
+	  (skip-chars-forward " \t\n")
+	(skip-chars-backward " \t\n"))
       (if (/= (point) here)
 	  (delete-region (point) here)
-	(funcall c-delete-function 1))))
-  t)
+	(funcall c-delete-function 1)))))
 
 (defun c-electric-pound (arg)
   "Electric pound (`#') insertion.

--Multipart_Wed_Jun__4_09:36:48_1997-1--

